products with documents containing a category field, which query returns all products whose category is either 'electronics', 'books', or 'clothing'?db.products.find({ category: { $in: ['electronics', 'books', 'clothing'] } })The $in operator matches documents where the field's value is any one of the values in the specified array. So it returns products whose category is 'electronics', 'books', or 'clothing'.
orders where each document has a numeric status_code. Which query returns orders with status codes 1, 3, or 5?db.orders.find({ status_code: { $in: [1, 3, 5] } })The $in operator matches documents where the status_code is any of the values 1, 3, or 5.
tags field?The $in operator requires an array as its value. Option A incorrectly passes multiple string arguments instead of an array, causing a syntax error.
users with an index on the role field. Which query will best use the index to find users with roles 'admin', 'editor', or 'viewer'?The $in operator efficiently uses indexes on the field to match any of the specified values. While $or can also use indexes, $in is more concise and optimized for this use case.
posts, each document has a field tags which is an array of strings. What does the query db.posts.find({ tags: { $in: ['mongodb', 'database'] } }) return?The $in operator matches if any element of the tags array is in the specified list. It does not require all elements to match or exact array equality.