When I create a new document both the id and rev will be null. So in order to 
determine if the create is a duplicate another field must be involved.
A view (this is my crude understanding) is a function in the database that test 
for programmable field values in the document. A design document is basically a 
document of views that can be persisted to the db. For example say my document 
had a field 'title' I could construct a view to return all documents that have 
a given 'title'. The reason that I brought this up in this context is that if I 
could check to see if there were any documents that had a particular title then 
I would be closer to finding out if the document had already been inserted in 
the db. Problem is that I don't know how to do all this with DreamSeat. Maybe I 
should use another .NET driver.

On Nov 5, 2012, at 2:00 PM, Jens Alfke <[email protected]> wrote:

> 
> On Nov 5, 2012, at 11:53 AM, Kevin Burton <[email protected]> wrote:
> 
>> So if I create a document that already exists how does the database know 
>> that it already exists to give me a 409 error?
> 
> If you PUT a document, and the body of your request has no ‘_rev’ property, 
> it’s an initial creation of a new document. The request will fail if there is 
> already a document with that ID in the database. (CouchDB can tell this apart 
> from an update request because you didn’t include the document’s existing 
> ‘_rev’ in the request.)
> 
> If you’re using POST, that by definition always creates a new document (with 
> a randomly-assigned ID), so it’s meaningless to say whether the document 
> already exists.
> 
>> How do I establish a view? Won't I run into the same problem by creating a 
>> view that already exists (via the DesignDocument)?
> 
> Sorry, I don’t understand the question.
> 
> Maybe you should back up and describe what you’re trying to do in more detail.
> 
> —Jens

Reply via email to