Consider a MongoDB database containing a collection of documents representing online orders for an e-commerce website. The documents have the following structure:
Select an aggregation pipeline that returns the total sales amount by state and month, for orders placed in the year 2022. The result should have the following format:
Answer: A
Question 2
There is a collection named products in MongoDB database. Your coworker wants to know how many products are in this collection (number of documents in the collection). Which query should you use? (Select two)
Answer: C,E
Question 3
When sharding a MongoDB collection, what is the main factor that determines the distribution of data across shards?
Answer: D
Question 4
Which of the following is the best practice for managing MongoDB data growth in a production environment (scale-out)?
Answer: C
Question 5
As a MongoDB Developer, you are tasked with optimizing a MongoDB database. Your collection has documents with the following structure:
{
"_id": ObjectId(),
"user_id": Number,
"user_data": {
"name": String,
"email": String,
"phone": String,
"address": {
"city": String,
"state": String,
"country": String
}
},
"transactions": [
{
"transaction_id": Number,
"amount": Number,
"date": Date
}
]
}
The application frequently queries for the total transaction amount for users based on the city. Which index should you create to optimize the performance of these queries?