add types and schemas
This commit is contained in:
44
src/database/entities/hotel-schedule.entity.ts
Normal file
44
src/database/entities/hotel-schedule.entity.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Hotel } from "@/database/entities/hotel.entity";
|
||||
import { PackageDetail } from "@/database/entities/package-detail.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class HotelSchedule {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => Hotel)
|
||||
hotel!: Rel<Hotel>;
|
||||
|
||||
@Property({ type: "time" })
|
||||
checkIn!: string;
|
||||
|
||||
@Property({ type: "time" })
|
||||
checkOut!: string;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Inverse side
|
||||
|
||||
@ManyToMany(() => PackageDetail, (packageDetail) => packageDetail.tourHotels)
|
||||
tourPackageDetails = new Collection<PackageDetail>(this);
|
||||
}
|
||||
Reference in New Issue
Block a user