Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
Storage Execution
Description
I'd like to be able to track the changes made to a collection.
This should be something that you could choose to activate on a collection or not.
I'll attempt to describe how this could be implemented so it's clear what I'm proposing, but I don't know if this would be the best way.
Once this feature has been activate in a collection, any change made to that collection would cause a new document to be created in a another collection.
That collection could be called "ChangeHistory" (or something like that), and that doc would contain info regarding what exactly changed.
The change document could look like:
_id : ObjectID() // unique id for this change
author : "ppinto" // the user who made this change
timeStamp : date/time // when the change was made
parentChanges : [] // array of 0, 1 or 2 parent change ids
previousContent: {} // an object that contains the data that was modified as it was before being modified
newContent: {} // an object that contains the data that was modified after it was modified
The parentChanges array above is used so we can track the order in which the changes were made. If the array is empty, then this is the first change. If the array has one change, that is the parent change. If the array has 2 changes, then this change is a merge change (much like the mercurial or git track their changes).
The previousContent and newContent properties only store the information that was actually changed and not the whole document that was changed.
As I said before, I don't know if this would be the best way to implement this feature, but the important points in this feature are:
- changes to a collection are tracked (only the changed data, not the whole document where the change was made)
- changes contain enough information to allow you to reproduce a collection at any point in its history.
- changes can be merged from one collection (or database) to another in the correct order that they happened.
- each change has a uniqueID so that the same change doesn't get merged twice