How to paginate with mongoose with query How to paginate with mongoose with query mongoose mongoose

How to paginate with mongoose with query


Try this:

const cutoff = new Date(); // The date you need.const pageOptions = {    page: parseInt(req.query.page, 10) || 0,    limit: parseInt(req.query.limit, 10) || 10}MeetingModel.find({startDate: {$lt: cutoff}})    .skip(pageOptions.page * pageOptions.limit)    .limit(pageOptions.limit)    .exec(function (err, doc) {        if(err) { res.status(500).json(err); return; };        res.status(200).json(doc);    });

I'm from Israel too :) Glad to help.