There are 10000 docs import by mongoimport, the _id is 6 length random string
{_id:"xxxxxx","u":0,"t":0}
because mongoimport can not specifiy data type, so string like "123456" was imported as type int. So I manually delete originals and re-insert them as
db.xxx.insert({_id:"123456","u":0,"t":0})
Because the default type of 0 is Double, so I change them to int by:
db.xxx.update({},{$set:{u:NumberInt(0)}},false,true)
WriteResult({ "nMatched" : 100000, "nUpserted" : 0, "nModified" : 99994 })
Seems 6 docs change failed, I validate the change by:
> 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 }
the update only modify docs which was imported by mongoimport but leave alone docs which I manually insert, why?