Quantcast
Channel: CodeSection,代码区,数据库(综合) - CodeSec
Viewing all articles
Browse latest Browse all 6262

MongoDB中的数据类型

$
0
0

mongoDB中存储的数据单元被称作文档。文档的格式与JSON很类似,只不过由于JSON表达的数据类型范围太小(null,boolean,numeric,string和object),mongoDB对其做了扩充,并命名为BSON。下面对各个数据类型进行介绍。

null

{‘x’: null},数据为空类型

boolean

{‘x’: true},数据为布尔类型

number

{‘x’: 3},3的存储类型是int,float,long等需要根据我们在开发时使用的引擎来决定

string

{‘x’: “foobar”},字符一般使用utf-8编码来存储

date

{“x”: ISODate("2016-11-17T14:28:08.295Z")},存储的值可以是一个日期。

array {“x”: [ "a", "b", "c" ] },存储的值可以是一个数组 embedded document

{ "x" : { "foo" : "bar" }},也可以直接将一个文档存储为某个键对应的值


Viewing all articles
Browse latest Browse all 6262

Trending Articles