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

Allow $type to support type values as string names

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.1.6
    • Affects Version/s: 3.1.3
    • Component/s: Querying
    • Fully Compatible
    • Quint Iteration 6

      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) }
      

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

              Created:
              Updated:
              Resolved: