The database is MongoDB.
Suppose there is a data table (data collection-collection) --- Users.
Every time a user (User) updates his or her data, a copy of historical data needs to be retained, but not too much. For example, only the latest 5 copies can be saved at most.
If you design a table UserHistory to store old data, you need to check whether there are more than 5 records each time you save new records. If so, delete the oldest one.
Is this reasonable?
Is there a more reasonable design?
https://docs.mongodb.com/v3.0...
Can this document answer your questions?
Traditionally use triggers + stored procedures.