For saving bulk documents i am using bulkDocs function and it is working fine. But how to use all-or-nothing option in bulkDocs function. I have tried the following code.
db.bulkDocs(docs, "all-or-nothing",function (err, body, res) {
console.log(body);
});
It's not working for me. Please suggest me to use that option because i need to save all documents or if any error occur none can be saved.
Thanks.
The node-couchdb-api bulkDocs
api only supports two arguments -- data and the callback. Instead of passing the option as an argument try embedding it in the data passed to bulkDocs
as shown in the CouchDB Documentation and below.
For example, I believe this should do what you want but I don't have a system setup at the moment to test it:
var data = {
"all_or_nothing": true,
"docs": docs
}
db.bulkDocs(data, function(err, body, errs) {
console.log(body);
}