You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any thoughts on how to implement a custom page/limit filter? Near as I can tell this itsn't handled in a normal query which gets built, but are additional operators find().limit().skip()
The text was updated successfully, but these errors were encountered:
Commonly this is done via a ?limit&page. On a side note it's actually not super efficient to use skip because this is done on a cursor so the data is first fetched in it's entirety and then paged. Mongo suggests using ranged queries using either a date field or _id (which is sorted). So you would then ask for the next 10 records starting form date/id X.
Personally I think this can all get a little messy. Perhaps a better approach would be to consider doing all of this via the aggregation pipeline. The benefit of this is that your query object is an array of aggregation queries so you can build this up with the middleware and pass a single query object to mongo (for instance how would you easily handle count, skip, limit or any other cursor operation?).
You could even make this an option (so the output of this middleware will either be a simple query or a pipeline)
Hey,
Any thoughts on how to implement a custom page/limit filter? Near as I can tell this itsn't handled in a normal query which gets built, but are additional operators
find().limit().skip()
The text was updated successfully, but these errors were encountered: