Add models
This commit is contained in:
parent
d7149bc5d9
commit
0140d93b9a
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { Model, Table, Column, DataType } from "sequelize-typescript";
|
||||||
|
|
||||||
|
import Hotel from "./hotel.model.ts";
|
||||||
|
import Client from "./client.model.ts";
|
||||||
|
|
||||||
|
@Table({
|
||||||
|
tableName: "HotelBooking",
|
||||||
|
})
|
||||||
|
export default class Booking extends Model {
|
||||||
|
@Unique
|
||||||
|
@Column({
|
||||||
|
type: DataType.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
field: "id"
|
||||||
|
})
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@ForeignKey(() => Hotel)
|
||||||
|
@Column({
|
||||||
|
type: DataType.INTEGER,
|
||||||
|
field: "HotelId"
|
||||||
|
})
|
||||||
|
hotelId: number;
|
||||||
|
|
||||||
|
@BelongsTo(() => Hotel)
|
||||||
|
hotel: Hotel;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Name"
|
||||||
|
})
|
||||||
|
name?: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Address"
|
||||||
|
})
|
||||||
|
address?: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.DATE,
|
||||||
|
field: "CreatedDate"
|
||||||
|
defaultValue: DataType.NOW
|
||||||
|
})
|
||||||
|
createdDate: Date;
|
||||||
|
|
||||||
|
@ForeignKey(() => Client)
|
||||||
|
@Column({
|
||||||
|
type: DataType.INTEGER,
|
||||||
|
field: "clientId"
|
||||||
|
})
|
||||||
|
clientId: number;
|
||||||
|
|
||||||
|
@BelongsTo(() => Client)
|
||||||
|
client: Client;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import { Model, Table, Column, DataType } from "sequelize-typescript";
|
||||||
|
|
||||||
|
import Hotel from "./hotel.model.ts";
|
||||||
|
import Booking from "./booking.model.ts";
|
||||||
|
|
||||||
|
@Table({
|
||||||
|
tableName: "Client",
|
||||||
|
})
|
||||||
|
export default class Client extends Model {
|
||||||
|
@Unique
|
||||||
|
@Column({
|
||||||
|
type: DataType.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
field: "id"
|
||||||
|
})
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Name"
|
||||||
|
})
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Address"
|
||||||
|
})
|
||||||
|
address: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Phone"
|
||||||
|
})
|
||||||
|
phone: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.DATE,
|
||||||
|
field: "CreatedDate"
|
||||||
|
defaultValue: DataType.NOW
|
||||||
|
})
|
||||||
|
createdDate: Date;
|
||||||
|
|
||||||
|
@HasMany(() => Booking)
|
||||||
|
bookings: Booking[];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { Model, Table, Column, DataType } from "sequelize-typescript";
|
||||||
|
|
||||||
|
import Client from "./client.model.ts";
|
||||||
|
import Booking from "./booking.model.ts";
|
||||||
|
|
||||||
|
@Table({
|
||||||
|
tableName: "Hotel",
|
||||||
|
})
|
||||||
|
export default class Hotel extends Model {
|
||||||
|
@Unique
|
||||||
|
@Column({
|
||||||
|
type: DataType.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
field: "id"
|
||||||
|
})
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Name"
|
||||||
|
})
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.STRING(255),
|
||||||
|
field: "Address"
|
||||||
|
})
|
||||||
|
address: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: DataType.DATE,
|
||||||
|
field: "CreatedDate"
|
||||||
|
defaultValue: DataType.NOW
|
||||||
|
})
|
||||||
|
createdDate: Date;
|
||||||
|
|
||||||
|
@HasMany(() => Booking)
|
||||||
|
bookings: Booking[];
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue