MCQs > IT & Programming > MongoDB > Consider the following document from the products collection: { _id: 1, product_code: '1234', variations: [ { size: 'L', price: 1000 }, { size: 'M', price: 800 } ] } What does the following query using $elemMatch return? db.products.find( { product_code: '1234' }, { variations: { $elemMatch: { size: 'L' } } } )

MongoDB MCQs

Consider the following document from the products collection: { _id: 1, product_code: "1234", variations: [ { size: "L", price: 1000 }, { size: "M", price: 800 } ] } What does the following query using $elemMatch return? db.products.find( { product_code: "1234" }, { variations: { $elemMatch: { size: "L" } } } )

Answer

Correct Answer: Returns the document but with only one element in the variations array (corresponding to size L)

Explanation:

Note: This Question is unanswered, help us to find answer for this one

MongoDB Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

MongoDB Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it