import { BaseEntity , DeleteResult , Repository } from 'typeorm' ; import { IBaseService } from './i.base.service' ; import { EntityId } from 'typeorm/repository/EntityId' ; import { LoggerService } from './logger/custom.logger' ; export class BaseService < T extends BaseEntity , R extends Repository < T > > implements IBaseService < T > { protected readonly repository : R ; protected readonly logger : LoggerService ; constructor ( repository , logger ) { this . repository = repository ; this . logger = logger ; } index ( ) { return this . repository . find ( ) ; } findById ( id ) { return this . repository . findOne ( id ) ; } findByIds ( ids ) { return this . repository . findByIds ( ids ) ; } store ( data ) { return this . repository . save ( data ) ; } async update ( id , data ) { await this . repository . update ( id , data ) ; return this . findById ( id ) ; } delete ( id ) { return this . repository . delete ( id ) ; } }