你能分享一下你如何在MongoDB中实现数据版本控制的想法吗?(关于卡桑德拉,我也问过类似的问题。如果你有任何想法,哪个db更好,请分享)
假设我需要对一个简单地址簿中的记录进行版本化。(地址簿记录存储为平面json对象)。我希望历史:
是否会不经常使用 会被一次性用“时间机器”的方式呈现出来吗 一张唱片的版本不会超过几百个。 历史不会终结。
我正在考虑以下方法:
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: { '_id': 'new id', 'user': user_id, 'timestamp': timestamp, 'address_book_id': 'id of the address book record' 'old_record': {'first_name': 'Jon', 'last_name':'Doe' ...} } This approach can be modified to store an array of versions per document. But this seems to be slower approach without any advantages. Store versions as serialized (JSON) object attached to address book entries. I'm not sure how to attach such objects to MongoDB documents. Perhaps as an array of strings. (Modelled after Simple Document Versioning with CouchDB)