Previous words
This article will detail the data types and $type operators of the MongoDB database
Data type
MongoDB supports the following data types
Type Number Memo double1 double-precision floating-point number-This type is used to store floating-point values string2 string-This is the most common data type used to store data. The string in MongoDB must be UTF-8Object3 Objects-This data type is used for embedded document array4 Arrays-This type is used to store an array or list or multiple values into a single key binary data52 Binary Data-This data type is used to store binary data undefined6Deprecated Object ID7 Object ID-This data type is used to store the document's Idboolean8 Boolean Type-this type is used to store a Boolean value (true/false) Value Date9th Period-This data type is used to store the current date or time in Unix time format. You can specify the date time that you want by creating a Date object and specifying the date of day, month, and year nullTen Null-This type is used to store null values regular11 Regular Expressions-This data type is used to store regular expression JavaScript13 Code-This data type is used to store JavaScript code in the document symbol14 Symbols-The data type is the same as the string, but it is usually reserved for language JavaScript that uses a particular symbol type ( withSCOPE) 15 code-This data type is used to store the scoped JavaScript code in the document32-bit Integer 16 32-bit integer-This type is used to store numeric timestamp17 Time Stamp-easy to record when a document is modified or added64-bit integer 18 64-bit integer-This type is used to store the value min key255 min Key-This type is used to compare the value to the minimum Bson element Max key127 maximum key-this type is used to compare the value to the maximum Bson element
$type
The $type operator is based on the Bson type to retrieve the matching data type in the collection and returns the result
Look for x with a value type of number $type 1
Look for x with a value type of string, $type of String 2
Look for X with a Boolean value of type $type 8
Data types and $type operators for MongoDB databases