You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1012 B
47 lines
1012 B
import { Model, Table, Column, ForeignKey, BelongsTo, DataType } from "sequelize-typescript"; |
|
import { User } from "../../users/entities/user.entity"; |
|
import { Product } from "../../shop/entities/product.entity"; |
|
import { Invoice } from "./invoice.entity"; |
|
|
|
@Table |
|
export class Cart extends Model<Cart> { |
|
@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.INTEGER, |
|
allowNull: true, |
|
}) |
|
productPrice: number; |
|
|
|
@Column({ |
|
type: DataType.ENUM("open", "closed"), |
|
allowNull: false, |
|
defaultValue: "open", |
|
}) |
|
status: "open" | "closed"; |
|
}
|
|
|