couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Hendricks <mich...@ndrix.org>
Subject Re: Bulk insert conflicts
Date Fri, 25 Jul 2008 16:16:41 GMT
On Fri, Jul 25, 2008 at 10:39:49AM -0500, Gilbert B Garza wrote:
> If there are any confllicts, I suggest that it would look something like
> this:
> 
> {
>   "ok":true,
>   "conflicts":true,
>   "new_revs": [
>     {"id": "1", "rev": "12345"},
>     {"id": "3", "rev": "23456"},
>     {"id": "4", "rev": "34567"}
>   ]
>   "conflict_revs": [
>     {"id": "0", "attempted_rev": "1001", "current_rev": "1002"},
>     {"id": "2", "attempted_rev": "5000", "current_rev": "5002"}
>   ]
> }
> 
> This way, not only do you know which documents had conflicts, but the entire
> bulk operation does not have to fail.

I like the idea of indicating which documents caused the conflict.  I
can see how that would make it easier to resolve the conflicts and try
again.

The current bulk_docs behavior of failing the entire operation when one
part fails is a very useful feature though.  It allows for limited
transactions.  I use the bulk_docs feature to maintain the database in a
consistent state when I need to delete one document and create another
one.  If either operation fails, I know that the entire bulk_docs
request will fail and the database will still be in a consistent state.

Perhaps using something like this as the body of the 412 response:

    {
    "ok":false,
    "conflict_revs": [
        {"id": "0", "attempted_rev": "1001", "current_rev": "1002"},
        {"id": "2", "attempted_rev": "5000", "current_rev": "5002"}
    ]
    }

I removed "conflicts":true since that can be inferred from the presence
of conflicted_revs.

-- 
Michael

Mime
View raw message