All challenges
Top 3 spenders
hard+80 XPExcluding cancelled orders, find the top 3 users by total spend: { _id: userId, spent: n }, sorted by spent descending, limited to 3.
Sample of shop.orders
{
_id: 1001,
userId: 101,
items: [
{
productId: 1,
qty: 2
},
{
productId: 3,
qty: 1
}
],
total: 99.97,
status: "delivered",
date: "2025-05-01"
}{
_id: 1002,
userId: 102,
items: [
{
productId: 5,
qty: 1
}
],
total: 199.99,
status: "shipped",
date: "2025-05-14"
}{
_id: 1003,
userId: 101,
items: [
{
productId: 9,
qty: 1
},
{
productId: 2,
qty: 1
}
],
total: 369.98,
status: "delivered",
date: "2025-06-02"
}