.updateOne on MongoDB not working in Node.js

后端 未结 8 1051
迷失自我
迷失自我 2021-01-03 20:07

I have the following code:

connection((db) => {
            db.collection(\'orders\')
                .updateOne(
                    { \"_id\": req.body         


        
8条回答
  •  孤独总比滥情好
    2021-01-03 20:30

    I had this trouble too, I create a constant with _id from req.body

    const {_id} = req.body  //pass ID user
    await User.updateOne({_id},{$set:data}, (err)=>{
                if(err) return res.status(200).json({
                    error: true,
                    code: 115,
                    message: "Erro to update user!"
                })
            })
    

提交回复
热议问题