Data types in MongoDB determine the type of data that can be placed in each document field. MongoDB offers a wide range of data types, each of which is best suited to distinct types of data.
A data type for storing textual data in MongoDB. Strings are UTF-8 encoded and are widely used to store many types of data such as names, descriptions, and other textual information.
MongoDB can store 32-bit or 64-bit signed integers. These are frequently used to store numerical data such as ages, numbers, and other whole-number values.
In MongoDB, the data type Double is used to hold floating-point numbers. It is used to represent decimal numbers or numbers with fractional portions, offering greater precision than integers.
In MongoDB, a Boolean is a data type that represents true or false values. Booleans are frequently used to store binary data, such as expressing the state of a condition or whether a specific event occurred.
In MongoDB, null is a data type that represents the absence of any value. It is typically used to indicate that a field has not yet been assigned a value or that the value is deliberately missing.
An array is an ordered collection of values in MongoDB that is stored as a single field. Arrays can hold items of numerous data kinds, including lists, sets, and other structured data.
In MongoDB, the object data type, also known as nested documents, enables for the storage of complicated data structures within one field. Objects can include key-value pairs, arrays, or other nested objects, which allows for the representation of hierarchical data.
MongoDB automatically generates a unique identifier for each document in a collection. ObjectIds are 12-byte values that include a timestamp, a machine identification, a process identifier, and a counter to ensure uniqueness among documents.
A data type in MongoDB that represents undefined values. It shows that a field was declared but not assigned a value.
MongoDB can store binary data such as photos, files, and other raw binary data. Binary data fields can store a variety of binary data, such as blobs or binary-encoded files.
A data type that stores date and time information in MongoDB. Dates are expressed as 64-bit integers, which typically indicate the number of milliseconds since the Unix epoch.
MongoDB internal data types are used to compare data. The min key represents the lowest possible value, and the max key represents the greatest possible value, enabling for range searches.
A data type comparable to strings but not often supported by MongoDB shell. When symbols are obtained from a database, they are transformed into strings.
MongoDB's data type for storing regular expressions. Regular expressions are patterns used to match strings, allowing for more advanced search and manipulation of text data.
A data type for storing JavaScript code in MongoDB documents. JavaScript code can be performed in the MongoDB environment, allowing for dynamic data processing and modification.
This data type, which was deprecated in MongoDB 4.4, allows for the storage of JavaScript code and its scope in MongoDB documents, providing more extensive data processing capabilities.
A data type in MongoDB for storing timestamps. Timestamps indicate a specific point in time and are important for determining when documents are created or modified.
Introduced in MongoDB version 3.4, this data type contains 128-bit decimal-based floating-point values with more precision than double. It is excellent for financial and scientific applications that require precise decimal representations.