是否可以在集合中创建全局自动递增值?
Is there a way to create a globally auto-incrementing value in a collection?
Perforce具有变更列表#的概念,它可以成为无状态更新的强大功能.我在考虑相同类型的功能.
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然后,我可以搜索在changelist:4之后进行的所有更改,并确信我没有错过任何事情.
Then I can search for any changes made after changelist:4 and be confident I did not miss anything.
任何来自mongodb专家的想法如何有效地做到这一点?
Any thoughts from the mongodb gurus on how to do that efficiently?
推荐答案MongoDB文档列出了自动递增字段.一般来说,这是不好的做法,但这可能会满足您所寻求的功能.
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.
同样,如果这是一个非常关键的功能,则您可能想看看Riak的MVCC,它似乎与您想要的最接近.
Likewise, if this is a really key feature, you may want to look at Riak's MVCC which seems closest to what you want.
更多推荐
MongoDb中的全局自动递增字段
发布评论