Challenges
Write real MongoDB commands, get auto-graded against the sample data. Equivalent solutions pass — there is no single “right” syntax.
List every product
Return all documents in the products collection.
Filter by category
Find all products whose category is "electronics".
Products under $30
Find all products with price strictly less than 30.
Count the catalog
Count how many documents are in the products collection.
Names and prices only
Return every product showing ONLY the name and price fields (no _id).
Most expensive first
Return all products sorted by price from highest to lowest.
Add a product
Insert a product with _id 100, name "Desk Organizer", category "office", price 15.99, stock 40.
Find Sara
Find the single user whose name is "Sara Khan".
Unique categories
Get the list of distinct product categories.
Page two
Products are paged 4 per page, sorted by _id ascending. Return page 2 (documents 5-8).
Mid-range products
Find products priced between 30 and 100 inclusive, sorted by price ascending.
Cheap or excellent
Find products that are either under $20 OR have a rating of at least 4.8.
Wireless things
Find all products whose tags array contains "wireless".
Office & furniture
Find products in the "office" or "furniture" categories using a single operator.
Price correction
Set the price of the product named "Desk Lamp" to 29.99 without changing anything else.
Restock electronics
Increase the stock of ALL electronics products by 10.
Tag the monitor
Add the tag "hdr" to the tags array of the product named "Monitor 27 inch".
Purge cancelled orders
Delete all orders whose status is "cancelled".
Category counts
Using aggregation, count products per category. Output docs like { _id: 'office', count: 3 }, sorted by count descending.
Average product rating
Compute one document with the average rating across ALL products, as { _id: null, avgRating: ... }.
Premium members
Find users who are premium members (premium: true), returning only their name and email (no _id).
Nolan filmography
In the cinema database, find all movies directed by "Christopher Nolan", sorted by year ascending. (Run "use cinema" first — your answer just needs the query.)
Revenue by status
Aggregate orders into { _id: status, revenue: total sum, orders: count }, sorted by revenue descending.
Best-selling products
Each order has an items array of { productId, qty }. Compute total quantity sold per productId as { _id: productId, sold: n }, sorted by sold descending.
Orders with customer names
Join each order to its user (orders.userId → users._id) into a field called customer, unwind it, and project { total: 1, status: 1, 'customer.name': 1 }.
Price histogram
Bucket products by price with boundaries [0, 50, 150, 500], collecting a count in each bucket (default bucket: 'other').
Top 3 spenders
Excluding cancelled orders, find the top 3 users by total spend: { _id: userId, spent: n }, sorted by spent descending, limited to 3.
Genre power ranking
In cinema.movies, unwind genres and compute the average rating per genre, rounded to 2 decimals as avgRating, sorted by avgRating descending. Output: { _id: genre, avgRating: n }.
Inventory value
For each product compute inventoryValue = price * stock, returning { name: 1, inventoryValue: 1, _id: 0 }, sorted by inventoryValue descending, top 5 only.
One-pass dashboard
Use $facet to compute two things in one pipeline: byCategory (count per category) and priceStats (single doc with avg price as avgPrice). Facet keys: byCategory, priceStats.