Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-18819

Allow $type to support type values as string names

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 3.1.3
    • 3.1.6
    • Querying
    • Fully Compatible
    • Quint Iteration 6

    Description

      The $type query operator should accept the following string aliases:

      Double (1) - "double"
      String (2) - "string"
      Object (3) - "object"
      Array (4) - "array"
      Binary data (5) - "binData"
      Undefined (6) - "undefined"
      Object id (7) - "objectId"
      Boolean (8) - "bool"
      Date (9) - "date"
      Null (10) - "null"
      Regular Expression (11) - "regex"
      DBPointer (12) - "dbPointer"
      JavaScript (13) - "javascript"
      Symbol (14) - "symbol"
      JavaScript (with scope) (15) - "javascriptWithScope"
      32-bit integer (16) - "int"
      Timestamp (17) - "timestamp"
      64-bit integer (18) - "long"
      Min key (255) - "minKey"
      Max key (127) - "maxKey"

      Example:

      > db.coll.drop()
      > db.coll.insert({_id: 1, num: NumberInt('123')})
      > db.coll.insert({_id: 2, num: NumberLong('123')})
       
      > db.coll.find({num: {$type: "int"}})
      { "_id" : 1, "num" : 123 }
      > db.coll.find({num: {$type: "long"}})
      { "_id" : 2, "num" : NumberLong(123) }
      

      Attachments

        Issue Links

          Activity

            People

              qingyang.chen Qingyang Chen
              daniel.coupal@mongodb.com Daniel Coupal
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: