MongoDB Data Types

MongoDB Data Types: In MongoDB, data is stored in BSON format, which is the binary encoded form of JSON. By using BSON format, remote procedure call (RPC) can be used in MongoDB. In MongoDB, each data type has two things.  First is the alias & second is the number which is used to search any particular record within its database. Nearly all the data types used in JavaScript can be used in MongoDB.

  • Integer: Data type used to store a numerical value. Both 32 & 64-bit integers are supported depending on the server. 
  • Boolean: This data type is used to store a Boolean i.e., either true or false values.
  • Double: It is used for storing floating-point data.
  • Min-Max keys: These keys are used for comparison of values against the lowest & the highest BSON elements.
  • Arrays: Arrays are stored by implementing an array of data types. Many other values can also be stored under a common single key.
  • Object: It is used for embedding documents.
  • String: It is the most common data type used to store data that must be UTF-8 valid.
  • Symbol: It is generally used for language having a specific type of symbol. It is identical to the string.
  • Null: It is used for storing a null value.
  • Date: Just like the unique time format, here date is used to store the current date & time.