Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
sequelize-pagination
Advanced tools
Add a method on a sequelize model for pagination queries
The project is inspired by sequelize-simple-pagination
Define a sequelize model and add a pagination method:
// Define a model
const withPagination = require('sequelize-pagination');
const Counter = sequelize.define('counter', {
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
value: Sequelize.INTEGER,
});
const options = {
methodName: 'paginate', // the name of the pagination method
primaryKey: 'id', // the primary key field of the model
};
// Add a pagination method for the model
withPagination(options)(Counter);
Call the paginate
(default method name) method:
Counter.paginate({
pageIndex: 0,
pageSize: 10,
})
.then(pagination => {
console.log(pagination.entities)
})
The paginate
method returns a promise with resolve data of SequelizePaginationResult
type.
withPagination({
pageSize: 3, // Fix page size
})(Counter);
example/PredefinePagination.js
Create a pagination with orderBy, order options
async function paginateCounter(options) {
const {orderBy, order, ...others} = options;
const result = await Counter.paginate({
orders: [[orderBy, order]],
...others,
});
return {orderBy, order, ...result};
}
example/CustomPagination-OrderBy.js
withPagination()
is a function generator for remember pagination configuration.
options
is a object with following properties:
paginate
id
oneBaseIndex
is false
. Page index starts from 1 if oneBaseIndex
is true
. Default: false
options.methodName
is paginate
)options
is a object with following properties:
false
. Page index starts from 1 if oneBaseIndex istrue
.return a promise with resolve data of SequelizePaginationResult
type.
SequelizePaginationResult
is a object type with following properties:
where
parameter of findAll
orders
parameter of findAll
attributes
parameter of findAll
include
parameter of findAll
npm run test
FAQs
Add a method on a sequelize model for pagination queries
The npm package sequelize-pagination receives a total of 186 weekly downloads. As such, sequelize-pagination popularity was classified as not popular.
We found that sequelize-pagination 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.