threetwo:PRIMARY> db.version()
|
3.2.0
|
|
// Insert a document where x is a Double
|
threetwo:PRIMARY> db.foo.insert({x: 1})
|
WriteResult({ "nInserted" : 1 })
|
|
// Verify it's a Double
|
threetwo:PRIMARY> db.foo.find({x: {$type:1}})
|
{ "_id" : ObjectId("56829f8f891b45519f22028c"), "x" : 1 }
|
|
// Update to NumberInt
|
threetwo:PRIMARY> db.foo.update({ "_id" : ObjectId("56829f8f891b45519f22028c")},{$set: {x: NumberInt(1)}})
|
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
|
|
// Note nModified of 0, and field is still Double
|
threetwo:PRIMARY> db.foo.find({x: {$type:1}})
|
{ "_id" : ObjectId("56829f8f891b45519f22028c"), "x" : 1 }
|