一、官网地址
https://studio3t.com/
二、下载和安装
点击DOWNLOAD即可下载
按照自己电脑系统进行选择,然后填写邮箱和选择行业,第一次登录如果不提交不会下载,下载完成是一个zip压缩包(我的电脑是windows系统),解压缩安装即可,安装途中可以自行选择安装路径
安装完成选择连接
根据提示进行操作,最后点击保存即可
右键新建的连接,选择Add Database新建数据库
输入数据库名称点击OK
右键创建的database,选择Add Collection创建新的Collection(相当于新建关系型数据库中的表),也可以删除数据库Drop Database
三、CRUD操作
首先打开命令行窗口,Open intelliShell
红色框是输入的命令行,绿色框是输出的提示信息
1、Insert操作详解
插入一个文档,db.collection.insertOne()
插入多个文档,db.collection.insertMany()
2、Query操作详解
查询所有, db.collection.find(),相当于:SELECT * FROM table_name
数据源
db.inventory.insertMany([
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }
]);
按条件查询db.collection.find({ke:value}),相当于SELECT * FROM table_name WHERE name = ?
使用查询运算符指定条件
指定AND条件查询,相当于SELECT * FROM inventory WHERE status = “A” AND qty < 30
指定OR条件,相当于SELECT * FROM inventory WHERE status = “A” OR qty < 30
指定AND和OR条件,相当于SELECT * FROM inventory WHERE status = “A” AND ( qty < 30 OR item LIKE “p%” )
3、Update操作详解
数据源
db.inventory.insertMany( [
{ item: "canvas", qty: 100, size: { h: 28, w: 35.5, uom: "cm" }, status: "A" },
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "mat", qty: 85, size: { h: 27.9, w: 35.5, uom: "cm" }, status: "A" },
{ item: "mousepad", qty: 25, size: { h: 19, w: 22.85, uom: "cm" }, status: "P" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
{ item: "sketchbook", qty: 80, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "sketch pad", qty: 95, size: { h: 22.85, w: 30.5, uom: "cm" }, status: "A" }
] );
更新单个文档db.collection.updateOne()
更新多个文档db.collection.updateMany()
替换文档db.collection.replaceOne()。
4、Delete操作详解
数据源
db.inventory.insertMany( [
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
] );
删除所有文档db.collection.deleteMany()
删除与条件匹配的文档
删除与条件匹配的一个文档
以上为CRUD的基本操作,其他扩展的CRUD方法见官网(可点击查看)