最新下载
热门教程
- 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);
});
相关文章
- 原神遐思套和断章套给谁用 原神4.6版本新圣遗物适用角色推荐 04-19
- 物华弥新战天月怎么打 物华弥新战天月打法攻略 04-19
- 梦幻西游怎么在藏宝阁卖东西 04-19
- 星际战甲前期干什么好 04-19
- 率土之滨灵帝怎么加点 04-19
- 原神妮露对单能力怎么样 04-19