AnhLedger's picture
Add Role Entity
9ec4f32
raw
history blame
1.03 kB
import {
Entity,
Column,
BaseEntity,
PrimaryGeneratedColumn,
OneToMany,
ManyToOne,
Relation,
JoinColumn,
} from 'typeorm';
import { BranchEntity } from './branch.entity.js';
import { RoleEntity } from './role.entity.js';
@Entity('users')
export class UserEntity extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: true })
avatar: string;
@Column({ nullable: true })
full_name: string;
@Column({ nullable: true })
phone_number: string;
@Column({ nullable: true })
address: string;
@Column({ nullable: true })
email: string;
@Column({ nullable: true })
role_id: number;
@Column({ nullable: true })
hash_password: string;
@Column({ default: true })
is_valid: boolean;
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
create_at: Date;
@OneToMany(() => BranchEntity, (branch) => branch.owner)
branches: Relation<BranchEntity>[];
@ManyToOne(() => RoleEntity)
@JoinColumn({ name: 'role_id'})
role: RoleEntity;
}