crud product
This commit is contained in:
@@ -1,15 +1,29 @@
|
||||
import { Entity, Property } from '@mikro-orm/core';
|
||||
import { Collection, Entity, ManyToOne, OneToMany, Property } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Category } from './category.entity';
|
||||
import { Attribute } from './attribute.entity';
|
||||
|
||||
|
||||
@Entity({ tableName: 'products' })
|
||||
export class product extends BaseEntity {
|
||||
export class Product extends BaseEntity {
|
||||
@Property({ primary: true })
|
||||
id: bigint
|
||||
|
||||
@ManyToOne(() => Category)
|
||||
category: Category
|
||||
|
||||
@OneToMany(() => Attribute, (attr) => attr.productId)
|
||||
attributes = new Collection<Attribute>(this)
|
||||
|
||||
@Property()
|
||||
title: string;
|
||||
|
||||
@Property({ type: 'json' })
|
||||
desc: string[]
|
||||
|
||||
@Property()
|
||||
prepareTime: number;
|
||||
|
||||
@Property({ type: 'text', nullable: true })
|
||||
linkUrl?: string;
|
||||
|
||||
@@ -19,4 +33,7 @@ export class product extends BaseEntity {
|
||||
@Property({ type: 'json', nullable: true })
|
||||
images?: string[];
|
||||
|
||||
@Property({ type: 'int' })
|
||||
order?: number | null
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user