Closed ClintEsteMadera closed 9 years ago
Yes, this should be possible. Will look at it tomorrow.
@jchiocchio Can you please provide some code that reproduces this, or even better, a test? By looking at the code passing query options to db.bulk(docs, [params], [callback])
should still be possible.
Hey Jonathan / @jchiocchio try using bulk like this:
var database = nano.use('alice');
var bulkUpdate = {};
bulkUpdate.docs = [];
for (var index in docsToSave) {
// These are CouchDB docs, with _id and _rev properties if you're doing an update
bulkUpdate.docs.push(docsToSave[index]);
}
var options = {
"all_or_nothing": true
};
database.bulk(bulkUpdate, options, function (err, response) {
if (err) {
return callback(err);
}
// Handle the response as per CouchDB spec
for (var docIndex in response) {
if (!response[docIndex].ok) {
// Something went wrong ...
}
}
}
I close this for now. Please reopen with reproducable code, or a test.
Took me way too long to figure out I had to supply an object with a docs
property set to my array of documents. I just kept trying to pass the array directly and could not figure out why it was failing.
As of version 6.1.2 of the library, the bulk function does not provide a way of specifying optional parameters supported by CouchDB's REST API, such as:
all_or_nothing (boolean) – Sets the database commit mode to use all-or-nothing semantics. Default is false. Optional new_edits (boolean) – If false, prevents the database from assigning them new revision IDs. Default is true. Optional
(params details were taken from CouchDB's official documentation )
Is there any chance for this to be included anytime soon in a future release?
Thanks very much in advance, Jonathan