incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Burton <>
Subject Re: Exist test?
Date Mon, 05 Nov 2012 19:53:53 GMT
So if I create a document that already exists how does the database know that it already exists
to give me a 409 error? How do I establish a view? Won't I run into the same problem by creating
a view that already exists (via the DesignDocument)?

On Nov 5, 2012, at 1:45 PM, Robert Newson <> wrote:

> Easiest to just create the document, you'll get a 409 response to indicate
> that it already existed. If your documents don't have user assigned id's,
> then I don't see how you could check for existence before writing anyway.
> On 5 November 2012 19:40, Kevin Burton <> wrote:
>> I am mainly using it the context of initially populating a database. So
>> there isn't any danger of a race because there is only one user.
>> On Nov 5, 2012, at 12:47 PM, Jens Alfke <> wrote:
>>> On Nov 5, 2012, at 10:22 AM, Kevin Burton <>
>> wrote:
>>>> I am calling CreateDocument<Document>() but I suspect that testing
>> the document exists first may perform better in the long run. I am using
>> DreamSeat for my driver but I suspect other drivers have a similar "test".
>> My problem is that I don't know what to test for and I am unfamiliar with
>> the available methods. Any one successfully use such a pattern (preferably
>> with DreamSeat) that tests for existence then creates if the document
>> doesn't exist? Keep in mind I don't initially have an id. Thank you.
>>> I don’t know anything about that particular API, but in general,
>> check-then-create doesn’t work well in a concurrent environment. It’s prone
>> to race conditions where something else creates the resource in between
>> your check call and your create call. (The canonical example is checking
>> whether a file exists, then creating the file, which is a classic old
>> security hole in privileged Unix tools.)
>>> —Jens

View raw message