How does mongodb solve the skip result caused by inserting data while skipping data

  mongodb, question

Such as reading skip10 data for the first time,
Then 10 pieces of data were inserted, and the last time skip20 read the data, how should this problem be solved?

This is actually no problem, because you have new data, the original first page is already running to the second page, so you take the second page is the original 10 data. If you want to prevent the interference of new data, you can take one more condition, such as when the insertion time was before or where the _id started.
On one more condition:

  • _idThe default value for isObjectIdWhich is actually timestamped;

  • So add one more condition when querying{_id: {$lt: <id>}}It can be guaranteed that new data will not be found out.

This problem has nothing to do with MongoDB. It will happen when using relational databases. How will you deal with relational databases?