🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

mongo-cursor-pagination

Package Overview
Dependencies
Maintainers
30
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-cursor-pagination - npm Package Compare versions

Comparing version

to
7.2.0

4

CHANGELOG.md
## Changelog
* 7.2.0 Add support for `COLLATION` configuration parameter.
* 7.1.0 Add support for `aggregate`.
* 7.0.1 Update base64-url to fix security issue (https://github.com/mixmaxhq/mongo-cursor-pagination/pull/41 - thanks @pwiebe).

@@ -6,0 +8,0 @@

@@ -6,2 +6,3 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

const { prepareResponse, generateSort, generateCursorQuery } = require('./utils/query');
const config = require('./config');

@@ -65,2 +66,4 @@ /**

let options = config.COLLATION ? { collation: config.COLLATION } : undefined;
// Support both the native 'mongodb' driver and 'mongoist'. See:

@@ -70,3 +73,3 @@ // https://www.npmjs.com/package/mongoist#cursor-operations

let results = yield collection[aggregateMethod](params.aggregation).toArray();
let results = yield collection[aggregateMethod](params.aggregation, options).toArray();

@@ -73,0 +76,0 @@ return prepareResponse(results, params);

@@ -6,2 +6,3 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

const { prepareResponse, generateSort, generateCursorQuery } = require('./utils/query');
const config = require('./config');

@@ -43,3 +44,5 @@ /**

const results = yield collection[findMethod]({ $and: [cursorQuery, params.query] }, params.fields).sort($sort).limit(params.limit + 1) // Query one more element to see if there's another page.
const query = collection[findMethod]({ $and: [cursorQuery, params.query] }, params.fields);
const collatedQuery = config.COLLATION ? query.collation(config.COLLATION) : query;
const results = yield collatedQuery.sort($sort).limit(params.limit + 1) // Query one more element to see if there's another page.
.toArray();

@@ -46,0 +49,0 @@

{
"name": "mongo-cursor-pagination",
"version": "7.1.0",
"version": "7.2.0",
"description": "Make it easy to return cursor-paginated results from a Mongo collection",

@@ -58,3 +58,3 @@ "main": "index.js",

"mongodb-memory-server": "^1.6.1",
"mongoist": "1.4.3",
"mongoist": "2.3.0",
"mongoose": "5.0.15"

@@ -61,0 +61,0 @@ },

@@ -302,2 +302,7 @@ # mongo-cursor-pagination

### Alphabetical sorting
The collation to use for alphabetical sorting, both with `find` and `aggregate`, can be selected by setting `mongoPaging.config.COLLATION`. If this parameter is
not set, no collation will be provided for the aggregation/cursor, which means that MongoDB will use whatever collation was set for the collection.
### Indexes for sorting

@@ -304,0 +309,0 @@

const _ = require('underscore');
const sanitizeParams = require('./utils/sanitizeParams');
const { prepareResponse, generateSort, generateCursorQuery } = require('./utils/query');
const config = require('./config');

@@ -62,2 +63,4 @@ /**

let options = config.COLLATION ? { collation: config.COLLATION } : undefined;
// Support both the native 'mongodb' driver and 'mongoist'. See:

@@ -67,5 +70,5 @@ // https://www.npmjs.com/package/mongoist#cursor-operations

let results = await collection[aggregateMethod](params.aggregation).toArray();
let results = await collection[aggregateMethod](params.aggregation, options).toArray();
return prepareResponse(results, params);
};
const _ = require('underscore');
const sanitizeParams = require('./utils/sanitizeParams');
const { prepareResponse, generateSort, generateCursorQuery } = require('./utils/query');
const config = require('./config');

@@ -42,3 +43,5 @@ /**

const results = await collection[findMethod]({ $and: [cursorQuery, params.query] }, params.fields)
const query = collection[findMethod]({ $and: [cursorQuery, params.query] }, params.fields);
const collatedQuery = config.COLLATION ? query.collation(config.COLLATION) : query;
const results = await collatedQuery
.sort($sort)

@@ -45,0 +48,0 @@ .limit(params.limit + 1) // Query one more element to see if there's another page.