UNPKG

@tomei/product

Version:

NestJS package for product module

125 lines (98 loc) 2.58 kB
import { BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, Model, Table, UpdatedAt, } from 'sequelize-typescript'; import { ProductModel } from './product.entity'; import { YN } from '../enum/yn.enum'; import { ProductVariantStatus, ProductVariantType, } from '../enum/product-variant.enum'; import { ProductVariantWithInventoryModel } from './product-variant-with-inventory.entity'; @Table({ tableName: 'product_Variant' }) export class ProductVariantModel extends Model { @Column({ type: DataType.STRING, allowNull: false, primaryKey: true, }) VariantId: string; @ForeignKey(() => ProductModel) @Column({ primaryKey: true, allowNull: false, type: DataType.STRING, }) ProductId: string; @Column({ type: DataType.STRING(1000) }) Name: string; @Column({ type: DataType.STRING(3000) }) Description: string; @Column({ unique: true, allowNull: false, type: DataType.STRING(30) }) SKU: string; @Column({ type: DataType.STRING(20) }) Size: string; @Column({ type: DataType.STRING(20) }) Colour: string; @Column({ type: DataType.ENUM( 'Size', 'Colour', 'Weight', 'Width', 'Height', 'Length', 'Others', ), }) Type: ProductVariantType; @Column({ type: DataType.INTEGER }) Level: number; @Column({ type: DataType.STRING(30) }) ParentId: string; @Column({ type: DataType.DECIMAL(10, 2) }) MinWeight: number; @Column({ type: DataType.DECIMAL(10, 2) }) MaxWeight: number; @Column({ type: DataType.DECIMAL(10, 2) }) MinWidth: number; @Column({ type: DataType.DECIMAL(10, 2) }) MaxWidth: number; @Column({ type: DataType.DECIMAL(10, 2) }) MinHeight: number; @Column({ type: DataType.DECIMAL(10, 2) }) MaxHeight: number; @Column({ type: DataType.DECIMAL(10, 2) }) MinLength: number; @Column({ type: DataType.DECIMAL(10, 2) }) MaxLength: number; @CreatedAt CreatedAt: Date; @UpdatedAt UpdatedAt: Date; @Column({ type: DataType.ENUM('Active', 'Inactive', 'Deleted', 'Discontinued'), defaultValue: 'Active', }) Status: ProductVariantStatus; @Column({ type: DataType.STRING, allowNull: false }) CreatedById: string; @Column({ type: DataType.STRING, allowNull: false }) UpdatedById: string; @Column({ type: DataType.ENUM('Y', 'N'), defaultValue: 'N', }) UpdatedSSYN: YN; @BelongsTo(() => ProductModel) Product: ProductModel; @HasMany(() => ProductVariantWithInventoryModel) ProductVariantWithInventory: ProductVariantWithInventoryModel[]; }