【发布时间】:2014-02-03 08:53:28
【问题描述】:
我在变量结果中有一个类似于[{_id:64,minitem:30},{},{}...] 的 JSON 数组对象。这是聚合操作的结果,它是最低分数的投影。我需要遍历这个结果并从 DB 中删除 minvales。
我无法遍历结果对象.. 我试过了
for(i=0; i<result.length; i++){
db.students.update({
'_id': result['_id']
}, {
'$pull': { 'scores': { 'score': result[i]['minitem'] } }
})
}
这似乎没有效果。 DB 不变。我正在从mongo shell 尝试这个。
【问题讨论】:
标签: mongodb mongo-shell