What is the best practice in using the $match operator?
Answer: D
Question 2
Consider a MongoDB collection named products which has documents in the following format:
{
"_id" : ObjectId("5f5b0d2f3e3dfbcc11c84444"),
"name" : "Smartphone",
"brand" : "Apple",
"category" : "Electronics",
"price" : 1000,
"discount" : 0.1
}
What is the correct syntax to update the "price" field of all documents in the products collection by multiplying it with (1 - discount) using the $set operator and the $multiply operator?
Answer: D
Question 3
You are a MongoDB Associate Developer and need to demonstrate how to load the Atlas Sample Dataset into your MongoDB Atlas cluster. Your manager has asked you to guide a junior developer through this process to ensure they can independently load the dataset. What steps should the junior developer follow to successfully load the Atlas Sample Dataset?
Answer: A
Question 4
You manage a MongoDB collection called inventory that stores documents for a store's inventory. Each document has the fields item, category, and quantity. You want to ensure that an item is always present in the collection, even if it needs to be inserted. Specifically, if the item "notebook" in the "Stationery" category does not exist, it should be inserted with a quantity of 50. If it does exist, its quantity should be updated to 50. You plan to use the following command:
db.inventory.updateOne(
{ "item": "notebook", "category": "Stationery" },
{ $set: { "quantity": 50 } },
{ upsert: true }
)
What will happen after executing this command if there is no "notebook" item in the "Stationery" category in the inventory collection?
Answer: D
Question 5
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: