MongoDB Project and Update
Project only name and address of employee by name ram
db.employee.find({name:"ram"},{name:1,address:1})
Project only name and address of all employees.
db.employee.find({},{name:1,address:1})
Suppress id field of all employees in display
db.employee.find({},{name:1,address:1,_id:0})
Display the marks scored by ram
db.student.find({name:"ram"},{marks:1,_id:0})
Update address from goa to delhi for the person with the name mohan in the employee collection
db.employee.updateOne({name:"mohan"},{$set:{address:"delhi"}})
Update address as pune for all employees who get a salary greater than 10000
db.employee.updateMany({salary:{$gt:10000}},{$set:{address:"pune"}})
Replace a document with replaceOne
db.employee.replaceOne({name:"ram"},{"name":"replacedone",hobby:"replaced"})
Inserting an null value for a field in the employee collection
db.employee.insert({name:"tim",salary:5000,address:null})
Displaying all the employees whose address field contains null value
db.employee.find({address:null})
Quering for null using type
db.employee.find({address:{$type:10}})