The Design of mongodb Database

  mongodb, question

The database uses mongodb, the back end uses koa, and mongoose is used to connect the database with the back end. is used to make a chat webapp, because I got 10 messages in the initial state. originally, it was supposed to skip the previously sent data and return 10 messages at a time according to the front page. Then every message sent is stored in the database. However, if you want to obtain historical information later, because new information has been added to the database, you do not know where to continue to obtain historical information from the initial place at this time.

In fact, the data in the database will change dynamically. How is this part actually designed?

According to the time, according to the time of the earliest message in the front-end message queue, 10 messages earlier than this time are returned.