First : Return the name of the first document in the sorted result.
Last : Return the name of the last document in the sorted result.
Query : db.mycol1.aggregate([{$sort:{age:1}},{$group:{_id:null,youngest:
{$first:"$name"},oldest:{$last:"$name"}}}]);
In operator : checking the condition more than one at a time;
!!!!
===================================================================================
===========================================!!!
DELETING THE DOCUMENT :
=> remove()
=> deleteOne()
=> deleteMany()
creating functions : db.createCollection("programmers");
Creating data : db.programmers.insert([{name:"james"},{name:"dennis"},
{name:"kumar"}]);
deleteOne() : db.programmers.deleteOne({name:{$in:
["azar","james","dennis"]}}); ///it will delete james
DeleteMany() : db.programmers.deleteMany({name:{$in:["azar","james","dennis"]}});
Remove() : db.programmers.remove({name:"james"});
DeleteMany : db.programmers.deleteMany({age:{$gt:60}});
FINDANDDELETE():
=> used to delete one single document based on selection criteria.
=> it deletes the first documents from the collection that matches the
given filter query expression.
=> db.mycol.findOneAndDelete({name:"kishore"});