UNPKG

@jsgurucompany/jsg-nestjs-common

Version:

Initial README.md

39 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseCrudService = void 0; class BaseCrudService { constructor(repository) { this.repository = repository; } async findAll(options) { const results = await this.repository.findAll(options); return { total: results.length, data: results, }; } async findPaginated(paginationParams, options) { const { count: total, rows: data } = await this.repository.findPaginated(paginationParams, options); return { total, data, }; } async findById(id) { return this.repository.findOneById(id); } async findOne(options) { return this.repository.findOne(options); } async create(payload) { return this.repository.create(payload); } async update(id, payload) { return this.repository.update(id, payload); } async remove(id) { return this.repository.remove(id); } } exports.BaseCrudService = BaseCrudService; //# sourceMappingURL=base-crud.service.js.map