Cyber Monday 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
4 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
3 months ago
Yeah, that looks like the correct query to return the first five elements of the array.
upvoted 0 times
...
Ayesha
3 months ago
I think the answer is A) db.c.find( { > , { b : { $slice : [ 0 , 5 ] } } )
upvoted 0 times
...
Goldie
4 months ago
I agree, SQL is much more straightforward.
upvoted 0 times
...
...
Benton
5 months ago
I believe option A is correct because $slice is used to return a subset of an array.
upvoted 0 times
...
Raul
5 months ago
I'm not sure, but I think option C might also work.
upvoted 0 times
...
Lai
5 months ago
I'm going with Option A. Can't beat the classic $slice approach for array slicing.
upvoted 0 times
Andree
4 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
5 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
5 months ago
I think Option D is the way to go. Specifying the index positions directly seems more straightforward.
upvoted 0 times
Kimbery
4 months ago
Got it, thanks for the clarification!
upvoted 0 times
...
Catalina
4 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
4 months ago
So, would Option A be the correct choice then?
upvoted 0 times
...
Ilene
5 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
5 months ago
I agree with Roxanne, option A seems to be the right choice.
upvoted 0 times
...
Roxanne
5 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
5 months ago
I agree, using the $slice operator in the query seems like the right approach.
upvoted 0 times
...
Rosalia
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
...
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77