Mongodb Mongo-更新对象中的所有字段

Mongodb Mongo-更新对象中的所有字段,mongodb,Mongodb,我有一个像这样的mongo场: answers = [ { "answer" : "Test", "votes" : 1 }, { "answer" : "Blaat", "votes" : 0 }, { "answer" : "Bliep", "votes" : 0 } ] 现在我想将所有“投票”字段设置为0,如何实现这一点? 我试过这个: $set: { 'answers.votes': 0 } 它不会给出错误,但不

我有一个像这样的mongo场:

answers = [
  {
    "answer" : "Test",
    "votes" : 1
  },
  {
    "answer" : "Blaat",
    "votes" : 0
  },
  {
    "answer" : "Bliep",
    "votes" : 0
  }
]
现在我想将所有“投票”字段设置为0,如何实现这一点? 我试过这个:

$set: { 'answers.votes': 0 }
它不会给出错误,但不会更改字段

有什么想法吗


谢谢

或者这一个:你的问题的答案在我链接的副本中,所以请先阅读并尝试。