incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark J. Reed" <markjr...@gmail.com>
Subject Re: DELETE doc without rev
Date Tue, 19 Oct 2010 13:54:34 GMT
I find it helpful to use doc._rev as the value in emit()s that would
otherwise have a null, in views you might query to identify documents
to delete.

For quick manual removal from the command line, I  use this bash
function to automatically fill in the rev:

rmdoc() {
    local url
    for url in "$@"; do
        curl -X DELETE "$url"?rev="$(curl -I "$url" | sed -ne
's/^Etag: "\(.*\)".*$/\1/p')"
    done
}

e.g.

rmdoc http://localhost:5984/mydb/mydoc-123



On Tuesday, October 19, 2010, Matt Goodall <matt.goodall@gmail.com> wrote:
> On 19 October 2010 11:39, Alex Ivasyuv <industral@gmail.com> wrote:
>> Hi,
>>
>> I would like to delete a document from DB. But for this purpose I need to
>> explicitly mentioned a version, what's assume, to get
>> one more call for get it.
>> Is there any way to delete doc without mentioned revision of doc, e.g.
>>
>> $ curl -X DELETE http://localhost:5984/mydb/mydoc-123
>
> You must provide the current _rev to delete a document. However, you
> can get the doc's current rev from the ETag in a HEAD response.
>
> $ curl http://localhost:5984/mydb/mydoc-123 -I
> HTTP/1.1 200 OK
> Server: CouchDB/1.0.1 (Erlang OTP/R13B)
> Etag: "3-825cb35de44c433bfb2df415563a19de"
> Date: Tue, 19 Oct 2010 11:00:41 GMT
> Content-Type: text/plain;charset=utf-8
> Content-Length: 64
> Cache-Control: must-revalidate
>
> - Matt
>

Mime
View raw message