Complete the code to create a collection optimized for fast reads by embedding related data.
db.users.insertOne({ name: "Alice", orders: [1] })Embedding the orders array inside the user document allows faster reads by avoiding joins.
Complete the query to find users with embedded orders containing item 'book'.
db.users.find({ "orders.item": [1] })Querying with "orders.item": "book" finds users whose embedded orders include a book.
Fix the error in the update to add a new embedded order to user 'Alice'.
db.users.updateOne({ name: "Alice" }, { [1]: { orders: { item: "notebook", qty: 3 } } })$push adds a new element to the embedded orders array, which is needed to add an order.
Fill both blanks to create an index on the embedded field for faster reads.
db.users.createIndex({ [1]: [2] })Creating an ascending index on 'orders.item' speeds up queries filtering by that embedded field.
Fill all three blanks to write an aggregation pipeline that unwinds orders and filters by qty > 2.
db.users.aggregate([ { $unwind: "$[1]" }, { $match: { "[2].qty": { [3]: 2 } } } ])$unwind deconstructs the orders array, then $match filters orders with qty greater than 2 using $gt.