0
{ 
   _id: 'abc123',
   reports: [ 
             { uid: 33, name: 'john' }, 
             { uid: 215, name: 'jess' },
             { uid: 29, name: 'hal'}
           ]
}

假设我有上面的文件。

models.Stuff.findOne({_id:'abc123'},function(err,result){
     //Got the above record.
});

拿到文件后,如何把所有的“uids”都改成0?我想浏览所有文档的报告并将所有 uid 更改为 0。

4

2 回答 2

1
for(i in result.reports){
    result.reports[i].uid = 0;
}
result.save();
于 2011-07-09T08:21:59.090 回答
0

最好使用pinch.min.js,这对于这种需求来说非常方便。

于 2013-01-08T07:49:45.697 回答