Gathering detailed insights and metrics for @mother/mongoose-cursor-pagination
Gathering detailed insights and metrics for @mother/mongoose-cursor-pagination
Gathering detailed insights and metrics for @mother/mongoose-cursor-pagination
Gathering detailed insights and metrics for @mother/mongoose-cursor-pagination
Easy-to-use, scalable, cursor pagination plugin for mongoose
npm install @mother/mongoose-cursor-pagination
Typescript
Module System
Min. Node Version
Node Version
NPM Version
64.7
Supply Chain
91
Quality
77
Maintenance
100
Vulnerability
99.3
License
JavaScript (100%)
Total Downloads
7,888
Last Day
3
Last Week
11
Last Month
150
Last Year
1,689
MIT License
5 Stars
66 Commits
2 Forks
3 Watchers
7 Branches
1 Contributors
Updated on Jun 04, 2023
Minified
Minified + Gzipped
Latest Version
0.0.6
Package Id
@mother/mongoose-cursor-pagination@0.0.6
Unpacked Size
11.98 kB
Size
4.50 kB
File Count
5
NPM Version
9.6.4
Node Version
14.20.0
Published on
Apr 27, 2023
Cumulative downloads
Total Downloads
Last Day
-25%
3
Compared to previous day
Last Week
-81.7%
11
Compared to previous week
Last Month
-55.1%
150
Compared to previous month
Last Year
84.4%
1,689
Compared to previous year
2
1
This small plugin makes it easy to use cursor-based pagination in your app, without changing the way you use queries in mongoose.
npm install @mother/mongoose-cursor-pagination --save
Node.js 10.x or higher is required.
In your schema:
1import mongoose from 'mongoose' 2import paginationPlugin from '@mother/mongoose-cursor-pagination' 3 4const CommentSchema = new mongoose.Schema({ 5 date: { type: Date }, 6 body: { type: String }, 7 author: { 8 firstName: { type: String }, 9 lastName: { type: String } 10 } 11}) 12 13CommentSchema.plugin(paginationPlugin)
In your application code:
1const { results, pageInfo } = await Comment 2 .find({}) // Whatever filter you want 3 .limit(30) // Use limit and other Query options as you normally would 4 .sort('author.lastName') // Use sort as you would normally do 5 .paginate(startCursor) // startCursor optional 6 .exec() // Required
results
will be the results that you would expect from a normal mongoose find
query
pageInfo
will have two properties: hasNext
and nextCursor
Be sure to index correctly. Note that this plugin always add _id
to the sort key to ensure cursors are unique, so include that in your index as well. For example, say you are using the date
field for pagination, then you would want to setup the index:
1commentSchema.index({ date: -1, _id: -1 })
You can optionally pass an options object to this plugin:
1CommentSchema.plugin(paginationPlugin, { 2 // If no limit is specified, and paginate() is being used, 3 // what should the default limit be. 4 defaultLimit: 100 5})
Numerous tests are included in the tests
directory, and can be run using the command npm test
.
hasPrev
and prevCursor
exec
calls that use callbacks instead of promisesMIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
19 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More