Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
knex-paginate
Advanced tools
Readme
Extension of Knex's query builder with paginate
method that will help with your pagination tasks.
To use this lib, first you will have to install it:
npm i knex-paginate --save
// or
yarn add knex-paginate
Then, add the following lines to your Knex set up:
const knex = require('knex')(config);
const { attachPaginate } = require('knex-paginate');
attachPaginate();
.paginate(params: IPaginateParams): Knex.QueryBuilder<any, IWithPagination<TResult>>;
interface IPaginateParams {
perPage: number,
currentPage: number,
isFromStart?: boolean,
isLengthAware?: boolean,
}
interface IWithPagination<T = any> {
data: T;
pagination: IPagination;
}
interface IPagination {
total?: number;
lastPage?: number;
currentPage: number;
perPage: number;
from: number;
to: number;
}
const result = await knex('persons')
.paginate({ perPage: 10, currentPage: 2 });
// result.data - will hold persons data
// result.pagination - will hold pagination object
pagination
objectKey | Value |
---|---|
perPage | Items per page. |
currentPage | Current page number. |
from | Counting ID of the first item of the current page. |
to | Counting ID of the last item of the current page. |
Returned if isLengthAware == true
or currentPage == 1
or isFromStart == true
:
Key | Value |
---|---|
total | Total items that the full query contains. |
lastPage | Last page number. |
This lib got inspiration from knex-paginator
.
FAQs
Extension of Knex's query builder with `paginate` method that will help with your pagination tasks.
The npm package knex-paginate receives a total of 19,462 weekly downloads. As such, knex-paginate popularity was classified as popular.
We found that knex-paginate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.