Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis based on data types and $type operator in MongoDB Database

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail the example analysis based on data types and $type operator in MongoDB database. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

The previous words

This article describes in detail the data types of the MongoDB database and the $type operator

Type numbers Note Double 1 double precision floating point numbers-this type is used to store floating point value String 2 strings-this is the most common data type used to store data. Strings in MongoDB must be UTF-8Object 3 objects-this data type is used for embedded document Array 4 arrays-this type is used to store arrays or lists or multiple values in a key Binary data 5 binary data-this data type is used to store binary data Undefined 6 obsolete Object id 7 object ID-this data type is used to store IDBoolean 8 Boolean type for storing documents-this type is used to store Boolean (true / false) values Date 9 dates-this data type is used to store the current date or time in UNIX time format. You can specify the date time you need by creating a date object and setting the date of the day, month, and year Null 10 Null-this type is used to store null values Regular 11 regular expressions-this data type is used to store regular expression JavaScript 13 code-this data type is used to store JavaScript code in the document Symbol 14 symbols-this data type is the same as a string However, language JavaScript (with scope) 15 code is usually reserved for using specific symbol types-this data type is used to store scoped JavaScript code in a document 32-bit integer 16 32-bit integers-this type is used to store numeric Timestamp 17 timestamps-when the document is modified or added You can easily record 64-bit integer 18 64-bit integers-this type is used to store numeric values Min key 255min keys-this type is used to compare values with minimum BSON elements Max key 127Max keys-this type is used to compare values with maximum BSON elements

Data type

MongoDB supports the following data types

$type

The $type operator retrieves the matching data types in the collection based on the BSON type and returns the result

Look for x with a numeric type and $type of 1 for the number

Look for x with a value of type string, and the $type of the string is 2

Find the x of the Boolean type, and the $type of the Boolean is 8

This is the end of this article on "sample analysis based on data types and $type operator in MongoDB database". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report