mongoose-paginate-v2
Advanced tools
Comparing version 1.0.24 to 1.2.0
@@ -34,3 +34,3 @@ "use strict"; | ||
*/ | ||
var deafultOptions = { | ||
var defaultOptions = { | ||
customLabels: { | ||
@@ -56,3 +56,3 @@ totalDocs: 'totalDocs', | ||
function paginate(query, options, callback) { | ||
options = _objectSpread({}, deafultOptions, paginate.options, options); | ||
options = _objectSpread({}, defaultOptions, paginate.options, options); | ||
query = query || {}; | ||
@@ -64,3 +64,2 @@ var _options = options, | ||
leanWithId = _options.leanWithId, | ||
limit = _options.limit, | ||
populate = _options.populate, | ||
@@ -70,2 +69,3 @@ projection = _options.projection, | ||
sort = _options.sort; | ||
var limit = parseInt(options.limit, 10) || 0; | ||
var isCallbackSpecified = typeof callback === 'function'; | ||
@@ -72,0 +72,0 @@ var findOptions = options.options; |
{ | ||
"name": "mongoose-paginate-v2", | ||
"version": "1.0.24", | ||
"version": "1.2.0", | ||
"description": "A cursor based custom pagination library for Mongoose with customizable labels.", | ||
@@ -42,4 +42,4 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.3.4", | ||
"@babel/cli": "^7.4.3", | ||
"@babel/core": "^7.4.3", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
@@ -62,3 +62,2 @@ "@babel/plugin-proposal-decorators": "^7.0.0", | ||
"@babel/preset-env": "^7.3.1", | ||
"babel-cli": "^6.26.0", | ||
"chai": "^4.2.0", | ||
@@ -65,0 +64,0 @@ "mocha": "^6.0.1", |
@@ -21,3 +21,3 @@ /** | ||
const deafultOptions = { | ||
const defaultOptions = { | ||
customLabels: { | ||
@@ -44,3 +44,3 @@ totalDocs: 'totalDocs', | ||
options = { | ||
...deafultOptions, | ||
...defaultOptions, | ||
...paginate.options, | ||
@@ -56,3 +56,2 @@ ...options | ||
leanWithId, | ||
limit, | ||
populate, | ||
@@ -63,2 +62,4 @@ projection, | ||
} = options; | ||
const limit = parseInt(options.limit, 10) || 0; | ||
@@ -186,2 +187,2 @@ const isCallbackSpecified = typeof callback === 'function'; | ||
module.exports.paginate = paginate; | ||
module.exports.paginate = paginate; |
@@ -75,3 +75,3 @@ 'use strict'; | ||
describe('paginates', function () { | ||
/*it('with limit and page', function () { | ||
it('with limit and page', function () { | ||
var query = { | ||
@@ -95,2 +95,3 @@ title: { | ||
console.log(result); | ||
expect(result.docs).to.have.length(0); | ||
@@ -109,3 +110,3 @@ expect(result.totalDocs).to.equal(12); | ||
/* | ||
it('with $where condition', function() { | ||
@@ -161,3 +162,2 @@ var query = { | ||
page: 5, | ||
populate: 'author', | ||
select: {title:1, price:1}, | ||
@@ -168,3 +168,3 @@ customLabels: myCustomLabels | ||
return Book.paginate(query, options).then((result) => { | ||
console.log(result); | ||
expect(result.itemsList).to.have.length(10); | ||
@@ -171,0 +171,0 @@ expect(result.itemsList[0].title).to.equal('Book #41'); |
31754
22
459