MongoDB data type

Source: Internet
Author: User
Tags unique id

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.