我正在尝试使用mongodb将一个对象推入一个数组,但是无法让它工作。难道我做错了什么?非常感谢任何帮助。
app.post('/api/savedJobs', (req, res) => {
const job = req.body.data
User.findOneAndUpdate({
_id: req.user._id
}, { $push: { savedJobs: job } }
)
.then((res, err) => err ? console.log(err) : console.log('done'))
res.json(req.body.data)
})
这是我的架构的外观
const userSchema = new Schema({
googleId: String,
name: String,
email: String,
image: String,
interests: String,
activeProjects: String,
city: String,
country: String,
about: String,
skills: String,
savedJobs: Array,
timestamp: ''
})