Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Cursor style limit on sorted items given an ObjectID in Mongo

I have a set of fields with variable match and sort criteria, i.e. a Smart Query. I run an aggregation that matches and sorts, but I'd like to implement a cursor style pagination. For my normal lists I can use a greater than the order field of a ObjectID passed into my API, but Smart Queries won't have a hard coded order field.

How can I use an ObjectID to get the next (n) number of items in a list that I've already matched and sorted. Using javascript and mongoose here's some general code for my current query

const plist = await Media.aggregate([
          ...smartMatch,
          ...smartSort,
          //somehow match and limit next (n) items after ObjectID,
        ]).allowDiskUse(true);

Smart Match and Sort being an array of operations defined by the user.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!