Reputation: 321
I'm using CouchDB and I have a situation where there are a bunch of documents keyed on user ids. I would like to be able to send a single query to update a particular field in all these documents. For example when a notification comes in, I'd like each user document to be updated with it by passing in the list of users to whom the notification applies and the notification message.
Upvotes: 3
Views: 2201
Reputation: 2365
Sadly the _update handlers in CouchDB currently only support a single document at a time, so it's not possible to use an _update handler on multiple documents. For this, you'd need to build a small "proxy," server-side script that would receive the request and send individual _update handler requests one per document. Not ideal, but until there's a patch to allow bulk update handlers to be built, this is the way to go.
I've requested a _bulk_update handler (or similar) be added to a future version of CouchDB...as I'd like the feature as well. :) https://issues.apache.org/jira/browse/COUCHDB-1303
Upvotes: 8
Reputation: 22436
I'd read _changes
(probably apply a filter) and then execute the HTTP queries needed.
Keep in mind that you'll need to fetch the document, before updating it.
Upvotes: 3