Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories Database
Created by Guest
Created on Aug 31, 2021

Easy Paging with offset

Paging is a common functionality for REST APIs. When implementing paging queries for large datasets skip and limit is often not an option. When using query filters with non unique fields, such as creation date there can be problems such as duplicate entities on subsequent pages. It would be great to be able to additionaly pass in an offset document reference, that would be used as a start in case the filter does not lead to a unique starting point. so for example db.test.find({"creationDate" : {$gte:ISODate('2021-08-27T07:25:00Z')}, {"offset":).sort({"creationDate":1}).limit(20)
  • Attach files
  • Guest
    Sep 10, 2021
    Could you expand on this a little, why would this be preferred over adding a filter on unique field, e.g. db.test.find({"creationDate" : {$gte:ISODate('2021-08-27T07:25:00Z')}, "_id" : {$gte: lastSeenId}).sort({"creationDate":1, _id: 1}).limit(20)