import { Column , Entity , OneToOne , Unique , JoinColumn } from 'typeorm' ; import { IsEnum , IsString , IsObject } from 'class-validator' ; import { User } from './Users' ; import { BaseModel } from './BaseModel' ; import { Provider } from './Enum' ; @ Entity ( ) @ Unique ( [ 'clientId' , 'user' ] ) export class UserAccount extends BaseModel { @ IsEnum ( Provider ) @ Column ( { type : 'enum' , enum : Provider } ) provider ! : Provider ; @ IsString ( ) @ Column ( { length : 50 } ) clientId ! : string ; @ IsObject ( ) @ OneToOne ( ( _ ) => User , ( user ) => user . userAccount , { nullable : true } ) @ JoinColumn ( ) user ? : User ; }