import { CreateDateColumn , PrimaryGeneratedColumn , UpdateDateColumn , } from 'typeorm' ; import type { Constructor } from '../types' ; import type { AbstractDto } from './dto/abstract.dto' ; author Narek Hakobyan <narek.hakobyan.07@gmail.com>
 *
 *  description export interface IAbstractEntity < DTO extends AbstractDto , O = never > { id : Uuid ; createdAt : Date ; updatedAt : Date ; toDto ( options ? ) : DTO ; } export abstract class AbstractEntity < DTO extends AbstractDto = AbstractDto , O = never > implements IAbstractEntity < DTO , O > { @ PrimaryGeneratedColumn ( 'uuid' ) id : Uuid ; @ CreateDateColumn ( { type : 'timestamp' , } ) createdAt : Date ; @ UpdateDateColumn ( { type : 'timestamp' , } ) updatedAt : Date ; private dtoClass : Constructor < DTO , [ AbstractEntity , O ? ] > ; toDto ( options ? ) { const dtoClass = this . dtoClass ; if ( ! dtoClass ) { throw new Error ( `You need to use @UseDto on class (${ this . constructor . name }) be able to call toDto function` ) ; } return new this . dtoClass ( this , options ) ; } }