Datatypes in MongoDB
Many datatypes support MongoDB. Some of them are -
- String-This is the most frequently used data type to store data. In MongoDB, a string must be UTF-8 valid.
- Integer −To store a numerical value, this type is used. Depending on your server, Integer can be 32 or 64 bit.
- Boolean −A boolean (true / false) value is stored with this type.
- Double- To store floating point values, this type is used.
- Min/ Max keys -This type is used to measure a value against the lowest and highest BSON elements with Min/ Max keys.
- Arrays- This type is used to store a single key for arrays or arrays or multiple values.
- Timestamp − Timestamp. When a document has been modified or added, this can be useful for recording.
- Object −For embedded documents, this data type is used.
- Null −This type is used to store the value of null.
- Symbol −This data type is used in the same way as a string; however, it is normally reserved for languages that use a specific type of symbol.
- Date −This data type is used in the UNIX time format to store the current date or time. By creating a date object and passing the day, month, year into it, you can define your own date time.
- Object ID − This datatype is used to save the ID of a document.
- Binary data:-This type of data is used for storing binary data.
- Code:-This data type is used to store the document's JavaScript code.
- Regular expression:-This data type is used for regular expression storage.