Browse Source

events by day implemented, todo: calendar view to select a day

master
arnaucode 7 years ago
parent
commit
3480b90a7a
2 changed files with 20 additions and 0 deletions
  1. +18
    -0
      controllers/eventController.js
  2. +2
    -0
      server.js

+ 18
- 0
controllers/eventController.js

@ -210,3 +210,21 @@ exports.getEventsByCategory = function(req, res) {
res.status(200).jsonp(events);
});
};
exports.getEventsByDay = function(req, res) {
var dayRequested= new Date(req.params.day);
eventModel.find({
date: {
$gte: dayRequested
}
})
.lean()
.populate('user', 'username img shortDescription')
.sort('date')
.limit(pageSize)
.skip(pageSize * Number(req.query.page))
.exec(function (err, events) {
if (err) return res.send(500, err.message);
res.status(200).jsonp(events);
});
};

+ 2
- 0
server.js

@ -67,6 +67,8 @@ apiRoutes.route('/events/following')
.post(eventCtrl.getEventsByFollowingArray);
apiRoutes.route('/events/category/:category')
.get(eventCtrl.getEventsByCategory);
apiRoutes.route('/events/day/:day')
.get(eventCtrl.getEventsByDay);
apiRoutes.route('/categoriesList')
.get(eventCtrl.getCategoriesList);

Loading…
Cancel
Save