Program2_WM
Program2_WM
a. Develop a MongoDB query to select certain fields and ignore some fields of the
documents from any collection.
{
"rno" : 1,
"name" : "Bhavana",
"location": "Chennai"
}
{
"rno" : 2,
"name" : "Amit",
"location": "Delhi"
}
{
"rno" : 3,
"email_id" : "[email protected]" ,
"location":"Chennai"
}
{
"rno" : 4,
"name" : "Akash" ,
"location":"Bangalore"
}
{
"rno" : 5,
"name" : "Chaitra",
"location": "Bangalore"
}
//Find command with condition with giving name field only to show
> db. details.find({rno:5},{name:1})
Output:
//Find command with condition with giving name field only to show and _id to hide
>db. details.find({rno:5},{name:1,_id:0})
Output:
Limit Operation: Used to restrict the number of documents returned by a query. This is
particularly useful when you're dealing with large datasets and you only need a subset of
documents.