当前位置:首页 > 云计算 > 正文内容

mongodb数据之间的转换

2022-05-04 03:29:22云计算3

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=newISODate(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.xibujisuan.cn/18072.html

标签: Python