【发布时间】:2017-03-01 19:41:23
【问题描述】:
在CouchDB documentation 中,他们说我们可以批量插入文档,如果我们愿意,可以使用all_or_nothing 或new_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"}
]
}
这会插入具有hello 和world id 的文档。通过将hello 替换为hello1 来重新运行脚本应该会导致hello1 被插入到数据库中,但world 文档的记录失败(因为它没有正确的_rev),因此它们都应该失败是因为我们说all_or_nothing。但最终,数据库中有 3 个文档:hello、hello1 和 world。
我们如何在 CouchDB 中使用all_or_nothing?
【问题讨论】:
标签: transactions couchdb pouchdb