Skip to content

Commit

Permalink
(#471) - bulkDocs errors inconsistency
Browse files Browse the repository at this point in the history
Return with the first error when some documents have invalid ids.
  • Loading branch information
jo committed Feb 22, 2013
1 parent fb079e2 commit 97a1605
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/adapters/pouch.idb.js
Expand Up @@ -167,6 +167,13 @@ var IdbPouch = function(opts, callback) {
return newDoc;
});

var docInfoErrors = docInfos.filter(function(docInfo) {
return docInfo.error;
});
if (docInfoErrors.length) {
return call(callback, docInfoErrors[0]);
}

var results = [];
var docs = [];

Expand Down
8 changes: 8 additions & 0 deletions src/adapters/pouch.leveldb.js
Expand Up @@ -350,6 +350,14 @@ LevelPouch = module.exports = function(opts, callback) {
return newDoc;
});

var infoErrors = info.filter(function(doc) {
return doc.error;
});
if (infoErrors.length) {
return call(callback, infoErrors[0]);
}


// group multiple edits to the same document
info.forEach(function(info) {
if (info.error) {
Expand Down
7 changes: 7 additions & 0 deletions src/adapters/pouch.websql.js
Expand Up @@ -123,6 +123,13 @@ var webSqlPouch = function(opts, callback) {
return newDoc;
});

var docInfoErrors = docInfos.filter(function(docInfo) {
return docInfo.error;
});
if (docInfoErrors.length) {
return call(callback, docInfoErrors[0]);
}

var tx;
var results = [];
var docs = [];
Expand Down

0 comments on commit 97a1605

Please sign in to comment.