14 MongoDB basic commands to start with

1.Listing the existing databases → show dbs

2. Choose a db to work with /create db → use alm

3. Print the name of db in use → db.getName()

4. Drop db → db.dropDatabase()

5. Display the collections in the db → show collections

6. Retrieve the name of the collections in the db → db.getCollectionNames

C-Create

7. Adding entry (which becomes a document of the collection)to the collection “employees”→ db.employees.insert/save({name:”Pallavi”,empId:183})

R-Read

8. Queries a collection for documents → db.employees.find()

9.Queries a collection for documents, depicting the 1st 2 documents → db.employees.find().limit(2)

10.Queries a collection for documents, depicting 1 document → db.employees.findOne()

11. Retrieve entries in the collection “employees” with empId 183 → db.employees.find({empId:183})

12.Retrieve entries in the collection “employees” with empId less than 183 → db.employees.find({empId:{$lt:183}})

U-Update

13.Updating documents in a collection → db.employees.update(query, update, options)

Updated document where name: Pallavi

D-Delete

14.Removing documents from a collection → db.collection.remove()

Deleted document where empId — 1187