BlackFriday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

MongoDB Exam C100DBA Topic 1 Question 93 Discussion

Actual exam question for MongoDB's C100DBA exam
Question #: 93
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:

Vallie
3 months ago
Shout out to the MongoDB devs for coming up with the $slice operator. Makes our lives so much easier!
upvoted 0 times
Maynard
2 months ago
E) db.c.find( { > , { b : [ 0 , 5 ] > )
upvoted 0 times
...
Lucille
2 months ago
B) db.c.find( { b : [ 0 , 5 ] > )
upvoted 0 times
...
Gail
2 months ago
A) db.c.find( { > , { b : { $slice : [ 0 , 5 ] } } )
upvoted 0 times
...
...
Linsey
3 months ago
Woah, option C with the $substr? That's like using a sledgehammer to crack a nut. Gotta keep it simple, people.
upvoted 0 times
...
Desiree
3 months ago
Haha, I almost went with option D and listed out the entire array. That's a rookie mistake, gotta love the $slice trick!
upvoted 0 times
Walker
3 months ago
Definitely, makes things so much easier.
upvoted 0 times
...
Kenneth
3 months ago
I know right, $slice is a lifesaver!
upvoted 0 times
...
...
Patria
3 months ago
I think Suzan is right. Option A is the best choice for this query.
upvoted 0 times
...
Suzan
3 months ago
I don't think C is correct, Nikita. The $slice operator is used for arrays.
upvoted 0 times
...
Nikita
3 months ago
I'm not sure, but I think it might be C.
upvoted 0 times
...
Tashia
3 months ago
I agree, A is the way to go. Slicing the array is the simplest and most efficient way to get the desired result.
upvoted 0 times
Kimberlie
2 months ago
Definitely, using $slice to get the first five elements is the most efficient option.
upvoted 0 times
...
Benedict
2 months ago
Yeah, A with $slice is the way to go for sure.
upvoted 0 times
...
Micaela
3 months ago
I think A is the correct query to use.
upvoted 0 times
...
...
Patria
4 months ago
I agree with you, Suzan. Option A makes sense.
upvoted 0 times
...
Suzan
4 months ago
I think the correct answer is A.
upvoted 0 times
...
Jeannetta
4 months ago
Option A is the correct answer. The $slice operator in the projection stage allows us to return only the first 5 elements of the 'b' array.
upvoted 0 times
Tabetha
4 months ago
Thanks for clarifying!
upvoted 0 times
...
Kenny
4 months ago
Option A is the correct answer.
upvoted 0 times
...
...

Save Cancel