mongoimport 导入 10000 个文档,_id 为 6 长随机字符串
{_id:"xxxxxx","u":0,"t":0}
因为 mongoimport 不能指定数据类型,所以像“123456”这样的字符串被导入为 int 类型。所以我手动删除原件并将它们重新插入为
db.xxx.insert({_id:"123456","u":0,"t":0})
因为0的默认类型是Double,所以我把它们改成int:
db.xxx.update({},{$set:{u:NumberInt(0)}},false,true)
WriteResult({ "nMatched" : 100000, "nUpserted" : 0, "nModified" : 99994 })
似乎 6 文档更改失败,我通过以下方式验证更改:
> db.code.find({u:{$type:1}})
{ "_id" : "263798", "t" : 4, "u" : 0 }
{ "_id" : "375249", "t" : 7, "u" : 0 }
{ "_id" : "659472", "t" : 3, "u" : 0 }
{ "_id" : "672534", "t" : 3, "u" : 0 }
{ "_id" : "784392", "t" : 0, "u" : 0 }
{ "_id" : "875631", "t" : 0, "u" : 0 }
更新仅修改由 mongoimport 导入的文档,但不保留我手动插入的文档,为什么?