Consider the following situation: You are a MongoDB Developer and are currently working on an application that requires complex reporting on large amounts of data. The application stores its data in MongoDB, which has grown significantly. To maintain efficiency and manageability, you decide to use MongoDB views. You want to create a view "UsersView" that includes only username, email, and createdAt fields from the Users collection. Which of the following commands would you use?
In a MongoDB database, you have a collection named orders that contains information about various product orders placed by customers. Each document in the collection has the following structure:
{
"customerID": "",
"orderID": "",
"product": "",
"quantity": ,
"price": ,
"date": "",
"status": ""
}
You are required to write an aggregation query that retrieves all orders placed by customers where the quantity of ordered items is greater than 100 and the status of the order is "delivered". Which of the following $match stages would you use to achieve this? Select the best option.
Consider a MongoDB collection named orders which has documents in the following format:
{
"_id" : ObjectId("5f5b0d2f3e3dfbcc11c84444"),
"orderId" : 1001,
"customerId" : 200,
"items" : [
{
"productId" : 101,
"quantity" : 2
},
{
"productId" : 102,
"quantity" : 1
}
],
"totalAmount" : 250,
"status" : "Pending"
}
What is the correct syntax to find and update the first document in the orders collection where "status" is "Pending", and change the "status" field to "Completed" using the findAndModify method?
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?
You are designing a MongoDB schema for an e-commerce platform. The platform has three main collections: Products, Orders, and Users.Products Collection: Contains information about each product, such as its name, price, and description.Orders Collection: Contains details about each order, including the userId (referencing the Users collection), an array of productIds (referencing the Products collection), and the total order amount.Users Collection: Contains user details, such as name, email, and address.Which of the following data modeling approaches represents an anti-pattern in MongoDB?