Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-paginate-v2

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-paginate-v2 - npm Package Compare versions

Comparing version 1.3.9 to 1.3.10

.travis.yml

10

dist/index.js

@@ -32,2 +32,3 @@ "use strict";

* @param {Number} [options.limit=10]
* @param {Boolean} [options.useEstimatedCount=true] - Enable estimatedDocumentCount for larger datasets. As the name says, the count may not abe accurate.
* @param {Object} [options.read={}] - Determines the MongoDB nodes from which to read.

@@ -60,2 +61,3 @@ * @param {Function} [callback]

pagination: true,
useEstimatedCount: false,
forceCountFn: false

@@ -77,2 +79,3 @@ };

pagination = _options.pagination,
useEstimatedCount = _options.useEstimatedCount,
forceCountFn = _options.forceCountFn;

@@ -117,5 +120,10 @@

if (forceCountFn === true) {
// Deprecated since starting from MongoDB Node.JS driver v3.1
countPromise = this.count(query).exec();
} else {
countPromise = this.countDocuments(query).exec();
if (useEstimatedCount === true) {
countPromise = this.useEstimatedCount(query).exec();
} else {
countPromise = this.countDocuments(query).exec();
}
}

@@ -122,0 +130,0 @@

134

package.json
{
"name": "mongoose-paginate-v2",
"version": "1.3.9",
"description": "A cursor based custom pagination library for Mongoose with customizable labels.",
"main": "dist/index.js",
"scripts": {
"pretest": "npm run build",
"test": "./node_modules/.bin/mocha tests/*.js -R spec --ui bdd --timeout 9999999",
"build": "babel src -d dist",
"prepublish": "npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aravindnc/mongoose-paginate-v2.git"
},
"keywords": [
"mongoose",
"pagination",
"plugin",
"mongodb",
"paginate",
"paging",
"next",
"prev",
"nextpage",
"prevpage",
"total",
"paginator",
"plugin"
],
"author": "Aravind NC <aravind_n_c@yahoo.co.in> (https://aravindnc.com)",
"contributors": [
"Fernando López Guevara (fernando.lguevara@gmail.com)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/aravindnc/mongoose-paginate-v2/issues"
},
"homepage": "https://github.com/aravindnc/mongoose-paginate-v2#readme",
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.3.1",
"chai": "^4.2.0",
"mocha": "^6.0.1",
"mongoose": "^5.2.4"
},
"engines": {
"node": ">=4.0.0"
}
}
"name": "mongoose-paginate-v2",
"version": "1.3.10",
"description": "A cursor based custom pagination library for Mongoose with customizable labels.",
"main": "dist/index.js",
"scripts": {
"pretest": "npm run build",
"test": "./node_modules/.bin/mocha tests/*.js -R spec --ui bdd --timeout 9999999",
"build": "babel src -d dist",
"prepublish": "npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aravindnc/mongoose-paginate-v2.git"
},
"keywords": [
"mongoose",
"pagination",
"plugin",
"mongodb",
"paginate",
"paging",
"next",
"prev",
"nextpage",
"prevpage",
"total",
"paginator",
"plugin"
],
"author": "Aravind NC <aravind_n_c@yahoo.co.in> (https://aravindnc.com)",
"contributors": [
"Fernando López Guevara (fernando.lguevara@gmail.com)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/aravindnc/mongoose-paginate-v2/issues"
},
"homepage": "https://github.com/aravindnc/mongoose-paginate-v2#readme",
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.3.1",
"chai": "^4.2.0",
"mocha": "^6.0.1",
"mongoose": "^5.2.4"
},
"engines": {
"node": ">=4.0.0"
}
}

@@ -5,2 +5,3 @@ ![Banner](static/banner.jpg)

