// IMPORT LIBRARY import { Entity, PrimaryGeneratedColumn, Column, OneToMany, ManyToOne } from "typeorm"; import { JsonProperty } from "@tsed/common"; // IMPORT CUSTOM import { addPrefix } from "../util/helper" import CoreEntity from '../core/entity/CoreEntity'; import { Password } from "../util/password"; export enum GenderType { Male = 'MALE', Female = 'FEMALE' } @Entity(addPrefix("customer")) export class Customer extends CoreEntity { constructor() { super() } // PROPERTIES @Column() @JsonProperty() phone: string @Column() @JsonProperty() name: string; @Column({ default: '' }) @JsonProperty() phoneRelative: string @Column({ default: '' }) @JsonProperty() address: string @Column() @JsonProperty() password: string @Column() @JsonProperty() email: string @Column({ default: GenderType.Male }) @JsonProperty() gender: string @Column({ nullable: true }) @JsonProperty() avatar: string; @Column({ nullable: true }) @JsonProperty() expoToken: string; @Column({ default: false }) @JsonProperty() isBlock: boolean // RELATIONS // METHODS async isValidPassword(password: string): Promise { const validate = await Password.validate(password, this.password) return validate } } // END FILE