From 5d83544e1c3d47fd464d7c01203ae779dc49ce7f Mon Sep 17 00:00:00 2001 From: zeus Date: Fri, 11 Dec 2020 02:05:47 +0200 Subject: [PATCH] add rest --- swarmlab-app/src/run/app.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index 05bd68b..e7de5e7 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -395,12 +395,17 @@ cors(corsOptions), (req, res, next) => { console.log(JSON.stringify('mongo connected')) var datestart = DateTime.fromObject(RES.start).toISODate() var dateend = DateTime.fromObject(RES.end).toISODate() - var search_term = { $and: [ { date: { $gt: datestart } }, { date: { $lt: dateend } } ] }; - + if(datestart && dateend){ + var search_term = { $and: [ { date: { $gt: datestart } }, { date: { $lt: dateend } } ] }; + }else if(datestart){ + var search_term = { $and: [ { date: { $gt: datestart } } ] }; + }else if(dateend){ + var search_term = { $and: [ { date: { $lt: dateend } } ] }; + } var resdataarray = [] var resraw = {} var reslab = '' - db.collection('logs').find({}, {}).toArray() + db.collection('logs').find(search_term, {}).toArray() .then(item => { for (let i in item) { reslab = item[i].tailed_path