mongodb如何修改字段类型
mongodb中修改字段类型的方法:在mongodb中使用“db.tb_name.find({"status":{$type:"double"}).count()”或“db.tb_name.find({"status":{$type:1}).count()”语法来修改字段类型,这个语句中的tb_name指的是数据表名、status指的是表中的字段名称、$type:后面则是需要修改的字段类型。
具体方法如下:
?字段类型判断语法
db.tb_name.find({"status":{$type:"double"}).count() //所有的status字段类型为Double类型的db.tb_name.find({"status":{$type:1}).count() //所有status字段类型为Double类型的
数据类型批量转换
(double转为int32):
db.tb_name.find({"status":{$type:1}}).forEach(function(x){x.status=NumberInt(x.status);db.tb_name.save(x)})
(string转为array):
db.log.find({"record":{$type:2}}).forEach(function(x){x.record=Array(x.record);db.log.save(x)})
上一篇:mongodb如何查表的数据
下一篇:mongodb如何删除数据
winlogins.exe是什么文件?winlogins.exe是不是病毒
winsock2.6.exe是什么文件?winsock2.6.exe是不是病毒
WinDefendor.dll是什么文件?WinDefendor.dll是不是病毒
系统目录是什么文件?系统目录是不是病毒
wholove.exe是什么文件?wholove.exe是不是病毒
winn.ini是什么文件?winn.ini是不是病毒
w6oou.dll是什么文件?w6oou.dll是不是病毒
winduxzawb.exe是什么文件?winduxzawb.exe是不是病毒
wuammgr32.exe是什么文件?wuammgr32.exe是不是病毒
windiws.exe是什么文件?windiws.exe是不是病毒