New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

knex-paginate

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knex-paginate - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

CHANGELOG.md

36

lib/index.js

@@ -28,2 +28,3 @@ const Knex = require('knex');

let pagination = {};
let countQuery = null;

@@ -37,2 +38,13 @@ if (currentPage < 1) {

if (shouldFetchTotals) {
countQuery = new this.constructor(this.client)
.count('* as total')
.from(
this.clone()
.offset(0)
.as('__count__query__'),
)
.first();
}
// This will paginate the data itself

@@ -45,26 +57,6 @@ this.offset(offset).limit(limit);

if (shouldFetchTotals) {
const groupStmt = this._statements.find(stmt => stmt.grouping === 'group');
const { total } = await countQuery.transacting(trx);
const countQuery = await this.clone()
.clearSelect()
.clearOrder()
.clearHaving()
.modify(qb => {
qb._clearGrouping('group');
if (groupStmt) {
qb.count(`${groupStmt.value[0]} as total`, { distinct: true });
} else {
qb.count('* as total');
}
})
.offset(0)
.first()
.transacting(trx);
const total = +countQuery.total;
pagination = {
...pagination,
total,
total: +total,
lastPage: Math.ceil(total / perPage),

@@ -71,0 +63,0 @@ };

{
"name": "knex-paginate",
"version": "1.1.1",
"version": "1.2.0",
"description": "Extension of Knex's query builder with `paginate` method that will help with your pagination tasks.",

@@ -12,3 +12,4 @@ "main": "lib/index.js",

"scripts": {
"test": "jest"
"test": "jest",
"version": "auto-changelog -p && git add CHANGELOG.md"
},

@@ -36,6 +37,7 @@ "repository": {

"@types/node": "^12.0.0",
"dotenv": "^8.0.0",
"jest": "^24.8.0",
"mysql": "^2.17.1",
"knex": "latest"
"auto-changelog": "^1.16.2",
"dotenv": "^8.2.0",
"jest": "^25.1.0",
"knex": "latest",
"mysql": "^2.18.1"
},

@@ -42,0 +44,0 @@ "jest": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc