@baapcompany/core-api
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "@baapcompany/core-api", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -129,2 +129,28 @@ const ServiceResponse = require("@baapcompany/core-api/services/serviceResponse"); | ||
async preparePaginationAndReturnData(query, criteria) { | ||
const pagination = { | ||
pageNumber : criteria.pageNumber, | ||
pageSize : criteria.pageSize | ||
} | ||
const paginationErrors = | ||
this.validateAndSanitizePaginationProps(pagination); | ||
if (paginationErrors) { | ||
return paginationErrors; | ||
} | ||
return this.execute(async () => { | ||
return { | ||
items: await this.model.find( | ||
query, | ||
{}, | ||
{ | ||
skip: pagination.pageSize * (pagination.pageNumber - 1), | ||
limit: pagination.pageSize, | ||
} | ||
), | ||
totalItemsCount: await this.model.countDocuments(query), | ||
}; | ||
}); | ||
} | ||
async paginationResults(query, pagination) { | ||
@@ -131,0 +157,0 @@ return this.execute(async () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14680
239