1、int转换为string类型
<a href="https://www.gaodaima.com/tag/db" title="查看更多关于db的文章" target="_blank">db</a>.collectionName.find().forEach(function(x) { x.FieldName = x.FieldName.toString(); db.collectionName.save(x); });
www#gaodaima.com来源gaodai.ma#com搞##代!^码@网搞代码
2、string转换为Date类型
db.collectionName.find().forEach(function(x) { x.FieldName = new ISODate(x.FieldName ); db.collectionName.save(x); });
3、string转换为int类型
//string转为int类型 db.collections.find().forEach( function (x) { x.ise= NumberInt (x.ise); db.collections.save(x); });
来源:搞代码网:原文地址:https://www.gaodaima.com