How to change the type of a field?

后端 未结 13 2040
北荒
北荒 2020-11-22 15:10

I am trying to change the type of a field from within the mongo shell.

I am doing this...

db.meta.update(
  {\'fields.properties.default\': { $type :         


        
13条回答
  •  隐瞒了意图╮
    2020-11-22 15:14

    db.coll.find().forEach(function(data) {
        db.coll.update({_id:data._id},{$set:{myfield:parseInt(data.myfield)}});
    })
    

提交回复
热议问题