Files
negareh-api/src/modules/admin/entities/admin.entity.ts
T
2026-02-01 10:35:09 +03:30

39 lines
1.0 KiB
TypeScript

import { Cascade, Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { normalizePhone } from '../../util/phone.util';
import { Role } from 'src/modules/roles/entities/role.entity';
import { ulid } from 'ulid';
import { NotificationPreference } from 'src/modules/notification/entities/notification-preference.entity';
@Entity({ tableName: 'admins' })
export class Admin extends BaseEntity {
@PrimaryKey({ type: 'string', columnType: 'char(26)' })
id: string = ulid()
@Property({ nullable: true })
firstName?: string;
@Property({ nullable: true })
lastName?: string;
private _phone!: string;
@Property({ unique: true })
get phone(): string {
return this._phone;
}
set phone(value: string) {
this._phone = normalizePhone(value);
}
@ManyToOne(() => Role)
role: Role
// @OneToOne(() => NotificationPreference, pref => pref.admin, {
// })
// notificationPreference!: NotificationPreference;
}