Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

MongoDB C100DBA Exam - Topic 7 Question 131 Discussion

Consider the following document from the products collection:What does the following query using $elemMatch return? db.products.find( { product_code: "345678" }, { variations: { $elemMatch: { size: ^L^ } } } )
B) Returns the document but with only one element in the variations array (corresponding to size L)
A) Returns the complete document but retrieves only the size field from the array
C) Returns the complete document since MongoDB does not support partial array retrieval
D) Returns the complete document but retrieves only the size field from the array and also with only one element in the variations array (corresponding to size L)

MongoDB C100DBA Exam - Topic 7 Question 131 Discussion

Actual exam question for MongoDB's C100DBA exam
Question #: 131
Topic #: 7
[All C100DBA Questions]

Consider the following document from the products collection:

What does the following query using $elemMatch return? db.products.find( { product_code: "345678" }, { variations: { $elemMatch: { size: ^L^ } } } )

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Audrie
5 hours ago
I feel like option D might be the right choice since it mentions retrieving the size field and only one element, which seems to align with how $elemMatch works.
upvoted 0 times
...
Becky
5 days ago
I’m a bit confused about whether MongoDB allows partial retrieval of arrays. I thought it did, but I could be wrong.
upvoted 0 times
...
Claribel
11 days ago
I remember practicing a similar question where $elemMatch was used, and it returned only the matching elements from the array. So, I’m leaning towards option B.
upvoted 0 times
...
Dorathy
16 days ago
I think the query is supposed to return the document with just the matching variation, but I'm not entirely sure if it includes the whole document or just part of it.
upvoted 0 times
...

Save Cancel