English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

MongoDB Data Types

MongoDB supports many data types. Some of them are:

  • String − This is the most commonly used data type for storing data. Strings in MongoDB must be UTF-8valid.

  • Integer − This type is used to store numeric values. Integers can be32bit or 64bits, depending on your server.

  • Boolean − This type is used to store boolean (true / false) value.

  • Double − This type is used to store floating-point values.

  • Min/ Max keys This type is used to compare values with the lowest and highest BSON elements.

  • Arrays − This type is used to store an array or list or multiple values in a single key.

  • Timestamp− ctimestamp (timestamp). This can be conveniently recorded when the document is modified or added.

  • Object − This data type is used for embedded documents.

  • Null − This type is used to store Null values.

  • Symbol− This data type is the same as string; however, it is usually reserved for languages that use specific symbol types.

  • Date − This data type is used to store the current date or time in UNIX time format. You can specify your own date and time by creating a Date object and passing the date, month, and year to it.

  • Object ID − This data type is used to store the document's ID.

  • Binary data − This data type is used to store binary data.

  • Code − This data type is used to store JavaScript code in documents.

  • Regular expression − This data type is used to store regular expressions.