mongodb 数据类型
It is known that the MongoDB stores the JSON data in a binary encoded format called BSON, where JSON data model actually extends the BSON in order to provide more flexibility with the additional data types and helps in easily encoding and decoding the data across various programming languages. By default, there is no support for the datatypes like date in JSON. But, BSON provides that feature.
众所周知,MongoDB以称为BSON的二进制编码格式存储JSON数据,其中JSON数据模型实际上扩展了BSON,以便通过其他数据类型提供更大的灵活性,并有助于轻松地跨各种编程语言对数据进行编码和解码。 默认情况下,不支持JSON中的日期等数据类型。 但是,BSON提供了该功能。
MongoDB supports the below list of datatypes. Each datatype in MongoDB possess a unique number.
MongoDB支持以下数据类型列表。 MongoDB中的每个数据类型都有一个唯一的编号。
Datatype | Number | Description |
---|---|---|
Double | 1 | Used to stored floating point values |
String | 2 | Commonly used datatype and it is UTF-8 valid |
Object | 3 | Used for storing embedded objects |
Array | 4 | Used for storing embedded objects |
Binary Data | 5 | Used to store binary data |
Undefined | 6 | Used to store undefined value |
Object Id | 7 | Used to store document's ID |
Boolean | 9 | Used to store Boolean value |
Date | 10 | Used to store current date time in UNIX format. |
Null | 11 | Used to store null value |
Regular Expression | 12 | Used to store regex |
Javascript | 13 | Used to store JavaScript data without scope |
Symbol | 14 | Basically used to store string, but reserved for languages that use specific symbol |
Javascript with scope | 15 | Used to store JavaScript data with scope |
Integer | 16 & 18 | Used to store numerical value |
Timestamp | 10 | Used to track when a document is modified. |
Min/Max Key | 255/127 | Used to compare value against lowest and highest BSON elements |
数据类型 | 数 | 描述 |
---|---|---|
双 | 1个 | 用于存储浮点值 |
串 | 2 | 常用的数据类型,它是UTF-8有效 |
目的 | 3 | 用于存储嵌入式对象 |
数组 | 4 | 用于存储嵌入式对象 |
二进制数据 | 5 | 用于存储二进制数据 |
未定义 | 6 | 用于存储未定义的值 |
对象编号 | 7 | 用于存储文档的ID |
布尔型 | 9 | 用于存储布尔值 |
日期 | 10 | 用于以UNIX格式存储当前日期时间。 |
空值 | 11 | 用于存储空值 |
正则表达式 | 12 | 用于存储正则表达式 |
Java脚本 | 13 | 用于存储无范围JavaScript数据 |
符号 | 14 | 基本上用于存储字符串,但保留给使用特定符号的语言使用 |
具有范围的Javascript | 15 | 用于存储具有范围JavaScript数据 |
整数 | 16和18 | 用于存储数值 |
时间戳记 | 10 | 用于跟踪文档何时被修改。 |
最小/最大键 | 255/127 | 用于将值与最低和最高BSON元素进行比较 |
翻译自: https://www.studytonight.com/mongodb/datatypes-in-mongodb
mongodb 数据类型