Open alexborisov opened 8 years ago
Yes, this is something I have thought of but I have not concluded on what the best API interface should look like. Any suggestions?
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)
I'd love to see something like this as well. Thanks for a great project!
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()