Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melissamarima/e8511e634d26f51aaed8 to your computer and use it in GitHub Desktop.
Save melissamarima/e8511e634d26f51aaed8 to your computer and use it in GitHub Desktop.
// 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
@melissamarima
Copy link
Author

function(param1, param2, cb){
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment