You are viewing a single comment's thread from:

RE: Mongodb数据库快速开发

in #starnote • 7 days ago
mongosh 
//切换数据库
use test 
//创建集合
db.createCollection(name, options), eg: db.createCollection("info")
//显示集合
show collections
//删除集合
db.collection.drop(), eg: db.info.drop()
//删除当前数据库
db.dropDatabase()  

//插入记录 insertOne insertMany
db.COLLECTION_NAME.insertOne(document)
eg: 
  >db.info.insertOne({title: 'MongoDB 教程44', 
      description: 'MongoDB 是一个 Nosql 数据库5',
      by: '菜鸟教程',
      url: 'http://www.runoob.com',
      tags: ['mongodb', 'database', 'NoSQL'],
      likes: 100
  })
//查找记录
db.info.find().pretty()