品易云推流 关闭
文章详情页
文章 > MongoDB > mongodb数据之间的转换

mongodb数据之间的转换

头像

 Ly

2020-06-10 09:47:183548浏览 · 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);
});
关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图