Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
knex-paginator
Advanced tools
Readme
Warning: do not use in production. This is not being actively maintained.
Simple paginator for Knex. It adds the .paginate() function to knex's query builder.
To use this paginator, first you will have to install it:
npm i knex-paginator --save
Then, simply add the following lines to your Knex set up:
const knex = require('knex')(config);
const setupPaginator = require('knex-paginator');
setupPaginator(knex);
paginate(perPage = 10, page = 1, isLengthAware = false)
Argument | Description |
---|---|
perPage (integer , defaults to 10 ) | Items to show per page. |
page (integer , defaults to 1 ) | Current page. |
isLengthAware (boolean . Defaults to false ) | Whether the paginator is aware of its length or not. |
Note: If isLengthAware
is set to true, the performance will be worst, as it will have to perform an extra query to get the length.
knex('products')
.where('price', '<', 20)
.paginate(15, 1, true)
.then(paginator => {
console.log(paginator.current_page);
console.log(paginator.data);
});
const paginator = await knex('products')
.where('price', '<', 20)
.paginate(15, 1, true);
console.log(paginator.current_page);
console.log(paginator.data);
The function returns an object that contains the following data:
Always returned:
Key | Value |
---|---|
per_page | Items per page. |
current_page | Current page number. |
from | ID of the first item of the current page. |
to | ID of the last item of the current page. |
data | The actual data of the current page. |
Returned if isLengthAware == true
:
Key | Value |
---|---|
total | Total items that the full query contains. |
last_page | Last page number. |
FAQs
Simple paginator for Knex. It adds the .paginate() function to knex's query builder.
The npm package knex-paginator receives a total of 251 weekly downloads. As such, knex-paginator popularity was classified as not popular.
We found that knex-paginator demonstrated a not healthy version release cadence and project activity because the last version was released 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.