MongoDB Interview
Test your MongoDB knowledge before the interview. Think, reveal, self-assess — then jump to Learn if something is rusty.
More filters
- Must KnowEasyConcept
How would you explain MongoDB to someone who already knows relational databases?
3 minFundamentalsOpen
- Must KnowEasyConcept
MongoDB stores documents. How is BSON different from JSON, and why does that matter?
3 minFundamentalsOpen
- ImportantMediumConcept
MongoDB is schema-flexible. When does that help, and when does it hurt?
4 minFundamentalsOpen
- ImportantEasyConcept
What is ObjectId, and when would you not use one as _id?
3 minFundamentalsOpen
- Must KnowMediumConcept
What does it mean that a single-document write in MongoDB is atomic?
4 minFundamentalsOpen
- ImportantEasyConcept
What is the difference between find() and findOne()?
3 minCRUDOpen
- Must KnowEasyConcept
Why bother with projections if you are going to drop fields in application code anyway?
3 minCRUDOpen
- ImportantMediumScenario
A user hits 'save preferences' twice in a row. How would you write the update so the document is created if it does not exist, without inserting duplicates?
4 minCRUDOpen
- ImportantEasyConcept
When would you use $in rather than $or?
3 minQueryingOpen
- Must KnowMediumDebugging
This query returns nothing, even though the user exists. What is wrong, and how would you fix it?
4 minQueryingOpen
- ImportantMediumDebugging
This user search is fine in development and unusable in production. What would you investigate?
4 minQueryingOpen
- ImportantMediumScenario
A 'list users' API became slow and memory-heavy after you added profile fields, avatars, and a preferences object. The query is still find({ city }). What went wrong?
4 minQueryingOpen
- Must KnowMediumConcept
How do you query a nested field, and when must you use $elemMatch instead of dot notation on an array of objects?
4 minArraysOpen
- Must KnowMediumScenario
You stored comments as an array on each post. The write path starts failing for popular posts. What happened, and what would you change?
4 minArraysOpen
- ImportantMediumDebugging
This update is supposed to mark one skill as verified. What is wrong with it?
4 minArraysOpen
- Good to KnowMediumScenario
You need users who have both Node.js and MongoDB in a skills string array. How do you write that, and how is it different from $in?
4 minArraysOpen
- Must KnowMediumConcept
What is the aggregation pipeline, and why does stage order matter?
4 minAggregationOpen
- ImportantMediumConcept
How does $group work, and what does _id mean inside it?
4 minAggregationOpen
- Must KnowMediumConcept
What does $lookup do, and why is it sometimes expensive?
4 minAggregationOpen
- ImportantMediumConcept
What does $unwind do, and what silent behaviour should you know about?
4 minAggregationOpen
- Must KnowHardDebugging
This pipeline was acceptable at 100k orders and is now painful at 50 million. What would you investigate, in order?
5 minAggregationOpen
- ImportantMediumScenario
Product wants the top 3 customers by completed-order spend. How would you write the pipeline, and what index would you want?
4 minAggregationOpen
- ImportantHardDesign
An API always $lookups the user onto every order. Would you keep the join, embed the user snapshot, or duplicate a few fields? What factors decide?
5 minAggregationOpen
- Good to KnowMediumScenario
A dashboard needs completed-order count, revenue, and top 5 products from the same day's orders. Would you use $facet or three aggregations?
4 minAggregationOpen
- Must KnowHardDesign
How do you decide between embedding and referencing in MongoDB?
5 minData ModelingOpen
- Must KnowMediumDesign
Would you embed order items inside an order or store them in a separate collection? What factors would you consider?
4 minData ModelingOpen
- ImportantHardDesign
Would you embed product information inside an order line, or only store productId and $lookup the catalogue?
5 minData ModelingOpen
- ImportantMediumScenario
Users can enrol in many courses, and courses have many users. How would you model that in MongoDB?
4 minData ModelingOpen
- Good to KnowHardDesign
How would you decide between MongoDB and PostgreSQL for a new backend service?
5 minData ModelingOpen
- Good to KnowMediumScenario
A chat thread is stored as one document with a messages array. What problems appear at scale, and what pattern would you use instead?
4 minData ModelingOpen
- Must KnowMediumConcept
How do indexes work in MongoDB, and why would you not index every field?
4 minIndexingOpen
- Must KnowHardConcept
How does field order in a compound index affect which queries can use it?
5 minIndexingOpen
- Must KnowMediumConcept
What is the ESR guideline for compound indexes, and why does the sort field go before range?
4 minIndexingOpen
- ImportantEasyScenario
How would you prevent two users from registering with the same email?
3 minIndexingOpen
- ImportantMediumDebugging
Writes to orders slowed down after the team added an index for every dashboard filter. What happened, and how would you respond?
4 minIndexingOpen
- Good to KnowHardConcept
What is a covered query?
5 minIndexingOpen
- Must KnowMediumDebugging
A query is slow. How do you diagnose it?
4 minPerformanceOpen
- Must KnowHardScenario
You have 50 million orders. How would you efficiently fetch the latest 20 orders for a user?
5 minPerformanceOpen
- ImportantMediumDebugging
Page 1 of this API is fast. Page 5000 is not. Why, and what would you do instead?
4 minPerformanceOpen
- Good to KnowMediumConcept
Is a COLLSCAN always a problem?
4 minPerformanceOpen
- Must KnowHardConcept
Does MongoDB support transactions, and when do you actually need them?
5 minTransactionsOpen
- ImportantHardScenario
You must move money from account A to account B. Would you use a MongoDB transaction? What else would you consider?
5 minTransactionsOpen
- Must KnowMediumDebugging
Two checkouts can both buy the last Mechanical Keyboard. What is wrong, and how do you fix it?
4 minConcurrencyOpen
- ImportantHardScenario
Two requests credit the same wallet document at the same time using find, add in JS, then $set balance. How do you make this safe?
5 minConcurrencyOpen
- Must KnowMediumDebugging
A Node.js API creates new MongoClient() inside the request handler and closes it at the end. Latency is high and the cluster shows connection spikes. What is wrong?
4 minNode.jsOpen
- Must KnowMediumDebugging
This query became slow after orders reached 50 million documents. What would you investigate?
4 minNode.jsOpen
- ImportantMediumScenario
How should a Node.js web app share MongoDB connections across requests, and what goes in environment variables?
4 minNode.jsOpen
- Good to KnowMediumConcept
What does lean() do in Mongoose, and when would you use it?
4 minMongooseOpen
- Good to KnowMediumScenario
An order list API uses populate('user') and populate('items.product') and is slow. What is going on, and what would you change?
4 minMongooseOpen
- ImportantMediumConcept
What is a replica set, and what do write concern and read preference control?
4 minProductionOpen
Showing 50 of 50 questions.