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 2
You are tasked with developing a high-performance application using MongoDB as your primary database. The application heavily relies on queries that retrieve user profiles based on user names and their location. Given this requirement, you decide to implement a strategy to make these queries more efficient. What strategy should you implement to ensure these queries are covered queries?
Answer: D
Question 3
In your database there is a collection named companies with the following document structure:
{
name: 'Wize',
relationships: [
{
is_past: false,
title: 'Head of Product',
person: {
first_name: 'Ethan',
last_name: 'Smith',
permalink: 'ethan-smith'
}
},
{
is_past: true,
title: 'Director, Business Development',
person: {
first_name: 'Stephanie',
last_name: 'Quay',
permalink: 'stephanie-quay'
}
},
{
is_past: true,
title: 'Sr. Engineer',
person: {
first_name: 'Stefan',
last_name: 'Antonowicz',
permalink: 'stefan-antonowicz'
}
}
]
}
Which of the following queries should you use to extract all companies that have "Co-Founder" title in relationships field (Array)?
Answer: B
Question 4
You have a MongoDB collection named employees that contains documents with fields name, department, and salary. You want to update the salary of all employees in the "Marketing" department to $75,000. The original collection looks like this:
What will the collection look like after this update operation?
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?