Add all database tables with relations
This commit is contained in:
27
software/backend/models/orderedItem.model.ts
Normal file
27
software/backend/models/orderedItem.model.ts
Normal 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[]
|
||||
}
|
||||
Reference in New Issue
Block a user