MongoDB _ id attribute description

Source: Internet
Author: User

Generally, the ID field of a relational database is a self-increasing numeric type, but the _ id field of MongoDB is very strange. It can be unique, but it is not a simple type, not a number, it is not a string. I almost thought it was a string when I first came into contact.

In fact, it is a special object. In the JS shell of MongoDB, you can see that it is an object type and has a series of methods and attributes. The tostring attribute can return a string.

It is worth noting that after we get the _ ID of the object type, the. tostring cannot be used for search, cannot be converted, and can only be searched by the object type ....

For more information, see the following documents:
Http://www.mongodb.org/display/DOCS/Object+IDs
Http://api.mongodb.org/python/current/api/bson/objectid.html#module-bson.objectid

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.