简体   繁体   English

如何查询ArangoDB中的修订历史记录?

[英]How do I query revision history in ArangoDB?

I see the _rev in every document created in ArangoDB, but I have yet to see any information about using those revisions to access the change history for a document. 我在_rev中创建的每个文档中都看到了_rev ,但是我还没有看到有关使用这些修订来访问文档的更改历史记录的任何信息。 More specifically, how do I query the revision history for a specific document to see the previous versions or even a specific version in time? 更具体地说,如何查询特定文档的修订历史记录以及时查看以前的版本甚至特定的版本?

My understanding is that the revision ( _rev ) attribute is just there as a marker so you can know when a field was updated. 我的理解是,修订( _rev )属性作为标记存在,因此您可以知道字段何时更新。 You can't change it directly, but every time you UPDATE a document in a collection, the _rev value is updated. 您不能直接更改它,但是每次UPDATE集合中的文档时, _rev值都会更新。

To store historical values you would need to implement a process to archive the old values of a document when they get updated. 要存储历史值,您需要实现一个过程,以便在文档的旧值更新时将其存档。

The _rev attribute can be very helpful when scanning a document and seeing if any values were changed. _rev属性在扫描文档并查看是否有任何值更改时非常有用。 Rather than having to do a deep compare on a document and what you expect to see, you can just compare the _rev attribute with what you expect to see. 不必对文档和您希望看到的内容进行深入比较,只需将_rev属性与您希望看到的内容进行比较。 If the database returns a different _rev value than what you were checking for then your code can respond to the document changing, however required. 如果数据库返回的_rev值与您要检查的值不同,则您的代码可以响应文档的更改(无论如何)。

Remember, you have access to the old version of a document when you execute an UPDATE or UPSERT command ( the doco ) and you could choose to return the OLD document contents to push off to an archive location, or process as you wish. 请记住,在执行UPDATEUPSERT命令( doco )时,您可以访问文档的旧版本,并且可以选择返回OLD文档内容以下达到存档位置,或根据需要进行处理。 The updated document will receive a new _rev value after that update. 更新的文档在更新后将收到一个新的_rev值。

The OLD value does not persist after the return of the UPDATE or UPSERT command, so you'll have to archive it right away or the older document will be lost. 返回UPDATEUPSERT命令后, OLD值将不持久,因此您必须立即对其进行归档,否则旧的文档将丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM