Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-5883

Document "number" alias for $type

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • None
    • Server
    • None

    Description

      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/

      Attachments

        Activity

          People

            ravind.kumar Ravind Kumar (Inactive)
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              8 years, 11 weeks ago