Spaces:
Sleeping
Sleeping
import { | |
Entity, | |
Column, | |
BaseEntity, | |
PrimaryGeneratedColumn, | |
OneToMany, | |
ManyToOne, | |
Relation, | |
JoinColumn, | |
CreateDateColumn, | |
} from 'typeorm'; | |
import { BranchEntity } from './branch.entity.js'; | |
import { IsOptional } from 'class-validator'; | |
import { Role } from '../common/enums/role.enum.js'; | |
import { ReceiptEntity } from './receipt.entity.js'; | |
'users') | (|
export class UserEntity extends BaseEntity { | |
'uuid') | (|
id: string; | |
() | |
nullable: true }) | ({|
avatar: string; | |
() | |
full_name: string; | |
unique: true }) | ({|
phone_number: string; | |
() | |
nullable: true }) | ({|
address: string; | |
nullable: true, unique: true }) | ({|
email: string; | |
type: 'enum', enum: Role, default: 'CUSTOMER' }) | ({|
role: Role; | |
() | |
hash_password: string; | |
default: true }) | ({|
is_valid: boolean; | |
() | |
create_at: Date; | |
() => BranchEntity, (branch) => branch.owner) | (|
branches: Relation<BranchEntity>[]; | |
() => ReceiptEntity, (receipt) => receipt.sender) | (|
in_receipts: Relation<ReceiptEntity>[]; | |
() => ReceiptEntity, (receipt) => receipt.receiver) | (|
out_receipts: Relation<ReceiptEntity>[]; | |
() => BranchEntity, { nullable: true }) | (|
name: 'branch_id' }) // Tùy chỉnh tên cột là branch_id | ({|
branch: Relation<BranchEntity>; | |
nullable: true }) | ({|
branch_id: string; | |
} | |