Reputation: 333
I would like to save the information about some objects and relations between them in Mongodb. There is also requirement to save all changes objects in history and ability to look the state of the objects in the past.
Now I'm saving actual version of objects in respective collections and using separate respective collections for changes (with id of objects and change time), and collecting the state of objects in the past by using all changes by time.
I'm feeling that I'm inventing bicycle here and there is better database structure or existing framework to do this easier. Can someone recommend something? Will be very obliged, thank you.
Upvotes: 0
Views: 1234
Reputation: 9497
This is commonly referred to as "versioning" or "document versioning". The most common approaches are:
Each approach has it's own set of advantages and tradeoffs. Here are some good resource with further exploration of these approaches:
I am not aware of any popular frameworks that handle this in Java, and this may also be dependent on whether or not you are using an ODM (e.g. Spring Data MongoDB or Morphia). Mongooose (Node.js) does have document versioning.
Upvotes: 1