1

根据 couchDb 2.0 http://docs.couchdb.org/en/2.0.0/api/database/common.html的官方文档

GET /{db} 获取有关指定数据库的信息。

参数:db - 数据库名称请求标头:

接受 – 应用程序/json 文本/纯文本

响应标头:

Content-Type –
application/json
text/plain; charset=utf-8

响应 JSON 对象:

committed_update_seq (number) – The number of committed update.
compact_running (boolean) – Set to true if the database compaction routine is operating on this database.
db_name (string) – The name of the database.
disk_format_version (number) – The version of the physical format used for the data when it is stored on disk.
data_size (number) – The number of bytes of live data inside the database file.
disk_size (number) – The length of the database file on disk. Views indexes are not included in the calculation.
doc_count (number) – A count of the documents in the specified database.
doc_del_count (number) – Number of deleted documents
instance_start_time (string) – Timestamp of when the database was opened, expressed in microseconds since the epoch.
purge_seq (number) – The number of purge operations on the database.
**update_seq (number) – The current number of updates to the database.**

状态码:
200 OK – 请求成功完成 404 Not Found – 未找到请求的数据库

update_seq 必须作为数字返回,但是当我们运行请求时

http://192.168.1.48:5984/testing **(CouchDb 2.0)**响应是

{"db_name":"testing","update_seq":"0-g1AAAAFTeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rkQGPoiQFIJlkT1idA0hdPGF1CSB19QTV5bEASYYGIAVUOp8YtQsgavcTo_YARO19YtQ-gKgFuTcLANRjby4","sizes":{"file":33952,"external":0,"active":0},"purge_seq":0,"other":{"data_size":0},"doc_del_count":0,"doc_count":0,"disk_size":33952,"disk_format_version":6,"data_size":0,"compact_running":false,"instance_start_time":"0"}

以前在我们运行请求时在 couchdb 1.6.1 中

http://192.168.1.80:5984/learners (CouchDb 2.0)响应是

{"db_name":"learners","doc_count":0,"doc_del_count":3,**"update_seq":6**,"purge_seq":0,"compact_running":false,"disk_size":12386,"data_size":657,"instance_start_time":"1487830025605920","disk_format_version":6,"committed_update_seq":6}

所以请解释一下这是couchdb 2.0或其他什么的例外。

4

1 回答 1

3

CouchDB 文档不是最新的。CouchDB 2.0 引入了集群,并且通过集群,update_seq 必须更改为唯一的字符串。

您应该将 update_seq 视为不透明的标识符,而不是具有内在含义的东西。如果 update_seq 已更改,则数据库本身已更改。

也就是说,update_seq 的第一部分是一个数字,所以如果你真的需要数字序列,你可以解析它。但我强烈建议不要依赖它,因为 update_seq 格式可能会在未来版本的 CouchDB 中发生变化。

于 2017-03-03T11:02:30.323 回答