All academies

Challenges

Write real MongoDB commands, get auto-graded against the sample data. Equivalent solutions pass — there is no single “right” syntax.

0 / 30 solved

List every product

Return all documents in the products collection.

easy+20 XP

Filter by category

Find all products whose category is "electronics".

easy+20 XP

Products under $30

Find all products with price strictly less than 30.

easy+25 XP

Count the catalog

Count how many documents are in the products collection.

easy+20 XP

Names and prices only

Return every product showing ONLY the name and price fields (no _id).

easy+25 XP

Most expensive first

Return all products sorted by price from highest to lowest.

easy+25 XP

Add a product

Insert a product with _id 100, name "Desk Organizer", category "office", price 15.99, stock 40.

easy+25 XP

Find Sara

Find the single user whose name is "Sara Khan".

easy+20 XP

Unique categories

Get the list of distinct product categories.

easy+25 XP

Page two

Products are paged 4 per page, sorted by _id ascending. Return page 2 (documents 5-8).

easy+30 XP

Mid-range products

Find products priced between 30 and 100 inclusive, sorted by price ascending.

medium+40 XP

Cheap or excellent

Find products that are either under $20 OR have a rating of at least 4.8.

medium+40 XP

Wireless things

Find all products whose tags array contains "wireless".

medium+40 XP

Office & furniture

Find products in the "office" or "furniture" categories using a single operator.

medium+40 XP

Price correction

Set the price of the product named "Desk Lamp" to 29.99 without changing anything else.

medium+45 XP

Restock electronics

Increase the stock of ALL electronics products by 10.

medium+45 XP

Tag the monitor

Add the tag "hdr" to the tags array of the product named "Monitor 27 inch".

medium+45 XP

Purge cancelled orders

Delete all orders whose status is "cancelled".

medium+40 XP

Category counts

Using aggregation, count products per category. Output docs like { _id: 'office', count: 3 }, sorted by count descending.

medium+50 XP

Average product rating

Compute one document with the average rating across ALL products, as { _id: null, avgRating: ... }.

medium+50 XP

Premium members

Find users who are premium members (premium: true), returning only their name and email (no _id).

medium+40 XP

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.)

medium+40 XP

Revenue by status

Aggregate orders into { _id: status, revenue: total sum, orders: count }, sorted by revenue descending.

hard+70 XP

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.

hard+80 XP

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 }.

hard+80 XP

Price histogram

Bucket products by price with boundaries [0, 50, 150, 500], collecting a count in each bucket (default bucket: 'other').

hard+80 XP

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.

hard+80 XP

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 }.

hard+85 XP

Inventory value

For each product compute inventoryValue = price * stock, returning { name: 1, inventoryValue: 1, _id: 0 }, sorted by inventoryValue descending, top 5 only.

hard+75 XP

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.

hard+90 XP