MongoDB supports a variety of data types, including numeric types (Double, Int, Long, Decimal128), string types (String, ObjectId), Boolean types (Bool), date and time types (Date, Timestamp) , binary types (Binary), other types (Null, Array, Object), and extended JSON data types (Regex, JavaScript, Symbol).
MongoDB data types
MongoDB is a document database that supports rich data types, to store data of various formats and properties. These types include:
Numeric types:
-
Double: 64-bit floating point number used to store decimals and very large numbers .
-
Int: 32-bit signed integer used to store integers.
-
Long: A 64-bit signed integer used to store very large integers.
-
Decimal128: A 128-bit decimal floating point number used to store precise decimals.
String type:
-
String: UTF-8 encoded Unicode string used to store text and symbol.
-
ObjectId: A 12-byte unique identifier that uniquely identifies the document.
Boolean type:
-
Bool: Boolean value, used to represent true or false.
Date and time types:
-
Date: Representation of date and time in milliseconds since the epoch (UNIX epoch ) since storage.
-
Timestamp: A 64-bit date and timestamp, where the first 32 bits are seconds and the last 32 bits are nanoseconds.
Binary type:
-
Binary: Arbitrary sequence of bytes, used to store images, files, and binary data.
Other types:
-
Null: Indicates that the value does not exist.
-
Array: An ordered collection of elements. The elements can be of any data type.
-
Object: A set of key-value pairs, where the key is a string and the value can be any data type.
Extended JSON Data Types:
-
Regex: Regular expression, used for Match text pattern.
-
JavaScript: A special type that can store and execute JavaScript code.
-
Symbol: Similar to string, but with stricter syntax rules.
The above is the detailed content of What are the data types of mongodb. For more information, please follow other related articles on the PHP Chinese website!