Aggregation pipeline တွင် အသုံးများသော stages များ:
• $match: Incoming documents များကို filter လုပ်သည် (find() နှင့်ဆင်တူသည်)
• $group: Documents များကို သတ်မှတ်ထားသော key ဖြင့် စုဖွဲ့ပြီး စုစုပေါင်း ($sum), ပျမ်းမျှ ($avg) စသည်တို့ကို တွက်ချက်သည်။
javascript
db.orders.aggregate([
// Stage 1: Filter documents with status "A"
{ $match: { status: "A" } },
// Stage 2: Group by customer_id and calculate total amount
{ $group: { _id: "$cust_id", total: { $sum: "$amount" } } }
])You should see
(status "A" ရှိသော orders များကို customer တစ်ယောက်ချင်းစီအလိုက် စုပြီး amount စုစုပေါင်းကို တွက်ချက်ပြသမည်)