可以在 CouchDB 中访问旧数据吗? [英] Are old data accessible in CouchDB?

查看:17
本文介绍了可以在 CouchDB 中访问旧数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过一些关于 CouchDB 的文章,我对它是仅附加"的事实非常感兴趣.我可能会误解,但据我了解,它的工作原理有点像这样:

I've read a bit about CouchDB and I'm really intrigued by the fact that it's "append-only". I may be misunderstanding that, but as I understand it, it works a bit like this:

  • 在时间 t0 将数据添加到数据库,告知 ID 为 1 的用户名为Cedrik Martin"

  • data is added at time t0 to the DB telling that a user with ID 1's name is "Cedrik Martin"

询问ID 为 1 的用户的名字是什么?" 的查询返回 Cedrik Martin"

在时间 t1 对 DB 进行更新,告知:ID 为 1 的用户名为 Cedric Martin"(将k"更改为'c').

at time t1 an update is made to the DB telling: "User with ID 1's name is Cedric Martin" (changing the 'k' to a 'c').

再次询问 ID 为 1 的用户的名字是什么" 现在返回Cedric Martin"

a query asking again "what is the name of the user with ID 1" now returns "Cedric Martin"

这是一个愚蠢的例子,但这是因为我想了解一些关于 CouchDB 的基本知识.

It's a silly example, but it's because I'd like to understand something fundamental about CouchDB.

看到更新是使用数据库末尾的追加进行的,是否可以在时间 t0"查询数据库,而不做任何特别的事情?

Seen that the update has been made using an append at the end of the DB, is it possible to query the DB "as it was at time t0", without doing anything special?

我可以问 CouchDB 在时间 t0 时 ID 为 1 的用户的名字是什么?"?

Can I ask CouchDB "What was the name of the user with ID 1 at time t0?" ?

EDIT 第一个答案非常有趣,所以我有一个更精确的问题:只要我不压缩"CouchDB,我就可以编写以某种方式引用"的查询透明"(他们会总是产生相同的结果)?例如,如果我查询 "document d at revision r",只要我不压缩数据库,我是否保证总是得到相同的答案?

EDIT the first answer is very interesting and so I've got a more precise question: as long as I'm not "compacting" a CouchDB, I can write queries that are somehow "referentially transparent" (i.e. they'll always produce the same result)? For example if I query for "document d at revision r", am I guaranteed to always get the same answer back as long as I'm not compacting the DB?

推荐答案

也许 CouchDB 最常见的错误是认为它为您的数据提供了一个版本控制系统.它没有.

Perhaps the most common mistake made with CouchDB is to believe it provides a versioning system for your data. It does not.

压缩会删除所有文档的所有非最新版本,而复制只会复制任何文档的最新版本.如果您需要历史版本,则必须使用您认为合适的任何方案将它们保留在最新版本中.

Compaction removes all non-latest revisions of all documents and replication only replicates the latest revisions of any document. If you need historical versions, you must preserve them in your latest revision using any scheme that seems good to you.

如前所述,_rev"是一个不幸的名字,但没有其他更清楚的词被提出._mvcc"和_mcvv_token"之前已经被推荐过.两者的问题是,任何关于那里发生的事情的描述都不可避免地包括旧版本保留在磁盘上直到压缩",这仍然意味着它是一个用户版本控制系统.

"_rev" is, as noted, an unfortunate name, but no other word has been suggested that is any clearer. "_mvcc" and "_mcvv_token" have been suggested before. The issue with both is that any description of what's going on there will inevitably include the "old versions remain on disk until compaction" which will still imply that it's a user versioning system.

要回答我可以问 CouchDB在时间 t0 时 ID 为 1 的用户的名字是什么?"这个问题,简短的回答是否".长答案是是的,但后来它不起作用",这只是说不"的另一种方式.:)

To answer the question "Can I ask CouchDB "What was the name of the user with ID 1 at time t0?" ?", the short answer is "NO". The long answer is "YES, but then later it won't work", which is just another way of saying "NO". :)

这篇关于可以在 CouchDB 中访问旧数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