import { Model, Table, Column, ForeignKey, BelongsTo, DataType } from "sequelize-typescript"; import { User } from "../../users/entities/user.entity"; import { Product } from "../../products/entities/product.entity"; import { Invoice } from "src/invoice/entities/invoice.entity"; @Table export class Cart extends Model { @ForeignKey(() => User) @Column userId: number; @BelongsTo(() => User, { onDelete: "CASCADE" }) user: User; @ForeignKey(() => Product) @Column productId: number; @BelongsTo(() => Product, { onDelete: "CASCADE" }) product: Product; @ForeignKey(() => Invoice) @Column invoiceId: number; @BelongsTo(() => Invoice, { onDelete: "CASCADE" }) invoice: Invoice; @Column({ type: DataType.INTEGER, allowNull: true, }) quantity: number; @Column({ type: DataType.DECIMAL(10, 2), allowNull: true, }) productPrice: number; @Column({ type: DataType.ENUM("open", "closed"), allowNull: false, defaultValue: "open", }) status: "open" | "closed"; }