Mongodb storage structure: database > collection > document
Interactive
- Turn on interactive
mongo
two。 List the databases that exist
show dbs
- Create a database
use saber2pr
- Create a collection in the database
db.createCollection("qwq")
- List the collections that exist in the database
show collections
- Insert a document into the collection
db.qwq.insert({name: "saber"})
- Find the specified document in the collection
db.qwq.find({name: "saber"})
- Find all documents in the collection
db.qwq.find()
- Delete the specified document in the collection
db.qwq.remove({name: "saber"})
- Delete all documents in the collection
db.qwq.remove({})
- Delete the specified collection in the database
db.qwq.drop()
twelve。 Delete the specified database
use saber2pr
db.dropDatabase()