最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mongo修改字段类型(string to int)的教程
时间:2022-06-29 10:33:36 编辑:袖梨 来源:一聚教程网
mongo可以通过find(...).forEach(function(x) {})语法来修改collection的field类型。
假设collection为foo,field为bad:
转换为int类型:
db.foo.find({bad: {$exists: true}}).forEach(function(obj) {
obj.user_id = new NumberInt(obj.user_id);
db.foo.save(obj);
});
同理转换为string类型:
db.foo.find( { bad : { $exist : true } } ).forEach( function (x) {
x.bad = new String(x.bad); // convert field to string
db.foo.save(x);
});
相关文章
- 诛仙2怎么钓鱼 钓鱼方法教程 08-28
- 远光84麦琪怎么样 麦琪角色介绍 08-28
- 诛仙2画质怎么调最清晰 画质设置攻略 08-28
- 远光84侦查英雄有哪些 侦查英雄介绍 08-28
- 远光84最稳灵敏度怎么调 灵敏度调试攻略 08-28
- 伊瑟兑换码最新 伊瑟可用兑换码及输入位置 08-28