These are the usable Mongodb Data Types. The "Type Number" can be used together with your MongoDb queries utilizing the conditional operator: '$type'. Whereas, the "Type Name" is a non-terminal data type (as is) as specified in the BSON specifications.
Type Name | Type Number | ||
---|---|---|---|
Double | 1 | ||
String | 2 | ||
Object | 3 | ||
Array | 4 | ||
Binary data | 5 | ||
Object id | 7 | ||
Boolean | 8 | ||
Date | 9 | ||
Null | 10 | ||
Regular expression | 11 | ||
JavaScript code | 13 | ||
Symbol | 14 | ||
JavaScript code with scope | 15 | ||
32-bit integer | 16 | ||
Timestamp | 17 | ||
64-bit integer | 18 | ||
Min key | 255 | ||
Max key | 127 |
Sample usage:
db.things.find( { a : { $type : 2 } } ); // matches if a is a string db.things.find( { a : { $type : 16 } } ); // matches if a is an intMore Information on MongoDb Data Types
No comments:
Post a Comment