Created
January 12, 2016 17:30
-
-
Save johanbrook/c332f43161b75726d02f to your computer and use it in GitHub Desktop.
Revisions
-
johanbrook created this gist
Jan 12, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ const updateNightclub = (req, res, next) => { const nightclubId = req.params.id; const {value} = req.body; console.log(nightclubId, value); Nightclubs.methods.updateVisitors.call({nightclubId, value}, (err, result) => { const response = { code: 200 }; if (err) { console.log(err) return JsonRoutes.sendResult(res, { data: {message: "There was an error"}, code: 500 }); } if (result === 1) { response.data = { message: "Success", nightclub: Nightclubs.findOne(nightclubId), value: 1 }; } else if (result === -1) { response.data = { message: "Success", nightclub: Nightclubs.findOne(nightclubId), value: -1 }; } else { response.code = 404; response.data = { message: "Did not find a nightclub with that ID", nightclubId: nightclubId, value: 0 }; } console.log(response); JsonRoutes.sendResult(res, response); }); }; JsonRoutes.add('put', 'nightclubs/:id', updateNightclub); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Nightclubs.methods.updateVisitors = new ValidatedMethod(/* ... */);