Aggregation
Mappers
|
|||||||||||||||||||
Summerization of
data
Do not store data
in any data tables
Do not change data
Like group by
clause
|
|||||||||||||||||||
db.products.aggregate({$group:{_id:"$Category",TotalValue:{$sum:"$Price"}}})
"_id" :
"Desktops", "TotalValue" : 0 }
"_id" :
"Laptops", "TotalValue" : 0 }
db.products.aggregate({$group:{_id:"$Category",TotalValue:{$sum:"$Price"}}})
"_id" :
"Laptops", "TotalValue" : 110000 }
db.products.aggregate({$group:{_id:"$Category",TotalValue:{$sum:"$Price"}}})
"_id" :
"Desktops", "TotalValue" : 20000 }
"_id" :
"Laptops", "TotalValue" : 110000 }
for order by we can use like this :
ReplyDeletedb.PublishedDocuments.find({ "$query" : { }, "$orderby" : { "Year" : -1, "Month" : -1 } }).limit(50);
Yes we can use . Thanks for sharing . orderby or sort either of them can be used
Delete