Add all database tables with relations

This commit is contained in:
2024-09-04 17:06:41 +02:00
parent 955758ec4c
commit 7ca15a66b3
6 changed files with 114 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany } from 'sequelize-typescript';
import { Orders } from './orders.model';
import { Products } from './products.model';
@Table
export class OrderedItem extends Model {
@Column
@ForeignKey(() => Orders)
orderId: number
@Column
@ForeignKey(() => Products)
productId: number
@Column
quantity: number
@Column
totalPrice: number
// Relations
@BelongsTo(() => Orders)
order: Orders
@HasMany(() => Products)
products: Products[]
}