global auto-incrementing field in MongoDb
Is there a way to create a globally auto-incrementing value in a collection?
Perforce has the concept of a changelist# that can be a powerful feature for stateless updates. I am thinking of the same type of functionality.
create> DocA.name = "foo" => changelist = 1 create> DocB.name = "bar" => changelist = 2 update> DocA.name = "bob" => changelist = 3 create> DocC.name = "joe" => changelist = 4
DocA.changelist = 3 DocB.changelist = 2 DocC.changelist = 4
Then I can search for any changes made after changelist:4 and be confident I did not miss anything.
Any thoughts from the mongodb gurus on how to do that efficiently?
The MongoDB docs have a listing for auto-incrementing fields. In general it is bad practice, but this could work for the functionality you seek.
That stated, I have also seen people use "timestamps" for the last updated time. This may satisfy your requirements.
Likewise, if this is a really key feature, you may want to look at Riak's MVCC which seems closest to what you want.