couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <>
Subject Re: _changes feed with filter - does filter pick up deletions?
Date Wed, 22 May 2013 21:18:25 GMT
return doc.doc_type === "foo" || doc._deleted;

You're blocking deletes.


On 22 May 2013 21:17, Jens Alfke <> wrote:
> On May 22, 2013, at 1:09 PM, Daniel Myung <> wrote:
>> I've got a changes listener with a filter on it that checks:
>> return doc.doc_type == "foo";
>> If I delete a document matching that criteria, I'm observing that it never
>> gets emitted on that filtered changes feed with that criteria and the
>> {"deleted": true } block.
>> Is this expected behavior as designed?
> Yes, and this is a very common question. I think it’s come up on this list within the
past week.
> By default, when a document is deleted its contents are replaced with a “tombstone”
revision that just consists of {“_deleted”:true}. So a filter that checks for any other
properties won’t find them. The best solution is to delete the document and still keep whatever
properties your filter needs — you can do that by updating the document with PUT and adding
a “_deleted”:true property to its contents. Or alternatively, I’ve heard you can add
a JSON HTTP body to the DELETE request, containing the extra properties you want the ‘tombstone’
revision to have.
> —Jens

View raw message