With the advent of the era of web2.0, the relational database in more and more scenarios under a lot of problems, in order to solve such problems, NoSQL database application, today is the mainstream NoSQL database MongoDB.
1. The basic data type MongoDB is similar to JSON, which is conceptually similar to JavaScript. JSON is a simple representation of data, consisting of 6 data types: null, Boolean , number, string, array, and object. There is no time data type, which can be cumbersome in operation time. MongoDB adds additional data types based on preserving JSON's basic key-value pairs.
Data type |
How the document is represented |
Description |
Null |
{"X": null} |
NULL indicates a null or nonexistent string |
Boolean |
{"X": True} |
Boolean has two values of true or false |
32-bit integer |
|
This type is not available in the shell because JavaScript only supports 64-bit floating-point numbers, and all 32-bit integers are automatically converted. |
64-bit integer |
|
This type is not supported in the shell, and the shell uses a special inline document to display a 64-bit integer |
64-bit floating point number |
{"X": 12.6} {"Y": 12} |
The numbers in the shell are this type |
String |
{"X": "Personaliinfo"} |
UTF-8 strings can be represented as string types of data |
Symbol |
|
The shell does not support this type. Shell converts a symbol type in a database to a string |
Object ID |
{"X": ObjectId ()} |
Object ID is a unique ID of 12 bytes of the document |
Date |
{"X": Newdate ()} |
The date type stores the number of milliseconds starting from the standard era, without storing the time zone |
Regular expressions |
{"X":/personaliinfo/i} |
The document can contain regular expressions, with the syntax of regular expressions |
Code |
{"X": function () {...}} |
The document can contain JavaScript code |
Binary data |
|
Binary data can be made up of strings of arbitrary bytes that cannot be used in the shell |
Maximum Value |
|
Bson contains a special type that represents the maximum possible value that is not in the shell |
Minimum value |
|
The Bson contains a special type that represents the minimum possible value that is not in the shell |
Not defined |
{"X": undefined} |
Undefined types can be used in documents (null and undefined are different types in JavaScript) |
Array |
{"X" ["A", "B", "C"]} |
Worth a collection or list can represent an array |
Inline document |
{"X": {"name": "H"}} |
Other documents can be embedded in the document |
MongoDB data type