mongoose-paginate-formatted

1.0.3 • Public • Published

Mongoose package that allow to paginate bulk data and Query without 3rd party library.

mongoose-paginate-formatted

mongoose-paginate-formatted is a mongoose based pagination library which have no dependencies other than mongoose. The main use of this library is to make query efficient and alter the return value by minimal change in query. This library provides formatted output to work with.

Installation

Install mongoose-paginate-formatted with npm

  npm install mongoose-paginate-formatted

Usage/Examples

const getPaginatedResponse = require("mongoose-paginate-formatted"); //Import Library
const schema = require(/*Import your Schema */);

let page = 1; //The page you like to have
let size = 10; //The number of Data you want to get
let sortQuery = {}; //On what basis to sort. ex: ```{"_id":-1} ``` for Last data First
let searchQuery = {}; //On what fundamental you like to search. ex: ```{_id:userId}``` to pick data of certain user
let selectQuery = ""; //What field to pick from schema. ex: ```"userId name address"```` sample field
let populate = [] ; //If data need to populate from another schema. ex: ```[{path:"userId",select:""}]```

let paginatedData = await getPaginatedResponse(
        schema,
        page,
        size,
        sortQuery,
        searchQuery,
        selectQuery,
        populate
      );

Package Sidebar

Install

npm i mongoose-paginate-formatted

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

3.3 kB

Total Files

3

Last publish

Collaborators

  • vkash