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 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
20 days 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
Goldie
7 days ago
I agree, SQL is much more straightforward.
upvoted 0 times
...
...
Benton
1 months ago
I believe option A is correct because $slice is used to return a subset of an array.
upvoted 0 times
...
Raul
1 months ago
I'm not sure, but I think option C might also work.
upvoted 0 times
...
Lai
1 months ago
I'm going with Option A. Can't beat the classic $slice approach for array slicing.
upvoted 0 times
Andree
16 days ago
User2: Agreed, $slice is a classic choice for array slicing.
upvoted 0 times
...
Caprice
24 days ago
User1: I think Option A is the way to go.
upvoted 0 times
...
...
Theodora
1 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
2 months ago
I think Option D is the way to go. Specifying the index positions directly seems more straightforward.
upvoted 0 times
Kimbery
5 days ago
Got it, thanks for the clarification!
upvoted 0 times
...
Catalina
6 days 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
7 days ago
So, would Option A be the correct choice then?
upvoted 0 times
...
Ilene
1 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
2 months ago
I agree with Roxanne, option A seems to be the right choice.
upvoted 0 times
...
Roxanne
2 months ago
I think the correct answer is A.
upvoted 0 times
...
Josue
2 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
1 months ago
User 2: I agree, using the $slice operator in the query seems like the right approach.
upvoted 0 times
...
Rosalia
2 months ago
User 1: 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