3

I can see the limit option in mongoDB Stitch docs but unable to find how can we skip records for pagination.

enter image description here

Wan B.
  • 18,367
  • 4
  • 54
  • 71
Muhammad Furqan
  • 324
  • 3
  • 16
  • 1
    Hi~ i have same issues while using mongodb Stitch... Did you find any good solution to fix this issue?? I saw Stitch doesn't support Skip() function. – Jihoon Kwon Apr 13 '18 at 05:33

2 Answers2

8

You can use aggregate with pipeline. Something like that:

exports = function(arg){
  const mongodb = context.services.get("mongodb-atlas");
  const coll = mongodb.db(<dbname>).collection(<collectionname>);

  const pipeline = [
    { "$skip" : 1 },
    { "$limit": 20 }
  ];

return coll
    .aggregate(pipeline)
    .toArray();

};
Aras Cglzn
  • 254
  • 2
  • 10
-2

this will skip 1st 100 doc from the result

db.collection.find({query}).skip(100)

here query is what you queried for.

nishant kumar
  • 507
  • 10
  • 28