When I try to point { $set: { info.name: req.body.name }
an error throws.
SyntaxError: Unexpected token '.'.
How to do it properly?
Code:
app.put('/users/updateMyOwnInfo', ValidateCookies, (req, res) => {
db.collection('users').updateOne({ id: parseInt(req.cookies.userId) },
{ $set: { info.name: req.body.name } }, (err, doc) => {
if (err) {
console.log(err)
return res.status(500)
}
res.send(doc)
})
})