最新下载
热门教程
- 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重制版深蔑空洞藏身处怎么解锁 07-02
- DEXTF Protocol(DEXTF币)要挖多久 07-02
- XRP占领韩国顶级交易所 07-02
- 光与影33号远征队振奋击破获取方法 07-02
- 龙石战争西奥多技能属性及搭配推荐 07-02
- 新三国志曹操传过关斩将任务攻略 07-02