在MongoDB中实现数据版本控制的方法

本文讨论如何在MongoDB中实现数据版本控制,提出了多种方法,包括创建新对象集合存储历史记录、将版本作为序列化JSON对象附加到条目、使用Mongoid的内置版本控制、采用Vermongo方案以及利用单个文档存储所有版本。同时,文章还提到了并发更新和删除文档的处理,以及如何选择存储差异或完整记录副本。
摘要由CSDN通过智能技术生成

本文翻译自:Ways to implement data versioning in MongoDB

Can you share your thoughts how would you implement data versioning in MongoDB. 您能否分享您的想法,如何在MongoDB中实现数据版本控制。 (I've asked similar question regarding Cassandra . If you have any thoughts which db is better for that please share) (我也曾问过有关Cassandra的类似问题 。如果您有任何想法,哪个数据库更好,请分享)

Suppose that I need to version records in an simple address book. 假设我需要在一个简单的通讯簿中对记录进行版本控制。 (Address book records are stored as flat json objects). (地址簿记录存储为平面json对象)。 I expect that the history: 我希望这段历史:

  • will be used infrequently 将很少使用
  • will be used all at once to present it in a "time machine" fashion 将一次全部使用,以“时间机器”的方式呈现
  • there won't be more versions than few hundred to a single record. 单个记录的版本不会超过几百个。 history won't expire. 历史不会过期。

I'm considering the following approaches: 我正在考虑以下方法:

  • Create a new object collection to store history of records or changes to the records. 创建一个新的对象集合以存储记录的历史记录或对记录的更改。 It would store one object per version with a reference to the address book entry. 它将在每个版本中存储一个对象,并引用地址簿条目。 Such records would looks as follows: 这样的记录如下:

    \n{
         {
        \n '_id': 'new id', '_id':'新ID',\n 'user': user_id, '用户':user_id,\n 'timestamp': timestamp, '时间戳':时间戳,\n 'address_book_id': 'id of the address book record' 'address_book_id':'通讯录记录的ID' \n 'old_record': {'first_name': 'Jon', 'last_name':'Doe' ...} 'old_record':{'first_name':'Jon','last_name':'Doe'...}\n} }\n

    This approach can be modified to store an array of versions per document. 可以修改此方法以存储每个文档的版本数组。 But this seems

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值