MongoDB Data Types

The last five datatypes (date, object id, binary data, regex, and JavaScript code) are non-JSON datatypes; specifically, they are special datatypes that BSON allows you to use. These are a bit unusual and I doubt i’ll ever need them,

String: This commonly used datatype contains a string of text (or any other kind of
characters). This datatype is used mostly for storing text values (e.g., “Country” :
“UK”}.

Integer (32b and 64b): This type is used to store a numerical value (e.g., { “Rank” :
1 } ). Note that the integer isn’t encapsulated by quotes

Boolean: This datatype can be set to either TRUE or FALSE.

Double: Used to store floating point values.

Min / Max keys: Used to compare a value against the lowest and highest BSON elements, respectively.

Arrays: This datatype is used to store arrays (e.g., [“MongoDB”, “CouchDB” ,”Cassandra”]).

Timestamp: Used to store a timestamp. This can be handy for recording when a document has been modified or added.

Object: This datatype is used for embedded documents.

Null: Used to store a Null value.

Symbol: This datatype is used identically to a string (see above); however, it’s
generally reserved for languages that use a specific symbol type.

Date *: This datatype is used to store the current date or time in UNIX time format

Object ID *: This datatype is used to store the document’s ID.

Binary data *: Used to store binary data.

Advertisements

One thought on “MongoDB Data Types

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s