Consider the following document:
> db.c.find()
{ "_id" : 12, b : [ 3, 5, 7, 2, 1, -4, 3, 12 ] }
Which of the following queries on the "c" collection will return only the first five elements of the array in the "b"
field? E.g.,
Document you want returned by your query:
{ "_id" : 12, "b" : [ 3, 5, 7, 2, 1 ] >
Suggested Answer: A
Get Premium C100DBA Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
11 comments · newest first
DA
Daron
11 months ago
Definitely A, it's the only one that makes sense here.
CO
Cordelia
12 months ago
Wait, can you really use $substr on arrays? Sounds off.
IL
Ilda
12 months ago
Nah, D is totally wrong, it won't work.
DE
Deeanna
12 months ago
I think B looks right too, but not sure.
AL
Alva
1 year ago
Option A is the correct syntax for $slice!
AM
Amina
1 year ago
I'm confused about option C; I don't think $substr works with arrays. It feels like a trick question to me.
LA
Lashanda
1 year ago
I think I saw a similar question where we had to extract parts of an array, and I remember $slice being the key. So, A seems like the best choice.
MA
Margart
1 year ago
I'm not entirely sure, but I feel like the syntax in option B looks off. It doesn't seem to use the right format for slicing.
AL
Alysa
1 year ago
I remember we practiced using the $slice operator to limit array results, so I think option A might be correct.
ED
Eden
1 year ago
I'm feeling pretty confident about this one. The descriptions seem clear, and I think I can identify the two true statements without too much trouble.
TA
Tamesha
1 year ago
Okay, let's see. I think the key here is to balance coverage and quality. No critical defects and static analysis showing no major violations seem like good starting points to me.