db.test.find({'score':{$type:2}}).forEach(function(x){
x.score=parseFloat(x.score);
db.test.save(x);
})
$type:2 为字符串
test 为collection名
score 为要修改的field名
parseFloat 是js中将字符串转换成浮点数,在mongodb中就对应为Double
db.test.find({'score':{$type:2}}).forEach(function(x){
x.score=parseFloat(x.score);
db.test.save(x);
})
$type:2 为字符串
test 为collection名
score 为要修改的field名
parseFloat 是js中将字符串转换成浮点数,在mongodb中就对应为Double
转载于:https://www.cnblogs.com/ssstudyUp/p/6322144.html