dbs-and-docs-test-bulkAddDriver
module.exports = bulkAddDriverTest
/*
[{
"ok": true,
"id": "100",
"rev": "1-5190881ca746eca2ce205be647a4f87f"
}, {
"ok": true,
"id": "200",
"rev": "1-eb2b4d10bd0c17043509e8b7faeaa180"
}, {
"ok": true,
"id": "300",
"rev": "1-cf1c5d4190efc543698efa71eddb5b6e"
}, {
"ok": true,
"id": "400",
"rev": "1-5ed61ab3bd832d566f2ac4bf88f43870"
}, {
"ok": true,
"id": "500",
"rev": "1-7accb86cf6c167dc71e89f75e3a2ea25"
}]
*/
//{ ok: true, index: 2, id: '300' }
function findProblemRecords(record) {
return record.ok === false;
}
console.log(res.find(findProblemRecords)); // { name: 'cherries', quantity: 5 }
function bulkAddDriverTest(a, b) {
return function (err, res) {
// what a and b are without having to have a global
console.log("Any problem records? ");
// console.log("Is there an error?: " + JSON.stringify(err));
// console.log("Is there a response ?: " + JSON.stringify(res));
console.log(res.find(findProblemRecords));
console.log("res[b.index].id === b.id " + res[b.index].id === b.id);
console.log("third item id!: " + res[b.index].id);
if (err === a &&
res.ok === b.ok &&
res[b.index].id === b.id) {
console.log('response: ' + JSON.stringify(res))
console.log('success! Done.')
} else if (err === a &&
res.ok === b.ok &&
res.id !== b.id) {
console.log('Problem! Your document\'s _id does not equal ' + b.id)
}
else {
console.log('error! ' + JSON.stringify(err))
}
}
}
no comments