From cdeff6c85de57e0afe89ab2f4d19abfbb84f264e Mon Sep 17 00:00:00 2001 From: Birm Date: Fri, 3 May 2024 14:37:54 -0400 Subject: [PATCH] try another syntax? --- handlers/dataHandlers.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/handlers/dataHandlers.js b/handlers/dataHandlers.js index d89b280..09dd129 100644 --- a/handlers/dataHandlers.js +++ b/handlers/dataHandlers.js @@ -352,13 +352,20 @@ Mark.pointList = function(req, res, next) { var query = req.query; delete query.token; var points = []; - - mongoDB.find("camic", 'mark', query, { x: 1, y: 1, _id: 0 }).forEach((doc) => { - points.push([doc.x, doc.y]); - }).then(() => { - req.data = { points: points }; - next(); - }).catch((e) => next(e)); + + var cursor = mongoDB.find("camic", 'mark', query, { x: 1, y: 1, _id: 0 }); + + cursor.each((err, doc) => { + if (err) { + return next(err); + } + if (doc) { + points.push([doc.x, doc.y]); + } else { + req.data = { points: points }; + next(); + } + }); };