MongoDB bulk get fix.

Ylian Saint-Hilaire committed Jan 10, 2021 at 14:41 UTC cb8fc7d150a06cbbbc52d64866be9e1abba7f7b0
2 files changed +3 -3
db.js
+1 -1
@@ -1479,7 +1479,7 @@ module.exports.CreateDB = function (parent, func) {
1479 }
1480
1481 // If there are not results, send out a null callback
1482 - for (var i in obj.filePendingGets) { for (var j in obj.filePendingGets[i]) { obj.filePendingGets[i][j](err, null); } }
1482 + for (var i in obj.filePendingGets) { for (var j in obj.filePendingGets[i]) { obj.filePendingGets[i][j](err, []); } }
1483
1484 // Move on to process any more pending get operations
1485 obj.filePendingGets = obj.filePendingGet;
meshagent.js
+2 -2
@@ -1205,7 +1205,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1205 if (command.oldnodeid.length != 64) break;
1206 const oldNodeKey = 'node//' + command.oldnodeid.toLowerCase();
1207 db.Get(oldNodeKey, function (err, nodes) {
1208 - if ((nodes != null) && (nodes.length != 1)) return;
1208 + if ((nodes == null) || (nodes.length != 1)) return;
1209 const node = nodes[0];
1210 if (node.meshid == obj.dbMeshKey) {
1211 // Update the device name & host
@@ -1283,7 +1283,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1283 if ((obj.agentInfo.capabilities & 0x40) != 0) {
1284 // Return nodeid of main agent + connection status
1285 db.Get('da' + obj.dbNodeKey, function (err, nodes) {
1286 - if (nodes.length == 1) {
1286 + if ((nodes != null) && (nodes.length == 1)) {
1287 obj.realNodeKey = nodes[0].raid;
1288
1289 // Get agent connection state