File

src/modules/partner/entities/partner.entity.ts

Extends

AbstractEntity

Index

Properties
Methods

Properties

address
Type : string
Decorators :
@Column({nullable: true})
contact
Type : string
Decorators :
@Column({nullable: true})
createdAt
Type : Date
Decorators :
@CreateDateColumn({type: 'timestamp with time zone'})
dtoClass
Default value : PartnerDto
email
Type : string
Decorators :
@Column({unique: true})
name
Type : string
Decorators :
@Column({unique: true})
updatedAt
Type : Date
Decorators :
@UpdateDateColumn({type: 'timestamp with time zone', nullable: true})
user
Type : UserEntity[]
Decorators :
@OneToMany(undefined, undefined, {nullable: true})
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

toLowerCase
toLowerCase()
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 {
  Column,
  CreateDateColumn,
  Entity,
  OneToMany,
  UpdateDateColumn,
  JoinColumn,
  BeforeInsert
} from 'typeorm';
import { PartnerDto } from 'modules/partner/dtos';
import { UserEntity } from 'modules/user/entities';

@Entity({ name: 'partners' })
export class PartnerEntity extends AbstractEntity<PartnerDto> {

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

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

  @Column({
    nullable: true,
  })
  address: string;

  @Column({
    nullable: true,
  })
  contact: string;

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

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

  @OneToMany(() => UserEntity, (user: UserEntity) => user.partner, {
    nullable: true,
  })
  user: UserEntity[];

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

  dtoClass = PartnerDto;
}

result-matching ""

    No results matching ""