couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Smith <...@iriscouch.com>
Subject Re: how to delete document with empty _id
Date Fri, 30 Sep 2011 16:16:09 GMT
I do not think Damien's suggestion works. During bulk updates, CouchDB
will replace both a missing ID and also an empty string ID with a
UUID.

https://github.com/apache/couchdb/blob/trunk/src/couchdb/couch_httpd_db.erl#L296-299

and

https://github.com/apache/couchdb/blob/trunk/src/couchdb/couch_db.hrl#L99-101

On Fri, Sep 30, 2011 at 10:15 PM, Zachary Zolton
<zachary.zolton@gmail.com> wrote:
> Does the _update function do the same thing as Damien's suggestion to
> POST to _bulk_docs? (Just curious)
>
> On Fri, Sep 30, 2011 at 6:02 AM, Jason Smith <jhs@iriscouch.com> wrote:
>> You can delete the problematic document with an empty ID using a
>> Javascript _update function.
>>
>> I wrote about it at
>> http://stackoverflow.com/questions/7604557/how-do-you-delete-a-couchdb-document-with-an-empty-document-id/7605456#7605456
>>
>> Basically just make an _update function which returns [{_id:"",
>> _rev:$your_rev, _deleted:true}, "Hasta lasagna, baby"];
>>
>> On Thu, Sep 29, 2011 at 12:50 AM, bsquared <bwcode4u@gmail.com> wrote:
>>> Christopher Bonhage <queezey@me.com> writes:
>>>
>>>> couchdb -i
>>>>
>>>> DbName = <<"database_name_here">>,
>>>> DocId = <<>>,
>>>> rr(couchdb),
>>>> {ok, Db} = couch_db:open(DbName, [{user_ctx, #user_ctx{roles=[<<"_admin">>]}}]),
>>>> case couch_db:open_doc(Db, DocId) of
>>>>         {ok, Doc} ->
>>>>             couch_db:update_doc(Db, Doc#doc{deleted=true}, []);
>>>>         Error ->
>>>>             Error
>>>> end.
>>>>
>>>>
>>>
>>> It appears that I need to include a user_ctx record the response from
>>> this code was:
>>> * 5: record user_ctx undefined
>>>
>>> --
>>> Regards,
>>> Brian Winfrey
>>>
>>>
>>
>>
>>
>> --
>> Iris Couch
>>
>



-- 
Iris Couch

Mime
View raw message