@aequum/typeorm
Version:
aequum TypeORM tools for repository, pagination, CRUD/CRUDL, configs and utils
40 lines (39 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCRUDLTypeORMPaginatedService = void 0;
const paginate_common_1 = require("@aequum/paginate-common");
const __1 = require("..");
/**
* Base CRUD/CRUDL TypeORM Service for a TypeORM entity model, with
* paginated list output, by default assumes that the primary key
* field as `id`
*
* @typeParam EntityModel TypeORM entity model
* @typeParam EntityModelDto DTO of the TypeORM entity model
* @typeParam EntityModelCreateDto DTO to create a new TypeORM entity model
* @typeParam EntityModelUpdateDto DTO to update a TypeORM entity model
* @typeParam PaginatedEntityModelDto Paginated DTO of the TypeORM entity model
* @typeParam CustomFilterType Custom filter type to filter the query
* @typeParam PrimaryKeyField Primary key field of the TypeORM Schema
* Model by default is `id` (Virtual ID)
*/
class BaseCRUDLTypeORMPaginatedService extends __1.BaseCRUDLTypeORMService {
/**
* List all data entries paginated
*
* @param filter - Filter to apply to the query
* @param page - Page number
* @param size - Page size
* @param sort - Sort options
* @param options - `typeorm-paginate` options
* @returns Paginated result
*
* @see [IPaginationOptions on GitHub](https://github.com/nestjsx/nestjs-typeorm-paginate/blob/master/src/interfaces/index.ts#L6-L12)
*/
async paginatedList(filter, page, size, sort, options) {
if (typeof sort === 'string')
sort = (0, paginate_common_1.sortStringToPaginateSortBy)(sort);
return this.repository.paginatedFindBy(this.queryFilterToTypeORMFilter(filter), page, size, sort, options);
}
}
exports.BaseCRUDLTypeORMPaginatedService = BaseCRUDLTypeORMPaginatedService;