mongoose-plugin-cursor-pagination
v1.1.0
Published
add getPage method to models
Downloads
6
Maintainers
Readme
mongoose-plugin-dataloader
Adds getPage
to models.
Works together with mongoose-plugin-datalodear
Getting Started
npm install mongoose-plugin-pagination
const { Schema, model } = require('mongoose')
const paginationPlugin = require('mongoose-plugin-pagination')
const schema = {
username: {
type: String,
required: true,
unique: true
}
}
const userSchema = new Schema(schema)
userSchema.plugin(paginationPlugin, 20) // default page size
module.exports = model('User', userSchema)
const User = require('./user-model');
// optional
let page = {
size: 5, // ommit for default
cursor: '5d58b82db5e527505ed65e26,' // or empty for 1st page
}
// optional
let params = {
username: new Regex('as', 'i')
}
User.getPage(page, params)