chore: first
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { Collection, Entity, EntityRepositoryType, ManyToOne, OneToMany, Opt, Property } from "@mikro-orm/core";
|
||||
|
||||
import { RefreshToken } from "./refresh-token.entity";
|
||||
import { Role } from "./role.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { UserRepository } from "../repositories/user.repository";
|
||||
|
||||
@Entity({ repository: () => UserRepository })
|
||||
export class User extends BaseEntity {
|
||||
@Property({ type: "varchar", length: 150, nullable: true })
|
||||
email?: string;
|
||||
|
||||
@Property({ type: "varchar", length: 11, unique: true, nullable: false })
|
||||
phone!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 50, unique: true, nullable: true })
|
||||
userName!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 150 })
|
||||
password!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 150 })
|
||||
firstName!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
lastName!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 12, nullable: true })
|
||||
birthDate?: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100, unique: true, nullable: true })
|
||||
nationalCode?: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100, nullable: true })
|
||||
profilePic?: string;
|
||||
|
||||
@Property({ type: "boolean", default: false })
|
||||
emailVerified!: boolean & Opt;
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
@ManyToOne(() => Role, { deleteRule: "restrict" })
|
||||
role!: Role;
|
||||
|
||||
//-----------------------------------
|
||||
|
||||
@OneToMany(() => RefreshToken, (token) => token.user)
|
||||
refreshTokens = new Collection<RefreshToken>(this);
|
||||
|
||||
[EntityRepositoryType]?: UserRepository;
|
||||
}
|
||||
Reference in New Issue
Block a user