'can't set object property in put request search
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)
})
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|