Consider that our posts collection contains an array field called tags that contains tags that the user enters. {

Which of the following commands will find all the posts that have been tagged as tutorial.
Suggested Answer: C
Get Premium C100DBA Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
35 comments · newest first
CI
Ciara
11 months ago
I thought tags were always arrays, so A should work, right?
GA
Gabriele
11 months ago
C is the only one that makes sense here.
IS
Isaiah
11 months ago
I think A looks correct too, but I’m not sure.
EL
Eleonore
11 months ago
Wait, are we sure D is even a valid command?
AR
Armando
12 months ago
Option C is definitely the right choice!
CH
Cherelle
12 months ago
Option B seems off with the syntax, and I don't think `$array` is a valid operator in MongoDB. I’m leaning towards C as well.
VE
Veronika
1 year ago
I'm a bit confused about option A; I feel like it should be using the `$elemMatch` operator or something like that, but I can't recall the exact details.
AD
Adaline
1 year ago
I remember practicing a similar question where we had to find items in an array, and I think using just the tag name like in option C is correct.
WI
Willodean
1 year ago
I think option C looks familiar, but I'm not entirely sure if it’s the right syntax for querying an array.
MA
Ma
1 year ago
I'm not too familiar with MongoDB, so this type of question is a bit tricky for me. I'll have to think through the array syntax carefully and review the options before making a decision.
JU
Judy
1 year ago
Okay, I got this. The key is that the tags field is an array, so we need to use the correct syntax to query for a specific value in the array. I'm pretty sure option C is the right answer here.
BE
Bernadine
1 year ago
Hmm, I'm a bit confused by the array field in the question. I'm not sure if we need to use a special query to search for a value within an array. Maybe I should review the MongoDB array query syntax before answering.
AU
Audria
1 year ago
This looks like a straightforward MongoDB query question. I think the answer is C, since the tags field is an array and we want to find all posts that have the 'tutorial' tag.
GL
Glendora
2 years ago
Wait, 'tutorial' is a tag, not a tutorial. This test is testing my sanity, not my MongoDB skills.
ME
Merissa
1 year ago
Wait, 'tutorial' is a tag, not a tutorial. This test is testing my sanity, not my MongoDB skills.
CY
Cyndy
2 years ago
A) db.posts.find( { tags : [\'tutorial\'] } );
GE
Gerald
2 years ago
B) db.posts.find( { $array : {tags: tutorial}) > is just plain weird. What is this, JavaScript land? I'll stick with good old C).
GI
Gilma
2 years ago
I think D is definitely wrong, it doesn't look like a valid command.
ST
Stefanie
2 years ago
I'm not sure, but C could also be a possibility.
LO
Lorita
2 years ago
D) db.posts.findInArray( { tags : tutorial > ); sounds like it should work, but I've never heard of that command. Is that some secret MongoDB technique?
LU
Luis
2 years ago
A) db.posts.find( { tags : [tutorial] } ); is the way to go. Gotta love that array matching!
JO
Jonell
1 year ago
User2: Thanks for the clarification, I'll keep that in mind for future queries.
NA
Nana
1 year ago
User3: User1 is right, A) is the correct command for finding posts with the 'tutorial' tag.
TY
Tyisha
1 year ago
User2: C) db.posts.find( { tags : 'tutorial' } ); is also a valid option.
FL
Fletcher
2 years ago
User1: A) db.posts.find( { tags : [tutorial] } ); is the way to go. Gotta love that array matching!
LA
Lashon
2 years ago
User2: Thanks for the clarification, I'll keep that in mind for future queries.
JE
Jennie
2 years ago
User3: User1 is right, A) is the correct command for finding posts with the 'tutorial' tag.
TA
Talia
2 years ago
User2: C) db.posts.find( { tags : 'tutorial' } ); is also a valid option.
TI
Timothy
2 years ago
User1: A) db.posts.find( { tags : [tutorial] } ); is the way to go. Gotta love that array matching!
CO
Corrie
2 years ago
I agree with Thea, A seems correct.
MI
Mindy
2 years ago
C) db.posts.find( { tags : tutorial } ); is the correct answer. It's a simple and straightforward way to query for posts with the 'tutorial' tag.
KA
Kassandra
2 years ago
Great, thanks for clarifying!
VE
Veronika
2 years ago
C) db.posts.find( { tags : \'tutorial\' } ); is the correct answer.
ST
Stephane
2 years ago
A) db.posts.find( { tags : [\'tutorial\'] } );
TH
Thea
2 years ago
I think the answer is A.