[SERVER-18819] Allow $type to support type values as string names Created: 04/Jun/15  Updated: 05/Feb/16  Resolved: 02/Jul/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.1.3
Fix Version/s: 3.1.6

Type: Improvement Priority: Minor - P4
Reporter: Daniel Coupal Assignee: Qingyang Chen
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-19243 Allow $type to support "number" as ty... Closed
Documented
is documented by DOCS-5882 Document string aliases for $type Closed
Related
related to SERVER-20345 Support additional queries with $type... Backlog
Backwards Compatibility: Fully Compatible
Sprint: Quint Iteration 6
Participants:

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



 Comments   
Comment by Githook User [ 02/Jul/15 ]

Author:

{u'username': u'coollog', u'name': u'Qingyang Chen', u'email': u'qingyang.chen@10gen.com'}

Message: SERVER-18819 allow $type to support type values as string names
Branch: master
https://github.com/mongodb/mongo/commit/cad7211943ccc80f8614b010a7f6137eebba04bc

Comment by Qingyang Chen [ 02/Jul/15 ]

mcipatching

Generated at Thu Feb 08 03:48:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.