Created
January 12, 2016 17:30
-
-
Save johanbrook/c332f43161b75726d02f to your computer and use it in GitHub Desktop.
This file contains 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 characters
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 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 characters
Nightclubs.methods.updateVisitors = new ValidatedMethod(/* ... */); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment