Socket
Socket
Sign inDemoInstall

mongoose-paginate-v2

Package Overview
Dependencies
0
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.2 to 1.4.3

6

CHANGELOG.md
# Changelog
## v1.4.3
[2022-01-06]
- Fix hasPrevPage behaviour with limit > offset > 0
## v1.4.2

@@ -4,0 +10,0 @@

3

dist/index.js

@@ -242,2 +242,5 @@ "use strict";

meta[labelPrevPage] = page - 1;
} else if (page == 1 && typeof offset !== 'undefined' && offset !== 0) {
meta[labelHasPrevPage] = true;
meta[labelPrevPage] = 1;
} // Set next page

@@ -244,0 +247,0 @@

2

package.json
{
"name": "mongoose-paginate-v2",
"version": "1.4.2",
"version": "1.4.3",
"description": "A custom pagination library for Mongoose with customizable labels.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -238,2 +238,5 @@ /**

meta[labelPrevPage] = page - 1;
} else if (page == 1 && typeof offset !== 'undefined' && offset !== 0) {
meta[labelHasPrevPage] = true;
meta[labelPrevPage] = 1;
}

@@ -240,0 +243,0 @@

@@ -146,2 +146,30 @@ 'use strict';

it('first page with page and limit, limit > doc.length, offset by one', function () {
var query = {
title: {
$in: [/Book/i],
},
};
var options = {
offset: 1,
limit: 200,
page: 1,
lean: true,
};
return Book.paginate(query, options).then((result) => {
expect(result.docs).to.have.length(99);
expect(result.totalDocs).to.equal(100);
expect(result.limit).to.equal(200);
expect(result.page).to.equal(1);
expect(result.pagingCounter).to.equal(1);
expect(result.hasPrevPage).to.equal(true);
expect(result.hasNextPage).to.equal(false);
expect(result.prevPage).to.equal(1);
expect(result.nextPage).to.equal(null);
expect(result.totalPages).to.equal(1);
});
});
it('first page with page and limit', function () {

@@ -253,5 +281,5 @@ var query = {

expect(result.pagingCounter).to.equal(1);
expect(result.hasPrevPage).to.equal(false);
expect(result.hasPrevPage).to.equal(true);
expect(result.hasNextPage).to.equal(true);
expect(result.prevPage).to.equal(null);
expect(result.prevPage).to.equal(1);
expect(result.nextPage).to.equal(2);

@@ -258,0 +286,0 @@ expect(result.totalPages).to.equal(10);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc