Skip to content

Instantly share code, notes, and snippets.

@nmchenry01
Created August 20, 2020 10:42
Show Gist options
  • Select an option

  • Save nmchenry01/d4ec2d7024c79c37164dad7d3f9903ee to your computer and use it in GitHub Desktop.

Select an option

Save nmchenry01/d4ec2d7024c79c37164dad7d3f9903ee to your computer and use it in GitHub Desktop.
Product entity for "Prisma vs. TypeORM"
@Entity()
export class Product {
@PrimaryGeneratedColumn()
id: number;
@Column({ unique: true })
name: string;
@Column({ nullable: true })
description?: string;
@CreateDateColumn()
createdAt: string;
@ManyToOne(() => Company, (company) => company.products)
@JoinColumn({ name: 'companyId' })
company: Company;
@ManyToMany(() => Customer, (customer) => customer.products)
customers: Customer[];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment