mongodb update matched doc fail
问题 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 })