Data types and $type operators for MongoDB databases

Source: Internet
Author: User

Previous words

This article will detail the data types and $type operators of the MongoDB database

Data type

MongoDB supports the following data types

Type Number Memo double1 double-precision floating-point number-This type is used to store floating-point values string2 string-This is the most common data type used to store data. The string in MongoDB must be UTF-8Object3 Objects-This data type is used for embedded document array4 Arrays-This type is used to store an array or list or multiple values into a single key binary data52 Binary Data-This data type is used to store binary data undefined6Deprecated Object ID7 Object ID-This data type is used to store the document's Idboolean8 Boolean Type-this type is used to store a Boolean value (true/false) Value Date9th Period-This data type is used to store the current date or time in Unix time format. You can specify the date time that you want by creating a Date object and specifying the date of day, month, and year nullTen Null-This type is used to store null values regular11 Regular Expressions-This data type is used to store regular expression JavaScript13 Code-This data type is used to store JavaScript code in the document symbol14 Symbols-The data type is the same as the string, but it is usually reserved for language JavaScript that uses a particular symbol type ( withSCOPE) 15 code-This data type is used to store the scoped JavaScript code in the document32-bit Integer 16 32-bit integer-This type is used to store numeric timestamp17 Time Stamp-easy to record when a document is modified or added64-bit integer 18 64-bit integer-This type is used to store the value min key255 min Key-This type is used to compare the value to the minimum Bson element Max key127 maximum key-this type is used to compare the value to the maximum Bson element

$type

The $type operator is based on the Bson type to retrieve the matching data type in the collection and returns the result

Look for x with a value type of number $type 1

Look for x with a value type of string, $type of String 2

Look for X with a Boolean value of type $type 8

Data types and $type operators for MongoDB databases

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.