tags:

views:

65

answers:

1

Not exactly sure what to call this, but in SQL I often find myself doing something like this while developing:

DELETE FROM people WHERE name == "John"

This is often used when I've just imported a bunch of data with a batch importer, and want to clear out a few results but not then entire data set. How do I go about doing this in CouchDB? I can easily make a map function

function(doc) {
   if (doc.Name == "John") 
       emit(doc._id, null);
}

And then delete the returned _ids...but that would require me to write some sort of front-end app to take these _ids and perform the DELETEs. Sometimes my queries are much more complex, and would require a few queries, followed by a delete, followed by another query and an update.

What's the accepted method of doing this sort of map/delete and perhaps a map/update?

+2  A: 

The excepted method is pretty much just as you descibe. Query the view and then delete the returned ids. This isn't as bad as it sounds though. A quick script in your choice of language with a CouchDB library and you are essentially just moving the logic of your sql into a language with more power. Some might consider this benefit. YMMV

Jeremy Wall