mongoose-paginate-v2
Advanced tools
Comparing version 1.3.6 to 1.3.7
@@ -13,3 +13,3 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -186,2 +186,5 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
meta[labelPrevPage] = page - 1; | ||
} else if (page == 1 && offset !== 0) { | ||
meta[labelHasPrevPage] = true; | ||
meta[labelPrevPage] = 1; | ||
} else { | ||
@@ -188,0 +191,0 @@ meta[labelPrevPage] = null; |
{ | ||
"name": "mongoose-paginate-v2", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "A cursor based custom pagination library for Mongoose with customizable labels.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -83,3 +83,3 @@ ![Banner](static/banner.jpg) | ||
Please note that the above properties can be renamed by setting customLabel attribute. | ||
Please note that the above properties can be renamed by setting customLabels attribute. | ||
@@ -86,0 +86,0 @@ ### Sample Usage |
@@ -188,2 +188,5 @@ /** | ||
meta[labelPrevPage] = (page - 1); | ||
} else if (page == 1 && offset !== 0) { | ||
meta[labelHasPrevPage] = true; | ||
meta[labelPrevPage] = 1; | ||
} else { | ||
@@ -190,0 +193,0 @@ meta[labelPrevPage] = null; |
@@ -147,3 +147,34 @@ 'use strict'; | ||
}); | ||
it('with offset and limit (not page) condition: offset > 0 < limit', function () { | ||
var query = { | ||
title: { | ||
$in: [/Book/i] | ||
} | ||
}; | ||
var options = { | ||
limit: 10, | ||
offset: 5, | ||
sort: { | ||
_id: 1 | ||
}, | ||
lean: true | ||
}; | ||
return Book.paginate(query, options).then((result) => { | ||
expect(result.docs).to.have.length(10); | ||
expect(result.totalDocs).to.equal(100); | ||
expect(result.limit).to.equal(10); | ||
expect(result.page).to.equal(1); | ||
expect(result.pagingCounter).to.equal(1); | ||
expect(result.hasPrevPage).to.equal(true); | ||
expect(result.hasNextPage).to.equal(true); | ||
expect(result.prevPage).to.equal(1); | ||
expect(result.nextPage).to.equal(2); | ||
expect(result.totalPages).to.equal(10); | ||
}); | ||
}); | ||
it('with limit=0 (metadata only)', function () { | ||
@@ -150,0 +181,0 @@ var query = { |
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
279541
781