在mongocollection的子阵列中更新字段

时间:2014-12-18 15:39:00

标签: mongodb meteor

我有以下数据结构:

{
  answers: [
    {
      text: 'text',
      owner: 'owner',
      timestamp: timestamp,
      comments: [
        {
          text: 'text',
          timestamp: timestamp,
          owner: 'owner'
        }
      ]
    }       
  ]
}

这是我的update-command:

return Questions.update({
        _id: id,
        'answers.timestamp': answerTimestamp,
        'answers.comments.timestamp': commentTimestamp,
        'answers.comments.owner': this.userId
      }, {
        $set: {
          'answers.$.comments.$.text': text
        }
      }); 

......这是错误:

Cannot apply the positional operator without a corresponding query field containing an array.

代码在服务器端运行!有人可以帮忙吗?

0 个答案:

没有答案