Signup/Sign In

Datatypes in MongoDB

It is known that the MongoDB stores the JSON data in a binary encoded format called BSON, where JSON data model actually extends the BSON in order to provide more flexibility with the additional data types and helps in easily encoding and decoding the data across various programming languages. By default, there is no support for the datatypes like date in JSON. But, BSON provides that feature.

MongoDB supports the below list of datatypes. Each datatype in MongoDB possess a unique number.

Double1Used to stored floating point values
String2Commonly used datatype and it is UTF-8 valid
Object3Used for storing embedded objects
Array4Used for storing embedded objects
Binary Data5Used to store binary data
Undefined6Used to store undefined value
Object Id7Used to store document's ID
Boolean9Used to store Boolean value
Date10Used to store current date time in UNIX format.
Null11Used to store null value
Regular Expression12Used to store regex
Javascript13Used to store JavaScript data without scope
Symbol14Basically used to store string, but reserved for languages that use specific symbol
Javascript with scope15Used to store JavaScript data with scope
Integer16 & 18Used to store numerical value
Timestamp10Used to track when a document is modified.
Min/Max Key255/127Used to compare value against lowest and highest BSON elements