setup database, entities, and migrations
This commit is contained in:
43
src/database/entities/hotel-facility.entity.ts
Normal file
43
src/database/entities/hotel-facility.entity.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Hotel } from "@/database/entities/hotel.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class HotelFacility {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
icon!: string;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@ManyToMany(() => Hotel, (hotel) => hotel.facilities)
|
||||
hotels = new Collection<HotelFacility>(this);
|
||||
}
|
||||
Reference in New Issue
Block a user