Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

关于mongodb更新数组里的所有对象内容问题。。。。

$
0
0

###文档如下:

{
    name: 4,
    list: [{
        id: "a",
        date: 1504195200000,
        other: "c"
    },{
        id: "b",
        date: 1504195200000,
        other: "c"
    }]
}

如何把list数组下的元素里的other全部一次性更新呢? 尝试了以下方法:不行…

db.getCollection('test').update({'name': 4}, {$set: {'list.$.other': 'a'}}, {multi: true})

不知道为什么?求大神的解决方法,谢谢


Viewing all articles
Browse latest Browse all 14821

Trending Articles