* mongodb://localhost:27017 --> to connect to mongodb
* show dbs --> to show dbs
* use employeeDb --> it will create db if there is exixting db on same name it will
switch to that db
* db.createCollection("<name of the name collection>") --> it will create
collection.
** The collection name should be same as db name
Ex:
---
dbname : employeedb
collection name: employee
*db.employee.insertMany([{empname:"anish",salary: 230000,city:"Hyd"},
{empname:"Rama",salary: 23000000,city:"Hyd"}]) --> To insert data
* db.employee.find() --> To fetch records
*db.employee.upadte({empname:"Anish"},{$set:{name:"seetha"}) -->update
* db.employee.remove({},{empname:""})
* To print only empname:
db.employee.find({empname:1})
** Here 1 --> to show data
0 --> to hide the data
** $gt --> Greater than
** $lt --> Less Than
** $gte --> Greater than or equal to
** $lte --> Less than or equal to
** $ne --> Not equal to
*db.employee.find({salary:{$get:30000}},{empname:1,salary:1,_id:0})
--> it will find the details more than 300000 and id should be hide.
* If we want only two records means
db.employee.find().limit(2)
* If we want to skip two records means
db.employee.find().skip(2)
* db.employee.find({city:"Chennai"}).count() --> To know the count.
* db.employee.aggregate([{$group:{_id:"$city",Totalsalary:{$sum:"$salary"}}}]) --
>To get total salary
* db.employee.aggregate([{$match:{empname:"sam"}},{$project:
{empname:1,age:1,city:1}}]) -->To find the matching person.
db.employee.aggregate([{$match:{department:"IT"}},{$project:
{empname:1,age:1,city:1,department:1}}])
index quick retrieval of data
sorting
pipeline