【问题标题】:How do we use CouchDB's _bulk_docs with all_or_nothing option?我们如何将 CouchDB 的 _bulk_docs 与 all_or_nothing 选项一起使用?
【发布时间】:2017-03-01 19:41:23
【问题描述】:

CouchDB documentation 中,他们说我们可以批量插入文档,如果我们愿意,可以使用all_or_nothingnew_edits 选项。但是,all_or_nothing 键在我们这样使用时似乎没有任何作用:

HOST="http://test:test@localhost:5984/mydb"

curl -vX POST "$HOST/_bulk_docs" \
    -H "Content-type: application/json" \
    -d @test.json

带有 test.json:

{
    "all_or_nothing":true,
    "docs":[
        {"_id":"hello"},
        {"_id":"world"}
    ]
}

这会插入具有helloworld id 的文档。通过将hello 替换为hello1 来重新运行脚本应该会导致hello1 被插入到数据库中,但world 文档的记录失败(因为它没有正确的_rev),因此它们都应该失败是因为我们说all_or_nothing。但最终,数据库中有 3 个文档:hellohello1world

我们如何在 CouchDB 中使用all_or_nothing

【问题讨论】:

    标签: transactions couchdb pouchdb


    【解决方案1】:

    我的用法是正确的。但是,我的尝试失败的原因不止一个:

    1. PouchDB-server 只是忽略(即使没有适当的错误)all_or_nothing,因为他们 do believe 这是正确的方法。

    2. Cloudant 只需 drops this feature,因为他们将数据库服务保持在分布式状态,并且事务不会让数据库扩展。

    3. CouchDB dropped all_or_nothing support in 2.0 version

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-14
      • 2013-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      相关资源
      最近更新 更多