No skip parameter on find query?

Skip to first unread message

James Cooke

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

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

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:

Let me know if you have any other questions!

Raj Narayan

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
0 new messages