mongodb数据之间的转换
Ly
2020-06-10 09:47:185123浏览 · 0收藏 · 0评论

1、int转换为string类型
db.collectionName.find().forEach(function(x) {
x.FieldName = x.FieldName.toString();
db.collectionName.save(x);
});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);
});
关注公众号,随时随地在线学习