No skip parameter on find query?

37 views
Skip to first unread message

James Cooke

unread,
Jul 20, 2018, 9:36:57 PM7/20/18
to MongoDB Stitch Users
Hi,

Just trying to set up some pagination but have come a bit stuck as it doesn't seem there is a skip parameter on a find query on the client sdk.

I can't find it mentioned in the docs either. Is it something that will be added?

Eric Daniels

unread,
Jul 20, 2018, 9:52:22 PM7/20/18
to MongoDB Stitch Users
Hi James,

We don't currently support skip in the Stitch MongoDB API and we don't have any future plans to. Skip is generally inefficient with indexes since it requires passing over many index entries. We recommend using range based pagination instead. See: https://docs.mongodb.com/manual/reference/method/cursor.skip/#using-range-queries

Let me know if you have any other questions!
Eric

Raj Narayan

unread,
Jun 22, 2019, 5:22:31 PM6/22/19
to MongoDB Stitch Users
Yea what Eric suggests works for me. The only difference I read somewhere that on Stitch limit should be in the options.

const query = startKey ? { "_id": { "$lt": new BSON.ObjectId( startKey ) }} : {}; // startKey in my case is a string
const options = {"sort": {"_id": -1}, "limit": nPerPage};
collection.find(query, options).toArray();
Reply all
Reply to author
Forward
0 new messages