I can see the limit option in mongoDB Stitch docs but unable to find how can we skip records for pagination.
Asked
Active
Viewed 590 times
3
-
1Hi~ 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 Answers
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
-
1i am talking about stitch not core mongodb. when i try this it gives me error "TypeError: 'skip' is not a function". – Muhammad Furqan Apr 02 '18 at 05:33