🚀 Join 1,200+ candidates currently preparing with PrimerPrep
Back to Must-Know Dashboard

MongoDB

Must-Know Practice Sets

Overall Progress0 / 4 Modules Completed
Aggregation#1

The most basic pipeline stages provide __________ that operate like queries.

A
stored procedure
B
filters
C
aggregates
D
methods

In MongoDB aggregation, basic pipeline stages like $match act as filters that operate similarly to standard queries, allowing you to narrow down the documents before passing them to the next stage.

Aggregation#2

The _id field is mandatory in a $group operator.

A
No
B
Yes

The _id field is a mandatory requirement in the $group stage. It defines the grouping key used to aggregate the documents. If you want to aggregate all documents into a single group, you can set _id to null or another constant value.

Aggregation#3

What option is used with update command so that a new document gets created if no matching document is found based on the query condition?

A
This can be handled in application code(Node.js, PHP, JAVA, C#, etc) and cannot be handled in mongo shell query
B
upsert command instead of update command
C
{update: true, insert: true} as third parameter of update command
D
Specify {upsert : true} option can be used as the third parameter

Setting the 'upsert' option to true in an update operation tells MongoDB to insert a new document if no documents match the specified query condition. If matching documents exist, they will be updated normally.

Aggregation#4
Logic Block
1
2
3
4
5
Predict the outcome: db.movies.aggregate([ { $match : { reviews : { $gt : 100, $lte : 200 } } }, { $group: { _id: null, count: { $sum: 1 } } } ]);
A
Calculates the number of movies with reviews between 100 and 200
B
Groups the movies by number of reviews (101, 102, 103.) by adding 1 every time
C
Fetches the movies with reviews between 100 and 200 and sets their _id as null
D
Fetches the movies with reviews between 100 and 200, sets the _id of the first document as null and then increments it 1 every time

The $match stage filters the documents to include only those where the 'reviews' field is greater than 100 and less than or equal to 200. The $group stage with _id set to null groups all these matched documents into a single group, and the $sum accumulator counts the total number of documents in this group.

Aggregation#5

In a collection that contains 100 movie documents, what does the following command do? db.movies.find().skip(5).limit(5)

A
Skip and limit nullify each other. Hence returning the first five documents.
B
Skips the first five documents and returns the next five
C
Limits the first five documents and then return them in reverse order
D
Skips the first five documents and returns the sixth document five times

The cursor.skip(5) method skips the first five documents in the result set, and cursor.limit(5) restricts the output to the next five documents. This pattern is commonly used for implementing pagination.

Aggregation#6

Which of the following is not an accumulator type in $group operation?

A
push
B
min
C
pop
D
max

In MongoDB's aggregation framework, $push, $min, and $max are valid accumulators used in the $group stage. However, $pop is an array update operator used to remove the first or last element of an array, not an accumulator.

Aggregation#7

The $group operator in aggregation, sorts the output documents returned.

A
False
B
True

The $group stage does not order its output documents. The documents output by $group can be in any order. If a specific order is required, you must explicitly use the $sort stage after $group.

Aggregation#8

Which of the following aggregate commands in MongoDB uses a pipeline approach with the goals of improving the aggregation performance?

A
group
B
All of them
C
mapReduce
D
aggregate

The aggregate command introduces the aggregation pipeline framework, which processes data through multiple stages. This approach is highly optimized, using native C++ operations, and is the recommended way to perform aggregations in MongoDB, offering much better performance than mapReduce.

Aggregation#9
Logic Block
1
2
3
4
Predict the outcome: db.MovieCollection.aggregate ([{$group : {"_id" : "$Genre", "MovieName" : {"$first" : "$MovieName"}}}]);
A
Returns the movie name of the first movie in the first genre group from the movie collection
B
Returns the first movie name in all the genre groups from the movie collection
C
Returns the genre of the first movie name from the movie collection set of documents
D
Error in command

This aggregation pipeline groups documents by the 'Genre' field. For each unique genre group, it uses the $first accumulator to return the 'MovieName' from the first document processed in that group. Note that without a preceding $sort stage, the 'first' document is not strictly deterministic.

Aggregation#10

Which of the following is used for single purpose aggregation?

A
match
B
count
C
sort
D
group

In MongoDB, commands like count() and distinct() are considered single-purpose aggregation operations because they aggregate documents for a specific task. In contrast, match, sort, and group are stages within the more versatile aggregation pipeline framework.

Master the remaining 64 Must-Know questions

You've seen the basics. Unlock the full database of verified simulations and guarantee your selection with the 2026 Success Pass.

Unlock Success Pass — ₹99

Key Topics to Study

Based on our question bank analysis, master these concepts to score high in MongoDB.

Recommended

Success Primer Exam

Test your knowledge under real exam conditions with our curated mock assessment.

Start Preparing for Primers