即使设置了它,也会遇到$ set错误?

时间:2019-05-08 21:21:35

标签: mongodb

print(hdf.T.reset_index().set_axis(range(hdf.shape[0]+1), axis=1, inplace=False).to_json(orient='records'))

有人看到我为什么要出错吗?它说:

chats.post('/approveUser', (req, res) => {
  // let regex = new RegExp(req.body.requestId)
  Chat.updateOne(
    { 'requests._id': req.body.requestId },
    { $set: {'approved': true} },
    { upsert: true }
  )
    .then(res => {
      console.log('hi')
      if (!res) {
        res.status(404).send()
      } else {
        res.status(200).send(res)
      }
    })
    .catch(err => {
      console.log(err)
      res.status(500).send(err)
    })
})

req.body.requestId不是未定义的。这是每个mongoDB文档的布局:

errmsg: '\'$set\' is empty. You must specify a field like so: {$set: {<field>: ...}}'

目的是将任何{ "_id":"5cd1f4aceb05c12298779345", "title":"test 3", "participants":[ { "_id":"5cd1f4aceb05c12298779347", "userEmail":"test@gmail.com" }, { "_id":"5cd1f4aceb05c12298779346", "userEmail":"adam2.cole@northumbria.ac.uk" }], "chatType":"publicGroup", "messages":[ { "_id":"5cd254b591a0eb1de4a0863c", "text":"hi", "from":"test@gmail.com", "dateTimeSent":"2019-05-08T04:01:57.732Z" }, { "_id":"5cd254b591a0eb1de4a0863b", "text":"hi", "from":"test@gmail.com", "dateTimeSent":"2019-05-08T04:01:57.764Z" } ], "__v":0, "requests":[ { "approved":false, "_id":"5cd2467891a0eb1de4a08631", "userEmail":"test2@gmail.com" } ] } 中的approved设置为true。我看不到为什么它不起作用。还有其他人知道为什么吗?

谢谢。

0 个答案:

没有答案