You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Alex Ivasyuv <in...@gmail.com> on 2010/10/19 12:39:24 UTC
DELETE doc without rev
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
Thanks,
Re: DELETE doc without rev
Posted by "Mark J. Reed" <ma...@gmail.com>.
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 <ma...@gmail.com> wrote:
> On 19 October 2010 11:39, Alex Ivasyuv <in...@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
>
Re: DELETE doc without rev
Posted by Matt Goodall <ma...@gmail.com>.
On 19 October 2010 11:39, Alex Ivasyuv <in...@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