On Tue, Nov 16, 2010 at 8:37 AM, Karel Minařík <[email protected]> wrote:
> Hmm, could you explain a bit how it should work? (Because the way I
> understand it, you have to iterate over _all_ the docs and check `if
> doc.value == xxx` in the client code? That'd be impossible for large data
> sets.)
Given /mydb/_design/mydd with the following (I'm not bothering with
quotation marks, so this isn't copy/pasteable):
views: { foo: { map: function(doc) { emit(doc.value, doc._rev) } } }
Then you fetch this:
/mydb/_design/mydd/_view/foo?key="xxx"
Which will include the doc id's and revisions of all the matching
docs. Then you use that result to build up a request like this:
{ docs: [ { _id: someid, _rev: itsrev, _deleted: true }, { _id:
someotherid, ...} ] }
Which you then post to /mydb/_bulk_docs, and then all the matching
docs are deleted, with only two HTTP round-trips.
For selective updating, you can use an update handler to modify a
document "in-place" without first fetching and then storing the whole
thing, but then you can't do that in bulk.
--
Mark J. Reed <[email protected]>