couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Hendricks <mich...@ndrix.org>
Subject Re: deleting a deleted document
Date Fri, 11 Jul 2008 18:23:46 GMT
On Fri, Jul 11, 2008 at 05:01:05PM +0100, Noah Slater wrote:
> On Fri, Jul 11, 2008 at 09:20:41AM -0600, Michael Hendricks wrote:
> > My other concern is that the CouchDB REST API doesn't accept double
> > deletions.  It generates an error.  If CouchDB is going to give an error
> > in one place, I think it should be consistent and do it elsewhere too.
> 
> Consistency is good.

The use case I'm working with is something like this.  I have a document
that I want to delete.  If the document exists in the database
everything is fine and the delete operation proceeds normally.  If the
document has already been deleted from the database, my own knowledge of
the database's state was obviously wrong (or I wouldn't have tried to
delete this document).  In some cases I don't care and in some cases I
do.

If CouchDB silently deletes documents that have already been deleted, I
have no way of finding that out because the return value from _bulk_docs
gives no hint.

If, for example, I run "rm file-does-not-exist" at a bash shell it
generates a warning and helpfully sets $? to 1.  If I don't care that
the file was missing, I just ignore the return value.  If I do care, I
can take appropriate action.  I hesitate to use an example from RDBMSes
(since we probably wouldn't be here if we cared much for them), but when
I perform a DELETE query I receive a count of the rows affected (at
least in PostgreSQL, MySQL and SQLite).  If the count matters to me, I
can use it.  If not, I can ignore it.

Perhaps _bulk_docs could return something like:

    {
        "ok" : true,
        "new_revs" : [
            { "id" : "123edce", "rev" : "12345" },
            { "id" : "ca32f29", "rev" : "55632", "already_deleted" : true },
        ],
    }

which would let consumers take action if they care.

We can't assume that people will just use DELETE if they want this kind
of notice because that doesn't scale well to deleting many records or
performing these deletions as part of an atomic operation.

-- 
Michael

Mime
View raw message