dbs-and-docs-test-bulkAddDriver

node v4.9.1
version: 17.0.0
endpointsharetweet
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; } 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)===undefined); console.log("res[b.index].id === b.id " + res[b.index].id === b.id); console.log("third item id!: " + res[b.index].id); var ProblemRecords = res.find(findProblemRecords); if (err === a && ProblemRecords === undefined && res[b.index].id === b.id) { console.log('Success! Done.') console.log('response: ' + JSON.stringify(res)); } else if (err === a && ProblemRecords !== undefined) { console.log('Problem! At least one of your documents didn\'t save.: '); console.log(JSON.stringify(res)); } else if (err === a && ProblemRecords === undefined && res[b.index].id !== b.id) { console.log('All documents saved but we found as issue.') console.log('The third docment\'s id does not equal "300".'); } else { console.log('error! ' + JSON.stringify(err)); } }; }
Loading…

no comments

    sign in to comment