[![npm version](https://img.shields.io/npm/v/mongoose-paginate-v2.svg)](https://www.npmjs.com/package/mongoose-paginate-v2)
[![Build Status](https://travis-ci.com/aravindnc/mongoose-paginate-v2.svg?branch=master)](https://travis-ci.com/aravindnc/mongoose-paginate-v2)
[![Dependency Status](https://david-dm.org/aravindnc/mongoose-paginate-v2.svg)](https://david-dm.org/aravindnc/mongoose-paginate-v2)

@@ -18,2 +19,7 @@ [![devDependency Status](https://david-dm.org/aravindnc/mongoose-paginate-v2/dev-status.svg)](https://david-dm.org/aravindnc/mongoose-paginate-v2#info=devDependencies)

## Why This Plugin
mongoose-paginate-v2 is a cursor based pagination library having a page wrapper. The plugin can be used as both page as well as cusror based pagination. The main usage of the plugin is you can alter the return value keys directly in the query itself so that you don't need any extra code for transformation.
The below documentation is not perfect. Feel free to contribute. :)
## Installation

@@ -56,2 +62,3 @@

- `[populate]` {Array | Object | String} - Paths which should be populated with other documents. [Documentation](http://mongoosejs.com/docs/api.html#query_Query-populate)
- `[projection]` {String | Object} - Get/set the query projection. [Documentation](https://mongoosejs.com/docs/api/query.html#query_Query-projection)
- `[lean=false]` {Boolean} - Should return plain javascript objects instead of Mongoose documents? [Documentation](http://mongoosejs.com/docs/api.html#query_Query-lean)

@@ -64,7 +71,9 @@ - `[leanWithId=true]` {Boolean} - If `lean` and `leanWithId` are `true`, adds `id` field with string representation of `_id` to every document

- `[pagination]` {Boolean} - If `pagination` is set to false, it will return all docs without adding limit condition. (Default: True)
- `[forceCountFn]` {Boolean} - Set this to true, if you need to support $geo queries.
- `[useEstimatedCount]` - Enable estimatedDocumentCount for larger datasets. As the name says, the count may not abe accurate. (Default: False)
- `[forceCountFn]` {Boolean} - Set this to true, if you need to support $geo queries. (Default: False)
- `[read]` {Object} - Determines the MongoDB nodes from which to read. Below are the available options.
- `[pref]`: One of the listed preference options or aliases.
- `[tags]`: Optional tags for this query. (Must be used with `[pref]`)
* `[callback(err, result)]` - If specified the callback is called once pagination results are retrieved or when an error has occurred
- `[options]` {Object} - Options passed to Mongoose's `find()` function. [Documentation](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
* `[callback(err, result)]` - If specified, the callback is called once pagination results are retrieved or when an error has occurred

@@ -313,6 +322,8 @@ **Return value**

## Changelog
[v1.3.10] - 1/11/2020
- Added support for estimatedCountDocuments for larger datasets. Set useEstimatedCount=true
## License
[MIT](LICENSE)

@@ -16,2 +16,3 @@ /**

* @param {Number} [options.limit=10]
* @param {Boolean} [options.useEstimatedCount=true] - Enable estimatedDocumentCount for larger datasets. As the name says, the count may not abe accurate.
* @param {Object} [options.read={}] - Determines the MongoDB nodes from which to read.

@@ -45,2 +46,3 @@ * @param {Function} [callback]

pagination: true,
useEstimatedCount: false,
forceCountFn: false

@@ -67,2 +69,3 @@ };

pagination,
useEstimatedCount,
forceCountFn

@@ -115,5 +118,10 @@ } = options;

if (forceCountFn === true) {
// Deprecated since starting from MongoDB Node.JS driver v3.1
countPromise = this.count(query).exec();
} else {
countPromise = this.countDocuments(query).exec();
if (useEstimatedCount === true) {
countPromise = this.useEstimatedCount(query).exec()
} else {
countPromise = this.countDocuments(query).exec();
}
}

@@ -120,0 +128,0 @@

@@ -37,2 +37,3 @@ 'use strict';

mongoose.connect(MONGO_URI, {
useUnifiedTopology: true,
useNewUrlParser: true

@@ -144,3 +145,30 @@ }, done);

});
it('last page with page and limit', function() {
var query = {
title: {
$in: [/Book/i],
},
};
var options = {
limit: 10,
page: 10,
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(10);
expect(result.pagingCounter).to.equal(91);
expect(result.hasPrevPage).to.equal(true);
expect(result.hasNextPage).to.equal(false);
expect(result.prevPage).to.equal(9);
expect(result.nextPage).to.equal(null);
expect(result.totalPages).to.equal(10);
});
});
it('with offset and limit (not page)', function () {

@@ -228,3 +256,2 @@ var query = {

return Book.paginate(query, options).then((result) => {
expect(result.docs).to.have.length(0);

@@ -231,0 +258,0 @@ expect(result.totalDocs).to.equal(12);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc