How do we use CouchDB's _bulk_docs with all_or_nothing option?
Asked Answered
W

1

6

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?

Wolfgang answered 20/10, 2016 at 0:40 Comment(0)
W
6

My usage was correct. However, there are more than one reason why my attempts are failed:

  1. PouchDB-server simply ignores (even without a proper error) all_or_nothing as they do believe this is the correct way.

  2. Cloudant simply drops this feature as they keep their database service distributed and transaction thing does not let the database scale.

  3. CouchDB dropped all_or_nothing support in 2.0 version.

Wolfgang answered 20/10, 2016 at 2:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.