📜  mongoose 使用 req.body 中的数据保存 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:44.952000             🧑  作者: Mango

代码示例1
_ = 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 }))