Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Created January 17, 2020 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/2a31998bd56c8ede7e8f2ceb0eb9a92c to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/2a31998bd56c8ede7e8f2ceb0eb9a92c to your computer and use it in GitHub Desktop.
TypeORM ManyToMany Kullanımı.
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, ManyToMany } from 'typeorm';
import { ObjectType, Field, ID } from 'type-graphql';
import { User } from '../user/user.entity';
@Entity()
@ObjectType()
export class Author extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
@Field(() => ID)
id: string;
@Column()
@Field()
title: string
// yazari begenenler
@ManyToMany(() => User, user => user.begenilenYazarlar, { lazy: true })
@Field(() => [User])
yazariBegenenler: Promise<User[]>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment