是否存在某值
db.data.aggregate([
{'$match' : {
"dms_source_id" : "xxxxx"
}
},
{
'$project': {
'_id': 0,
'dms_value.regions': 1
},
},
{
'$unwind': '$dms_value.regions'
},
{
'$match' : {
"dms_value.regions.result" : {$exist: true},
"dms_value.regions.ml_result" : {$exist: true}
}
}
])
循环更新
db.source.find({dms_key: {$regex:/53/i}}).forEach(function(it) {
it.init_dms_value = it.dms_value;
it.trust_rate = 0;
db.source.save({it});
});