From 4250e25187454b0a46ccce282ffbe53821d45404 Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Wed, 16 Jan 2019 16:19:05 -0700 Subject: [PATCH] Squash a deprecation in our Code base (#1573) * Utilize this method for mongodb native... `async`/`await` with `hasNext()`/`next()` tested and can also work but part of ES6+ NOTE: * Code looks more uniform with this method e.g. always wondered why there wasn't a final `aCallback` Ref: * https://stackoverflow.com/questions/25507866/how-can-i-use-a-cursor-foreach-in-mongodb-using-node-js#answer-25508173 Applies to #1516 Auto-merge --- libs/modifySessions.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libs/modifySessions.js b/libs/modifySessions.js index 2016c68f5..ac065c2cb 100644 --- a/libs/modifySessions.js +++ b/libs/modifySessions.js @@ -294,17 +294,11 @@ exports.findSessionData = function (aQuery, aStore, aOptions, aCallback) { aOptions.sessionList = []; - aUserSessions.each(function (aErr, aSessionData) { + aUserSessions.forEach(function (aSessionData) { var data = null; var rQuery = null; - if (aErr) { - aCallback(aErr); - return; - } - if (!aSessionData) { - aCallback(); return; } @@ -340,6 +334,8 @@ exports.findSessionData = function (aQuery, aStore, aOptions, aCallback) { } + }, function (aErr) { + aCallback(aErr); // done or err }); }); }