Answer the question
In order to leave comments, you need to log in
How to do pagination with MongoDB?
You need to do pagination, I read about the terrible speed of skip(), limit(), on foreign sites it is recommended to do this, take the id of the last document from each selection and do find() starting from it, and then limit() again, but the point is that I need for any number to find my 10 entries. Those. the number 5000 may just come in, and I need to generate 10 entries from page 5000. skip(), limit() is not an option, but how to do it then?
Answer the question
In order to leave comments, you need to log in
skip(), limit() are fast, you just need to make the correct index.
This may be slower, depends on the query and indexes.
In general, for pagination, this method is good because it will give out just the following N elements, when skip + limit you will be given "doubles" from the previous page if new elements appear in the database (for example, if you flip the page once an hour, then you can 2- th page to see the posts you viewed on the 1st page)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question