|
SERVER-19243 added the ability to use the syntax
db.coll.find({<field>: {$type: "number"}});
|
This will match all documents for which <field> is any of the numerical BSON types (NumberInt, NumberLong, NumberDouble):
> db.coll.drop()
|
> db.coll.insert({_id: 1, num: NumberInt('123')})
|
> db.coll.insert({_id: 2, num: NumberLong('123')})
|
|
> db.coll.find({num: {$type: "number"}})
|
{ "_id" : 1, "num" : 123 }
|
{ "_id" : 2, "num" : NumberLong(123) }
|
This should be added to the $type documentation here: http://docs.mongodb.org/manual/reference/operator/query/type/
|