// Online MongoDB shell (simulated mongosh)
// Database "shop": customers, products, orders
db.products.find({ price: { $lt: 50 } }, { name: 1, price: 1, _id: 0 }).sort({ price: -1 })
db.orders.aggregate([
{ $unwind: '$items' },
{ $group: { _id: '$items.product', sold: { $sum: '$items.qty' } } },
{ $sort: { sold: -1 } },
{ $limit: 3 }
])
Press ▶ Run or Ctrl/⌘ + Enter to run your code.
Database "shop" with collections: customers, products, orders. Each line's result is printed, like mongosh.