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 1 Question 48 Discussion

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 ] >
A) db.c.find( { > , { b : { $slice : [ 0 , 5 ] } } )
B) db.c.find( { b : [ 0 , 5 ] > )
C) db.c.find( { > , { b : { $substr[ 0 , 5 ] > > )
D) db.c.find( { > , { b : [ 0, 1, 2, 3, 4, 5 ] > )
E) db.c.find( { > , { b : [ 0 , 5 ] > )

MongoDB C100DBA Exam - Topic 1 Question 48 Discussion

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

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 ] >

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters
Daron
9 months ago
Definitely A, it's the only one that makes sense here.
upvoted 0 times
...
Cordelia
10 months ago
Wait, can you really use $substr on arrays? Sounds off.
upvoted 0 times
...
Ilda
10 months ago
Nah, D is totally wrong, it won't work.
upvoted 0 times
...
Deeanna
10 months ago
I think B looks right too, but not sure.
upvoted 0 times
...
Alva
10 months ago
Option A is the correct syntax for $slice!
upvoted 0 times
...
Amina
10 months ago
I'm confused about option C; I don't think $substr works with arrays. It feels like a trick question to me.
upvoted 0 times
...
Lashanda
10 months 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.
upvoted 0 times
...
Margart
10 months 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.
upvoted 0 times
...
Alysa
10 months ago
I remember we practiced using the $slice operator to limit array results, so I think option A might be correct.
upvoted 0 times
...
Eden
10 months 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.
upvoted 0 times
...
Tamesha
10 months 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.
upvoted 0 times
...

Save Cancel