Created
October 8, 2015 03:55
-
-
Save melissamarima/e8511e634d26f51aaed8 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
// models/Post.js mongoose schema for mongoDB | |
// I'd like this method to take in param1 and param2 | |
PostSchema.methods.thisMethod = function(cb) { | |
this.upvotes += 1; | |
this.save(cb); | |
}; | |
// Now we create the route in our index.js: | |
router.put('/posts/:post/upvote', function(req, res, next) { | |
var param1 = "hi"; | |
var param2 = 33; | |
req.post.upvote(function(err, post){ | |
if (err) { return next(err); } | |
res.json(post); | |
}); | |
}); | |
// source https://thinkster.io/mean-stack-tutorial#getting-user-input-enable-upvoting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function(param1, param2, cb){
...
}