Answers for "mongoose save with data from req.body"

0

mongoose save with data from req.body

_ = require("underscore")
var model = new Example(_.extend({ userId: req.user._id }, req.body))

or if you want to copy userId into req.body:

_ = require("underscore")
var model = new Example(_.extend(req.body, { userId: req.user._id }))
Posted by: Guest on November-09-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language