Database Reference
In-Depth Information
Matching Results Based on the BSON Type
The $type operator lets you match results based on their BSON type. For instance, the following snippet lets you find
all items that have a track list of the type Embedded Object (that is, it contains a list of information):
> db.media.find ( { Tracklist: { $type : 3 } } )
{ "_id" : ObjectId("4c1a86bb2955000000004076"), "Type" : "CD", "Artist" :
"Nirvana", "Title" : "Nevermind", "Tracklist" : [
{
"Track" : "1",
"Title" : "Smells Like Teen Spirit",
"Lenght" : "5:02"
},
{
"Track" : "2",
"Title" : "In Bloom",
"Length" : "4:15"
}
] }
The known data types are defined in Table 4-1 .
Table 4-1. Known BSON Types and Codes
Code
Data Type
-1
MiniKey
1
Double
2
Character string (UTF8)
3
Embedded object
4
Embedded array
5
Binary Data
7
Object ID
8
Boolean type
9
Date type
10
Null type
11
Regular Expression
13
JavaScript Code
14
Symbol
15
JavaScript Code with scope
16
32-bit integer
17
Timestamp
18
64-bit integer
127
MaxKey
255
MinKey
 
Search WWH ::




Custom Search