跳到主要内容

十九、MongoDB $type操作符

下表是 MongoDB 中的数据类型

类型数字
Double1
String2
Object3
Array4
Binary data5

| Undefined已废弃 | 6 | | Object id | 7 | | Boolean | 8 | | Date | 9 | | Null | 10 | | Regular Expression | 11 | | JavaScript | 13 | | Symbol | 14 | | JavaScript (with scope) | 15 | | 32-bit integer | 16 | | Timestamp | 17 | | 64-bit integer | 18 | | Min key | 255 | | Max key | 127 |

范例数据

使用以下命令向 数据库 souyunku 中的 lession 集合中插入数据

> db.lession.remove({});
> db.lession.insert({
title: 'PHP 基础教程',
description: 'PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言',
by: 'penglei',
url: 'https://pottercoding.cn/l/penglei/php/php-basic-index.html',
tags: ['php','php7'],
favorite: 2000
})
> db.lession.insert({title: 'Java 基础教程', 
description: 'Java 可以用来开发 JAVA WEB 和 AndRoid APP 运用程序',
by: 'penglei',
url: 'https://pottercoding.cn/l/penglei/java/java-basic-index.html',
tags: ['java','android'],
favorite: 3000
})