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);
});