What is the best practice in using the $match operator?
Answer: D
Question 2
What is the difference between a sparse index and a non-sparse index in MongoDB?
Answer: A
Question 3
We have a movies collection with the following document structure:
{
_id: ObjectId("573a1390f29313caabcd6223"),
genres: [ 'Comedy', 'Drama', 'Family' ],
title: 'The Poor Little Rich Girl',
released: ISODate("1917-03-05T00:00:00.000Z"),
year: 1917,
imdb: { rating: 6.9, votes: 884, id: 8443 }
},
{
_id: ObjectId("573a13e3f29313caabdc08a4"),
genres: [ 'Horror', 'Thriller' ],
title: 'Mary Loss of Soul',
year: 2014,
imdb: { rating: '', votes: '', id: 2904798 }
}
We need to use Aggregation Framework to calculate the following aggregates:
average imdb rating
minimum imdb rating
maximum imdb rating
Expected output:
[
{
_id: null,
avg_rating: 6.6934040649367255,
min_rating: 1.6,
max_rating: 9.6
}
]
Please note that some documents have "" (empty string) for the field "imdb.rating". Exclude these documents before aggregation.
Which pipeline should you use?
Answer: C
Question 4
Consider a collection named students with the following document:
{
"_id" : ObjectId("5f0a7e80d8c9c7b5a48c49e1"),
"name" : "Alice",
"age" : 21,
"courses" : [
{
"name" : "Math",
"grade" : 89
},
{
"name" : "Science",
"grade" : 92
}
]
}
What is the query to update the grade of the "Math" course for the student with "_id" equal to ObjectId("5f0a7e80d8c9c7b5a48c49e1") to 95?
Answer: C
Question 5
In the context of MongoDB development, you are creating a new service that is expected to handle high load. You've decided to leverage the MongoDB drivers' connection pooling capability. What best describes connection pooling and its advantages?