Improved inline edit feature

This commit is contained in:
Luke Vella 2015-01-12 16:18:18 +01:00
parent 10c035e359
commit 0eeb4866f4
10 changed files with 65 additions and 21 deletions

View file

@ -13,7 +13,7 @@ exports.create = function(req, res){
exports.show = function(req, res, next){
Event.findById(req.params.id, function(err, event){
if (err) return handleError(res, err);
if (!event) return res.status(404);
if (!event) return res.status(404).end();
return res.json(event);
});
}
@ -39,6 +39,23 @@ exports.createParticipant = function(req, res, next){
});
}
exports.updateParticipant = function(req, res, next){
var eventId = req.params.id;
var participantId = req.params.pid;
Event.update({
'_id' : eventId,
'participants._id': participantId
}, {
'$set': {
'updated' : Date.now(),
'participants.$' : req.body
}
}, function(err, num){
if (err) return next(err);
res.status(204).end();
});
}
exports.deleteParticipant = function(req, res, next){
var eventId = req.params.id;
var participantId = req.params.pid;