0
删除引号我有一个MongoDB的集合与多条记录这样从MongoDB的领域
{
"_id" : "500cecd97f3b198ba7aceea3",
"startDate" : NumberLong("1343023785531"),
"user_id" : "soggettoDGcfe",
"app_source" : "Diary",
"measuredValue":120,
}
问题是由于应用程序的一个bug,有数以百计的记录与现场“measuredValue”作为字符串:
{
"_id" : "ab0cecd97f3176eba7aceea3",
"startDate" : NumberLong("1343023785531"),
"user_id" : "soggettoDGcfe",
"app_source" : "Diary",
"measuredValue":"76.0",
}
所以,当我尝试运行一些查询,以检查是否值大于更大的东西,不返回记录。随着查询我能够逐一纠正一些记录
db.OBSERVABLEPARAMETER.update({_id:"500cecd97f3b198ba7aceea3"},{$set:{measuredValue:76}});
但他们是数百! 如何快速更新所有人?
它的工作太多了:)是否有可能修改measuredValue仅适用于字段app_source:“Diary”的记录? – Mark
'db.OBSERVABLEPARAMETER.update({measuredValue:“76.0”,“app_source”:“Diary”},{$ set:{measuredValue:76.0}},{multi:true});'或'c.find({ measuredValue:{$ type:2},“app_source”:“Diary”})' – jimoleary
抱歉,我的意思是:forEach函数将measuredValue设置为数字,但我只需要为app_source字段等于“日记” – Mark