Data types supported by MongoDB documents

Source: Internet
Author: User

1. Storage type
The MongoDB document is similar to JSON, but not full JSON. There are only six types of JSON: null, BOOL, number, string, array, object. But MONGO's documents also extend several types, such as date types, integers, and floating-point numbers, based on JSON.
MongoDB is really stored on disk using Bson (binary JSON).
2. Common data types
Null: Indicates a nonexistent or null value. Bool:true and False. String: strings, enclosed in quotation marks.
3. Digital
There are only numeric types in JSON. There are three types of MongoDB: 32-bit integer 64-bit integer 64 is the floating-point number by default, which is stored by floating-point numbers.
4. Date
The date type stores the number of milliseconds that start from the standard era.
{"X": New Date ()}

5. Arrays
can store arrays
{"X": ["a", "B", "C"]}

6. Inline documentation
Use one document as a value for another document.
{"X": {"foo": "Bar"}}

7. _id
The MONGDB document must have a "_id" key, which is a Objectid object by default. The Objectid uses 12 bytes of storage space, two bits per byte, 16 decimal digits, and 24-bit strings. Allocation as shown
The first four bytes are timestamps. Because in front, the Objectid is probably sorted by timestamp. Use it as an index to increase efficiency. The PID is the process identifier and the counter is the counter per second. Three times per second (16*16 = 256) can be generated.
_ID can be generated by the program, without the system automatically, it is necessary to ensure that each ID cannot be duplicated.
8. Other
The document can also contain regular expressions, JavaScript code, and binary data.
Address: http://blog.csdn.net/yonggang7/article/details/25510377
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.