import { DeepPartial, ObjectLiteral, Repository } from "typeorm"; import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity.js"; export class BaseService { constructor(protected readonly repo: Repository) { } findAll(relations: string[] = []) { return this.repo.find({ relations }); } findOne(id: string, relations: string[] = []) { return this.repo.findOne({ where: { id } as any, relations }); } create(data: DeepPartial) { const entity = this.repo.create(data); return this.repo.save(entity); } async update(id: string, data: QueryDeepPartialEntity) { await this.repo.update(id, data); return this.findOne(id); } delete(id: string) { return this.repo.delete(id); } }