CouchDB:如何使用_revs_diff获取文档修订版ID [英] CouchDB: how to use _revs_diff to get document revision ID

查看:55
本文介绍了CouchDB:如何使用_revs_diff获取文档修订版ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图测试benchDB的_revs_diff api以获取文档修订。这是我使用的命令

I tried to test couchDB's _revs_diff api to get document revisions. Here is the command I used

curl -X POST http://******:******@localhost:5984/grocery-sync/_revs_diff -H "Content-type:application/json" 

结果为

{"error":"unknown_error","reason":"badarg"}

有人知道原因吗?

推荐答案

根据 CouchDB Wiki页面 _revs_diff 如果给定文档的修订无效,则将返回一个值。没有给出使用 curl 的示例。

According to the CouchDB wiki page, _revs_diff will return a value if the revisions for a given document are invalid. No examples using curl are given.

查看此邮件列表发布问题似乎是您需要包含文档和修订信息,例如:

Looking at this mailing list posting the problem appears to be that you need to include document and revision information, like this:

$ curl -X POST -H "Content-type:application/json" \
   http://*:*@localhost:5984/grocery-sync/_revs_diff \
   -d '{"0d63eac0ca9a37daa062b23853a4cf4d":["1-e9e4e9c76323a267ff4f780f9f979b9f", "12-3286453e55eb2c401bc194670075f942"]}'


$ b $键( 0d63 ... cf4d )是文档ID,数组是修订ID。在此示例中,两个修订版本( 1 -... 12 -... )都存在于数据库中,因此响应是

Where the dictionary key (0d63...cf4d) is the document id and the array are revision ids. In this example both revisions (1-... and 12-...) are present in the database so the response is

{}

如果我提供缺少的修订ID(我发明了一个):

If I provide a missing revision id (one I invented):

$ curl -X POST -H "Content-type:application/json"  \
  http://*:*@localhost:5984/grocery-sync/_revs_diff \
  -d '{"0d63eac0ca9a37daa062b23853a4cf4d":["1-abcdef"]}'

响应为

{"0d63eac0ca9a37daa062b23853a4cf4d":{"missing":["1-abcdef"]}}

这篇关于CouchDB:如何使用_revs_diff获取文档修订版ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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