Data types supported by MongoDB documents

Source: Internet
Author: User
Tags documentation

1. Storage type
The MongoDB document is similar to JSON. But not completely JSON. There are only six types of JSON: null. bool Number, String. Array. Object.

However, MONGO's documentation extends several types on the basis of JSON. For example, a date type, an integer, a floating-point number.


MongoDB is really stored on disk using Bson (binary JSON).
2. Frequently used data types
Null: Indicates a nonexistent or null value.

Bool:true and False. String: strings, including with an argument.
3. Digital
There are only numeric types in JSON.

There are three kinds of MongoDB: 32-bit integer 64-bit integer 64 is floating-point number by default, it is stored according to floating-point numbers.
4. Date
The date type stores the number of milliseconds starting from the standard era.

{"X": New Date ()}

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

6. Inline documentation
Use a document as a value for a document.

{"X": {"foo": "Bar"}}

7. _id
The MONGDB document must have a "_id" key. The default is a Objectid object. The Objectid uses 12 bytes of storage space, two bits per byte, 16 binary digits, and is a 24-bit string. Allocations such as those seen in the
The first four bytes are timestamps. Because in front, the objectid is probably sorted according to the timestamp.

Use it as an index to increase efficiency.

The PID is the process identifier and the counter is the counter per second. The ability to generate three times per second (16*16 = 256).


_ID can program to generate, without the system's own initiative, this need to ensure that each ID can not be repeated.
8. Other
The document can also include regular expressions, JavaScript code, and binary data.


Address: http://blog.csdn.net/yonggang7/article/details/25510377

Data types supported by MongoDB documents

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.