operator_log为集合名,operation_type为字段名
{$type:2}代表type是2的,即字符串,查询所有字符串的forEach,并复制,保存
db.operator_log.find({"operation_type":{$type:2}}).forEach(function(x)
{
x.operation_type=NumberInt(x.operation_type);
db.operator_log.save(x);
}
)
db.operator_log.find({"operation_type":{$exists:true}}).forEach(function(x){
x.operation_type=x.operation_type+""; // 用new string(x.operation_type)就变成了文档,不知道为什么
db.operator_log.save(x);
});