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 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
6 days ago
Shout out to the MongoDB devs for coming up with the $slice operator. Makes our lives so much easier!
upvoted 0 times
...
Linsey
13 days 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
14 days 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
Kenneth
1 days ago
User 1: I know right, $slice is a lifesaver!
upvoted 0 times
...
...
Patria
16 days ago
I think Suzan is right. Option A is the best choice for this query.
upvoted 0 times
...
Suzan
17 days ago
I don't think C is correct, Nikita. The $slice operator is used for arrays.
upvoted 0 times
...
Nikita
18 days ago
I'm not sure, but I think it might be C.
upvoted 0 times
...
Tashia
21 days 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
Micaela
12 days ago
User 1: I think A is the correct query to use.
upvoted 0 times
...
...
Patria
28 days ago
I agree with you, Suzan. Option A makes sense.
upvoted 0 times
...
Suzan
1 months ago
I think the correct answer is A.
upvoted 0 times
...
Jeannetta
1 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
25 days ago
User 2: Thanks for clarifying!
upvoted 0 times
...
Kenny
1 months ago
User 1: Option A is the correct answer.
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