File

src/modules/user/entities/user.entity.ts

Extends

AbstractEntity

Index

Properties
Methods

Properties

Optional avatar
Type : string
Decorators :
@Column({nullable: true})
createdAt
Type : Date
Decorators :
@CreateDateColumn({type: 'timestamp with time zone'})
dtoClass
Default value : UserDto
email
Type : string
Decorators :
@Column({unique: true})
firstName
Type : string
Decorators :
@Column()
lastName
Type : string
Decorators :
@Column()
partner
Type : PartnerEntity
Decorators :
@ManyToOne(undefined, undefined, {nullable: true, onDelete: 'CASCADE'})
updatedAt
Type : Date
Decorators :
@UpdateDateColumn({type: 'timestamp with time zone', nullable: true})
userAuth
Type : UserAuthEntity
Decorators :
@OneToOne(undefined, undefined)
userConfig
Type : UserConfigEntity
Decorators :
@OneToOne(undefined, undefined)
Abstract dtoClass
Inherited from AbstractEntity
Defined in AbstractEntity:13
id
Type : number
Decorators :
@PrimaryGeneratedColumn('increment')
Inherited from AbstractEntity
Defined in AbstractEntity:7
uuid
Type : string
Decorators :
@Column()
@Generated('uuid')
Inherited from AbstractEntity
Defined in AbstractEntity:11

Methods

emailToLowerCase
emailToLowerCase()
Decorators :
@BeforeInsert()
Returns : void
toDto
toDto(options?: any)
Inherited from AbstractEntity
Defined in AbstractEntity:15
Parameters :
Name Type Optional
options any Yes
Returns : T
import { AbstractEntity } from 'common/entities';
import { UserDto } from 'modules/user/dtos';
import { UserAuthEntity, UserConfigEntity } from 'modules/user/entities';
import { PartnerEntity } from 'modules/partner/entities';
import {
  Column,
  CreateDateColumn,
  Entity,
  OneToMany,
  ManyToOne,
  JoinColumn,
  BeforeInsert,
  OneToOne,
  UpdateDateColumn,
} from 'typeorm';

@Entity({ name: 'users' })
export class UserEntity extends AbstractEntity<UserDto> {
  @Column()
  firstName: string;

  @Column()
  lastName: string;

  @Column({ unique: true })
  email: string;

  @Column({ nullable: true })
  avatar?: string;

  @CreateDateColumn({
    type: 'timestamp with time zone',
  })
  createdAt: Date;

  @UpdateDateColumn({
    type: 'timestamp with time zone',
    nullable: true,
  })
  updatedAt: Date;

  @OneToOne(() => UserAuthEntity, (userAuth: UserAuthEntity) => userAuth.user)
  userAuth: UserAuthEntity;

  @OneToOne(
    () => UserConfigEntity,
    (userConfig: UserConfigEntity) => userConfig.user,
  )
  userConfig: UserConfigEntity;

  @ManyToOne(() => PartnerEntity, (parnter: PartnerEntity) => parnter.user, {
    nullable: true,
    onDelete: 'CASCADE',
  })
  partner : PartnerEntity;

  @BeforeInsert()
  emailToLowerCase() {
      this.email = this.email.toLowerCase();
  }

  dtoClass = UserDto;
}

result-matching ""

    No results matching ""