Paginate-mongoose-data
This package is use to paginate mongodb data.
Installation
First install Node.js and MongoDB. Then:
Use the package manager npm to install paginate-mongoose-data.
npm install mongoose --savenpm install paginate-mongoose-data --save
Usage
;; const limit: number; // limit number of data to fetchconst currentpage: number; // current page of data to fetchconst criteria: object = field: value;const populateField = path: "userId" select: "userName" path: "categoryId" select: "name" ; ; // Model is required, second parameter of object is optional // Model and query object; // parameters => Model, Paginate object // Model and query object; // parameters => Model, Paginate object with populated fields
// How to populate nested objectconst populateField = path: "userId" select: "userName" path: "categoryId" select: "name" populate: path: 'userId' ; ; // parameters => Model, Paginate object with populated fields
// Using ES6 imports;; async { try const message data meta = await ; logger; return resstatus200; catch error logger; return resstatus500; };
// Using Nodejs require()const Users = ;const Paginate = paginate;const list = asyncreq res try const message data meta = await ; logger; return resstatus200; catch error logger; return resstatus500; moduleexports = list;
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to run test.
npm test
Authors
Adeyemi Kayode - Initial work - paginate-mongoose-data
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details