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.