Gathering detailed insights and metrics for objection-keyset-pagination
Gathering detailed insights and metrics for objection-keyset-pagination
Gathering detailed insights and metrics for objection-keyset-pagination
Gathering detailed insights and metrics for objection-keyset-pagination
Keyset pagination (cursor based pagination) plugin for Objection.js
npm install objection-keyset-pagination
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
20 Stars
37 Commits
2 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Jan 10, 2025
Latest Version
0.1.0
Package Id
objection-keyset-pagination@0.1.0
Unpacked Size
9.35 kB
Size
3.70 kB
File Count
4
NPM Version
6.4.1
Node Version
10.15.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Objection-keyset-pagination is a plugin to Objection.js ORM to implement keyset based pagination, also known as cursor pagination.
Keyset pagination requires having strict ordering of records. On the user interface side, keyset pagination goes well with infinite scroll elements. Keyset pagination provides stable results. Next batch of records always continues from the last record of previous batch even if there would be insertion or deletions between queries. Using dummy numbered pages such as Objection.js' own .page()
or OFFSET
in SQL, then insertion or deletion causes some records omitted or duplicated.
Install:
1npm install objection-keyset-pagination
Register the plugin:
1const Model = require('objection').Model; 2const keysetPagination = require('objection-keyset-pagination')(); 3 4class Person extends keysetPagination(Model) { 5 static get tableName() { 6 return 'Person'; 7 } 8}
limit: The number of rows per request if not set. The limit can be also set per query with .limit()
. Default value is 10.
countTotal: Query total number of rows. Default value is false. Second query will be performed to get the total count.
The options can be provided by optional second argument when registering the plugin:
1const keysetPagination = require('objection-keyset-pagination')({ 2 limit: 20});
Query with .keysetPage()
to fetch first batch of rows and the keyset. Then later fetch next batch of rows starting from the keyset. The keyset is a plain old JS object, which can be easily passed around in JSON serialization.
1const result1 = await Person 2 .query() 3 .where('age', '>', 20) 4 .limit(5) 5 .orderBy('id') 6 .keysetPage();
The models are returned in result.results
just like with .page()
.
The keyset index columns are returned in result.keyset
. Pass this back in the next query to fetch next batch of rows.
If the query doesn't have orderBy
clause, Model's idColumn
will be used in ascending order.
If countTotal was set to true, then the return value also has result.total
which contains total count of rows.
The next batch of rows are fetched by passing result.keyset
as parameter to .keysetPage()
.
1const result2 = await Person 2 .query() 3 .where('age', '>', 20) 4 .limit(5) 5 .orderBy('id') 6 .keysetPage(result1.keyset);
Fetching backwards can be achieved using .previousKeysetPage(result.keyset)
. The returned models here are in reverse order.
1const result3 = await Person 2 .query() 3 .where('age', '>', 20) 4 .limit(5) 5 .orderBy('id') 6 .previousKeysetPage(result2.keyset); 7 8expect(result3.results).to.eql(result1.reverse());
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
Score
Last Scanned on 2025-07-07
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