couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Alfke <>
Subject Re: Put method
Date Thu, 26 Sep 2013 17:41:04 GMT

On Sep 26, 2013, at 9:48 AM, Ashraf Janan <> wrote:

> I have a document field :  Student with :_id, _rev , name: "Tom" , age : "37" 
> and i want to send message to Tom

You wouldn’t do that by adding to the Tom document. (What if two people decided to send
messages?) You’d create a new document for the message, and put in a property containing
Tom’s ID. Then you create a view to index messages by person -ID, to look up the messages
for a person.

> * If i have the _id only for a student Tom,
>   Can i send a message to Tom direct?

No, because you’d end up blindly overwriting whatever was there before. You need to have
the current contents and modify them, and then send them back, in order to detect conflicts.
That way if someone else has made changes to the document since you last fetched it, the database
will return a 409 error and you can retry again, resolving the conflict.

This is all described in detail in the book (

View raw message