Vermongo · thiloplanz/v7files Wiki · GitHub - 0 views
-
Placing a document under version control is very unintrusive. Vermongo only adds a version number property (an int32 called _version) to the document. It does not touch any other fields. In particular, it also does not place any requirements on the contents of the _id field. Older revisions are stored in a separate collection that shadows the original collection. They are MongoDB documents themselves, and can be queried.
-
When creating, updating, or deleting documents, you just have to follow the Vermongo protocol outlined here. There will be (at least) a Java library to facilitate this. The only major downside is that documents have to be updated one-by-one (no bulk updates possible), and that there is some overhead in retrieving and copying the old version. Query operations can just proceed as normal.
-
After inserting into collection 'foo' a document { a=>"x"}, updating it to { a: "y"}, then to { a: "z" }, and finally deleting it, the shadow collection will contain the following (the original collection will not contain the document anymore, as it has been deleted): > db.foo.vermongo.find() { "_id" : { "_id" : ObjectId("4c78da..."), "_version" : 1 }, "a" : "x", "_version" : 1 } { "_id" : { "_id" : ObjectId("4c78da..."), "_version" : 2 }, "a" : "y", "_version" : 2 } { "_id" : { "_id" : ObjectId("4c78da..."), "_version" : 3 }, "a" : "z", "_version" : 3 } { "_id" : { "_id" : ObjectId("4c78da..."), "_version" : 4 }, "_version" : "deleted:4" }