couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gert Cuykens <gert.cuyk...@gmail.com>
Subject Re: url rev=x overwrite document _rev:y
Date Wed, 31 Aug 2011 23:00:19 GMT
The first example, will result into a document conflict because rev is
not specified in the doc and the rev from the the url gets ignored.
All other examples work. Note that the last example is a picture
attachment that also does not contain a rev inside a binary file, why
can this not be applied to json data too like in the first example.

curl -X PUT http://localhost:5984/_users/user%3Agert?rev=5xxx -H
'Content-Type: application/json' -d{
  "_id"          : "user:gert",
  "type"         : "user",
  "name"         : "gert",
  "roles"        : [],
  "password_sha" : "",
  "salt"         : ""
}'

curl -X PUT http://localhost:5984/_users/user%3Agert -H 'Content-Type:
application/json' -d{
  "_id"          : "user:gert",
  "_rev":"5xxx",
  "type"         : "user",
  "name"         : "gert",
  "roles"        : [],
  "password_sha" : "",
  "salt"         : ""
}'

curl -X PUT http://localhost:5984/_users/user%3Agert/picture?rev=5xxx
-H 'Content-Type: image/png' -d @picture.png

On Thu, Sep 1, 2011 at 12:33 AM, Mark Hahn <mark@boutiquing.com> wrote:
> I guess I don't understand.  All I can say is that in general you
> cannot change the _rev of a doc.  The rev includes a hash of the doc.
>
> If you want to make sure you don't get a conflict, then you will need
> to first GET the old doc and use the _rev of that old doc.  I do that
> in a loop doing a PUT over and over until I get no conflict.  Of
> course it usually works on the first PUT and no GET is needed.
>
> On Wed, Aug 31, 2011 at 2:50 PM, Gert Cuykens <gert.cuykens@gmail.com> wrote:
>> The app does not need to change the rev in the database, just the _rev
>> that is in the PUT or POST data which is about to get send too the
>> database. It already happens when adding attachments to couchdb
>> preventing conflicts. It is only logic it does this for normal updates
>> too when specified explicit in the url ignoring the _rev in the POST
>> or PUT data.
>>
>> Now I need to parse the json files one by one to change the _rev
>> inside the documents that need to get send.
>>
>> On Wed, Aug 31, 2011 at 9:00 PM, Mark Hahn <mark@boutiquing.com> wrote:
>>> The rev is used for replication.  If the app could change a rev,
>>> replication would break.
>>>
>>> On Wed, Aug 31, 2011 at 9:53 AM, Gert Cuykens <gert.cuykens@gmail.com>
wrote:
>>>> I believe that PUT http://localhost:5984/db/mydoc?rev=1-x -d
>>>> @newdoc.json should overwrite the _rev in the newdoc.json? Can you
>>>> point me too the discussion why this has not been done pleas.
>>>>
>>>
>>
>

Mime
View raw message