In the CouchDB documentation they say we can insert documents in bulk, with all_or_nothing
or new_edits
option if we want to. But it seems, all_or_nothing
key does not have any effects when we use like so:
HOST="http://test:test@localhost:5984/mydb"
curl -vX POST "$HOST/_bulk_docs" \
-H "Content-type: application/json" \
-d @test.json
with a test.json:
{
"all_or_nothing":true,
"docs":[
{"_id":"hello"},
{"_id":"world"}
]
}
This inserts documents which have hello
and world
ids. Re-running the script by replacing hello
with hello1
should cause hello1
to be inserted in the database but fail the world
document's recording (since it doesn't have correct _rev
), thus they both SHOULD fail because we said all_or_nothing
. But in the end, there are 3 documents in the database: hello
, hello1
and world
.
How do we use all_or_nothing
with CouchDB?