34 lines
567 B
TypeScript
34 lines
567 B
TypeScript
import { Country } from "@/database/entities/country.entity";
|
|
import {
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryKey,
|
|
Property,
|
|
type Rel,
|
|
} from "@mikro-orm/core";
|
|
|
|
@Entity()
|
|
export class City {
|
|
@PrimaryKey({ type: "varchar", length: 30 })
|
|
id!: string;
|
|
|
|
@Property({ type: "varchar", length: 100 })
|
|
name!: string;
|
|
|
|
@ManyToOne(() => Country)
|
|
country!: Rel<Country>;
|
|
|
|
@Property({
|
|
type: "timestamp",
|
|
onCreate: () => new Date(),
|
|
})
|
|
createdAt!: Date;
|
|
|
|
@Property({
|
|
type: "timestamp",
|
|
onCreate: () => new Date(),
|
|
onUpdate: () => new Date(),
|
|
})
|
|
updatedAt!: Date;
|
|
}
|