Introduction
Sometimes documents in a database are very big. The subset pattern helps us get only the parts we need, making things faster and easier.
db.collection.find(query, {field1: 1, field2: 1, ...})db.users.find({}, {name: 1, email: 1})db.products.find({category: 'books'}, {title: 1, price: 1, _id: 0})db.orders.find({status: 'pending'}, {items: 1})db.library.find({author: 'Jane Austen'}, {title: 1, year: 1, _id: 0})name and age fields from documents in a MongoDB collection named users?products with documents containing _id, name, price, and details fields, what will be the output of this query?db.products.find({}, {name: 1, price: 1, _id: 0})name and price with 1, and excludes _id with 0._id is included unless explicitly excluded. Here it is excluded.title and author fields from books collection:db.books.find({}, {title: 1, author: 0})title is included (1) and author is excluded (0), which is invalid.orders with documents containing many fields including customer, items, total, and shipping. You want to fetch only customer and the total fields but exclude _id. Which query correctly applies the subset pattern for best performance?customer and total, set them to 1 in projection._id to 0 to exclude it from results._id must be included (1), no mixing with 0.Pass the test and this pattern moves unknown