45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { Entity, Index, Property, OneToMany, Collection, PrimaryKey, OptionalProps } from '@mikro-orm/core';
|
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
|
import { LearningProgress } from '../../learnings/entities/learning-progress.entity';
|
|
import { Criticism } from '../../criticisms/entities/criticism.entity';
|
|
|
|
|
|
@Entity({ tableName: 'users' })
|
|
export class User extends BaseEntity {
|
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
|
|
|
@OneToMany(() => LearningProgress, (lp) => lp.user)
|
|
learningProgress = new Collection<LearningProgress>(this);
|
|
|
|
@OneToMany(() => Criticism, (c) => c.user)
|
|
criticisms = new Collection<Criticism>(this);
|
|
|
|
// @OneToMany(() => Order, order => order.user)
|
|
// orders = new Collection<Order>(this);
|
|
|
|
|
|
@Property({ nullable: true })
|
|
firstName?: string;
|
|
|
|
@Property({ nullable: true })
|
|
lastName?: string;
|
|
|
|
|
|
@Property({ unique: true })
|
|
phone: string
|
|
|
|
|
|
@Property({ default: true })
|
|
isActive?: boolean = true;
|
|
|
|
@Property({ default: true, nullable: true })
|
|
gender?: boolean;
|
|
|
|
|
|
@Property({ default: 0 })
|
|
maxCredit: number;
|
|
|
|
@Property({ type: 'string', nullable: true })
|
|
addresse?: string
|
|
}
|