mongdb 更新字段类型

//$type:1等于1表示是double类型  或者 type:"double"  

 

 

 

db.getCollection('HotLocation').find({"PlaceType":{$type:1}})
.forEach(
function(x)
{

//转换成int类型
x.PlaceType=NumberInt(x.PlaceType);
//修改数据类型
db.getCollection('HotLocation').update({"_id" : x._id},{$set:{"PlaceType" : x.PlaceType}})
})

//数据多  需要多次执行

posted @ 2021-05-21 09:54  枫岫  阅读(108)  评论(0编辑  收藏  举报