From 8a400d2996afc8435c848138648635817a905cce Mon Sep 17 00:00:00 2001 From: idoctnef Date: Sat, 8 Oct 2016 12:38:36 +0200 Subject: [PATCH] only future travels bug fixed --- controllers/travelController.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/travelController.js b/controllers/travelController.js index 796c988..f691b6b 100644 --- a/controllers/travelController.js +++ b/controllers/travelController.js @@ -72,7 +72,7 @@ exports.addTravel = function(req, res) { travel.save(function(err, travel) { if(err) return res.send(500, err.message); //res.status(200).jsonp(travel); - travelModel.find(function(err, travels) { + travelModel.find({date: {$gte: new Date()}}, function(err, travels) { if(err) res.send(500, err.message); res.status(200).jsonp(travels); @@ -105,7 +105,7 @@ exports.deleteTravel = function(req, res) { travel.remove(function(err) { if(err) return res.send(500, err.message); - travelModel.find(function(err, travels) { + travelModel.find({date: {$gte: new Date()}}, function(err, travels) { if(err) res.send(500, err.message); res.status(200).jsonp(travels); }); @@ -129,7 +129,7 @@ exports.addJoin = function(req, res) { travel.save(function(err, travel) { if(err) return res.send(500, err.message); //res.status(200).jsonp(travel); - travelModel.find(function(err, travels) { + travelModel.find({date: {$gte: new Date()}}, function(err, travels) { if(err) res.send(500, err.message); res.status(200).jsonp(travels); }); @@ -151,7 +151,7 @@ exports.doUnjoin = function(req, res) { travel.save(function(err, travel) { if(err) return res.send(500, err.message); //res.status(200).jsonp(travel); - travelModel.find(function(err, travels) { + travelModel.find({date: {$gte: new Date()}}, function(err, travels) { if(err) res.send(500, err.message); res.status(200).jsonp(travels); }); @@ -206,7 +206,7 @@ exports.addComment = function(req, res) { travel.save(function(err, travel) { if(err) return res.send(500, err.message); //res.status(200).jsonp(travel); - travelModel.find(function(err, travels) { + travelModel.find({date: {$gte: new Date()}}, function(err, travels) { if(err) res.send(500, err.message); res.status(200).jsonp(travels); });