MongoDB Basic Commands
Mongodb is a NoSQL database used for bigdata handling applications. In this blog, I have mentioned the basic commands of the Mongodb compass (>_MONGOSH).
show dbs
- It will show all the stored databases.
db
- It will show the currently active database.
use (Database Name)
- It will select the database or if it is unavailable, it will create a new database.
db.students.insertOne()
This will add a new document to a collection.
db.students.insertMany([{},{}])
This will add multiple documents to a collection.
db.students.find()
This will get all documents from a collection.
db.students.findOne()
This will get the first document from the collection.
db.students.findOne({filter})
This will get the specific document from the collection which satisfies the given condition.
db.students.find({filter})
This will get all the specific documents from the collection which satisfies the given condition.
db.students.updateOne({filter},{$set:{data}})
This will update a specific document from the collection which satisfies the given condition. Updated results is given below.
db.students.updateMany({filter},{$set:{data}})
This will update specific documents from the collection which satisfies the given condition.
Updated results is given below.
db.students.deleteOne({filter})
This will delete a specific document from the collection which satisfies the given condition.
db.students.deleteMany({filter})
This will delete the specific documents from the collection which satisfies the given condition. Updated results is given below.
Thank you for reading…