xxxxxxxxxx
db.stocks.aggregate([
{ $match: { "price": 2000 } }
])
xxxxxxxxxx
Aggregration is the way of processing large number of documents by passing them different stages.
xxxxxxxxxx
db.users.aggregate([
{
$group: {
_id: null,
avgAge: { $avg: "$age" }
}
}
]);
xxxxxxxxxx
db.stocks.insertMany([
{ name: "Infosys", qty: 100, price: 800 },
{ name: "TCS", qty: 100, price: 2000 },
{ name: "Wipro", qty: 2500, price: 300 }
])