Move software files one directory up, Readme
This commit is contained in:
46
backend/models/ordering/order.model.ts
Normal file
46
backend/models/ordering/order.model.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany, BelongsToMany, Default } from 'sequelize-typescript';
|
||||
import { Account } from '../user/account.model';
|
||||
import { Ticket } from './ticket.model';
|
||||
import { Address } from '../user/address.model';
|
||||
import { Payment } from '../user/payment.model';
|
||||
|
||||
@Table({
|
||||
updatedAt: false,
|
||||
createdAt: 'orderedAt'
|
||||
})
|
||||
export class Order extends Model {
|
||||
@Column
|
||||
@ForeignKey(() => Account)
|
||||
accountId: number
|
||||
|
||||
@Column
|
||||
orderedAt: Date
|
||||
|
||||
@ForeignKey(() => Address)
|
||||
@Column
|
||||
addressId: number
|
||||
|
||||
@ForeignKey(() => Payment)
|
||||
@Column
|
||||
paymentId: number
|
||||
|
||||
@Default(false)
|
||||
@Column
|
||||
shipped: boolean
|
||||
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => Account)
|
||||
account: Account
|
||||
|
||||
@BelongsTo(() => Address)
|
||||
address: Address
|
||||
|
||||
@BelongsTo(() => Payment)
|
||||
payment: Payment
|
||||
|
||||
@HasMany(() => Ticket)
|
||||
tickets: Ticket[]
|
||||
}
|
||||
33
backend/models/ordering/ticket.model.ts
Normal file
33
backend/models/ordering/ticket.model.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Model, BelongsTo, Column, ForeignKey, HasMany, HasOne, Table } from "sequelize-typescript";
|
||||
import { Concert } from "../acts/concert.model";
|
||||
import { Order } from "./order.model";
|
||||
import { Seat } from "../locations/seat.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Ticket extends Model {
|
||||
@Column
|
||||
@ForeignKey(() => Order)
|
||||
orderId: number
|
||||
|
||||
@Column
|
||||
orderPrice: number
|
||||
|
||||
@Column
|
||||
@ForeignKey(() => Concert)
|
||||
concertId: number
|
||||
|
||||
@Column
|
||||
@ForeignKey(() => Seat)
|
||||
seatId: number
|
||||
|
||||
|
||||
// Relations
|
||||
@BelongsTo(() => Order)
|
||||
order: Order
|
||||
|
||||
@BelongsTo(() => Concert)
|
||||
concert: Concert
|
||||
|
||||
@BelongsTo(() => Seat)
|
||||
seat: Seat
|
||||
}
|
||||
Reference in New Issue
Block a user