19 lines
487 B
TypeScript
19 lines
487 B
TypeScript
import { Cascade, Entity, Property, OneToOne } from '@mikro-orm/core';
|
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
|
import { Food } from '../../foods/entities/food.entity';
|
|
|
|
@Entity({ tableName: 'inventory' })
|
|
export class Inventory extends BaseEntity {
|
|
@OneToOne(() => Food, {
|
|
cascade: [Cascade.ALL],
|
|
orphanRemoval: true,
|
|
})
|
|
food!: Food;
|
|
|
|
@Property({ type: 'int' })
|
|
totalStock!: number;
|
|
|
|
@Property({ type: 'int' })
|
|
availableStock!: number;
|
|
}
|