express-rest-api-generator
Advanced tools
Comparing version 1.3.3 to 1.3.4
const bodyParser = require('body-parser'); | ||
const log = require('debug')('bot:app:rest:'); // eslint-disable-line | ||
const log = require('debug')('rest:'); // eslint-disable-line | ||
const { slugify, toNum, omit } = require('./helpers'); | ||
@@ -164,12 +164,13 @@ | ||
let { limit = this.pageSizeDefault, page = 0 } = query; | ||
const { sort = this.sortBy } = query; | ||
const { sort = this.sortBy, populate = null } = query; | ||
limit = Math.min(this.pageSizeMax, toNum(limit)); | ||
page = toNum(page); | ||
const search = id ? { _id: id } : {}; | ||
return this.model | ||
.find(Object.assign(search, omit(query, ['page', 'limit', 'sort']))) | ||
const queryWrapper = this.model | ||
.find(Object.assign(search, omit(query, ['page', 'limit', 'sort', 'populate']))) | ||
.sort(sort) | ||
.limit(limit) | ||
.skip(page > 0 ? (page - 1) * limit : 0) | ||
.execAsync() | ||
.skip(page > 0 ? (page - 1) * limit : 0); | ||
if (populate) queryWrapper.populate(populate); | ||
return queryWrapper.execAsync() | ||
.catch(fn) | ||
@@ -176,0 +177,0 @@ .then(fn.bind(null, null)); |
{ | ||
"name": "express-rest-api-generator", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "express mountable app for mongoose routes with generators for mongoose model embedded statics", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
9598
8
259
1
4