Node foundation seven: Mongodb database

Download address: https://www.mongodb.com/try/download/community

v:5.0.20 platform:window package:zip

Copy to c drive/Programs Files

The data/db folder is created on the c drive and the data address is stored by default

Start the database mongod in the bin directory, and the client connects to the database mongo

show dbs // 所有数据库
use 数据库名 // 指定数据库,可创建
db // 当前数据库
db.dropDatabase() // 删除数据库

db.createCollection('集合名') // 创建集合
show collections // 数据库集合
db.集合名.drop() // 删除集合
db.集合名.renameCollection('new name') // 重命名集合

db.集合名.insert(新文档) // 增
db.集合名.remove(条件) // 删
db.集合名.update({name: '张三'}, {$set: {age: 13}}) // 改
db.集合名.find(条件) // 查

Next chapter: Node Basics Eight: mongoose operates the database

Guess you like

Origin blog.csdn.net/weixin_64684095/article/details/132665017