25 lines
601 B
TypeScript
25 lines
601 B
TypeScript
import { Entity, PrimaryKey, Property, OptionalProps } from '@mikro-orm/core';
|
|
|
|
@Entity({ tableName: 'admns' })
|
|
export class Admin {
|
|
[OptionalProps]?: 'id' | 'createdAt' | 'updatedAt';
|
|
|
|
@PrimaryKey()
|
|
id!: number;
|
|
|
|
@Property({ nullable: true })
|
|
firstName?: string;
|
|
|
|
@Property({ nullable: true })
|
|
lastName?: string;
|
|
|
|
@Property({ unique: true })
|
|
phone!: string;
|
|
|
|
@Property({ defaultRaw: 'now()', columnType: 'timestamptz' })
|
|
createdAt: Date = new Date();
|
|
|
|
@Property({ onUpdate: () => new Date(), defaultRaw: 'now()', columnType: 'timestamptz' })
|
|
updatedAt: Date = new Date();
|
|
}
|