GithubHelp home page GithubHelp logo

express-mongo-paginator's Introduction

Express-Mongo-Paginator

This is a simple package that paginates your mongodb collection.It uses the mongoose ORM behind the scene.

Install

npm install express-mongo-paginator

api

const paginator = require("express-mongo-paginator")

paginator

This creates a new instance of express-mongo-paginator

paginator.paginator(collection,currentpage,perpage,filterConditions,IdToBePopulated)

Arguments

  • collection :This is the collection you want to paginate;
  • currentpage : Current page;
  • perpage : Number of items in a collection to be displayed perpage;
  • filterConditions: Add querys to your collection.If there aren't any filter condition pass and empty array [].
  • IdToBePopulated : Document To be populated.

usage

const express = require('express');
const paginator = require("express-mongo-paginator");
const mongoose = require("mongoose")
const PORT = process.env.PORT || 5000;
const app = express();


app.get("/get-users", async (req, res) => {
    try {
        let data = await paginator.paginator(User, page, 2,[{
            name: req.query.name
        }],"SchoolId,CategoryId");
        res.status(200).json({data})
    } catch (err) {
        res.status(500).json(err)
    }
})
app.listen(PORT. () => {
    logger.info(`App is running on ${port}`)
})

express-mongo-paginator's People

Contributors

wisdom132 avatar

Stargazers

Brian Obot avatar Catur Prasetyo Wibowo avatar Ahmed Bankole avatar Nduke-Abasi Sam avatar Ekikere-Abasi Michael avatar

Watchers

James Cloos avatar  avatar

Forkers

ndukesam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.