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 91 Discussion

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

Sharen
3 months ago
Personally, I find all this MongoDB syntax a bit of a headache. I prefer good old SQL, where things make sense. *chuckles*
upvoted 0 times
Latanya
2 months ago
Yeah, that looks like the correct query to return the first five elements of the array.
upvoted 0 times
...
Ayesha
2 months ago
I think the answer is A) db.c.find( { > , { b : { $slice : [ 0 , 5 ] } } )
upvoted 0 times
...
Goldie
3 months ago
I agree, SQL is much more straightforward.
upvoted 0 times
...
...
Benton
4 months ago
I believe option A is correct because $slice is used to return a subset of an array.
upvoted 0 times
...
Raul
4 months ago
I'm not sure, but I think option C might also work.
upvoted 0 times
...
Lai
4 months ago
I'm going with Option A. Can't beat the classic $slice approach for array slicing.
upvoted 0 times
Andree
3 months ago
Agreed, $slice is a classic choice for array slicing.
upvoted 0 times
...
Caprice
4 months ago
I think Option A is the way to go.
upvoted 0 times
...
...
Theodora
4 months ago
Haha, Option B is just silly. Who would use an array of indexes like that? Option A is clearly the correct choice.
upvoted 0 times
...
Nakita
4 months ago
I think Option D is the way to go. Specifying the index positions directly seems more straightforward.
upvoted 0 times
Kimbery
3 months ago
Got it, thanks for the clarification!
upvoted 0 times
...
Catalina
3 months ago
Yes, Option A is correct. It uses the $slice operator to return the first five elements of the array in the 'b' field.
upvoted 0 times
...
Erasmo
3 months ago
So, would Option A be the correct choice then?
upvoted 0 times
...
Ilene
4 months ago
Option D is incorrect. You need to use the $slice operator to return only the first five elements of the array.
upvoted 0 times
...
...
Belen
4 months ago
I agree with Roxanne, option A seems to be the right choice.
upvoted 0 times
...
Roxanne
4 months ago
I think the correct answer is A.
upvoted 0 times
...
Josue
5 months ago
Option A looks good to me. The $slice operator should do the trick to get the first 5 elements of the array.
upvoted 0 times
Whitney
4 months ago
I agree, using the $slice operator in the query seems like the right approach.
upvoted 0 times
...
Rosalia
4 months ago
Option A looks good to me. The $slice operator should do the trick to get the first 5 elements of the array.
upvoted 0 times
...
...

Save Cancel