mongoose-paginate-v2
Advanced tools
Comparing version 1.3.7 to 1.3.8
@@ -185,3 +185,3 @@ "use strict"; | ||
meta[labelPrevPage] = page - 1; | ||
} else if (page == 1 && offset !== 0) { | ||
} else if (page == 1 && offset && offset !== 0) { | ||
meta[labelHasPrevPage] = true; | ||
@@ -188,0 +188,0 @@ meta[labelPrevPage] = 1; |
{ | ||
"name": "mongoose-paginate-v2", | ||
"version": "1.3.7", | ||
"version": "1.3.8", | ||
"description": "A cursor based custom pagination library for Mongoose with customizable labels.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -188,3 +188,3 @@ /** | ||
meta[labelPrevPage] = (page - 1); | ||
} else if (page == 1 && offset !== 0) { | ||
} else if (page == 1 && offset && offset !== 0) { | ||
meta[labelHasPrevPage] = true; | ||
@@ -245,2 +245,2 @@ meta[labelPrevPage] = 1; | ||
module.exports.paginate = paginate; | ||
module.exports.paginate = paginate; |
@@ -116,3 +116,31 @@ 'use strict'; | ||
}); | ||
it('first page with page and limit', function() { | ||
var query = { | ||
title: { | ||
$in: [/Book/i], | ||
}, | ||
}; | ||
var options = { | ||
limit: 10, | ||
page: 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(false); | ||
expect(result.hasNextPage).to.equal(true); | ||
expect(result.prevPage).to.equal(null); | ||
expect(result.nextPage).to.equal(2); | ||
expect(result.totalPages).to.equal(10); | ||
}); | ||
}); | ||
it('with offset and limit (not page)', function () { | ||
@@ -431,2 +459,2 @@ 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
280328
807