Writing a Query for MongoDB Shell

Hi, I am a total newbie and do not really know how to write queries. I followed the link in the quiz that takes me to writing the count() function (here) but I am still very lost about how to implement this. You can see from my screenshot that I am just taking stabs in the dark with this. What resource can help me better understand how to write queries? Thank you so much. Screen Shot 2020-09-19 at 1.24.04 PM

Your are missing value for the field you are querying as the error indicates
missing :
Give some value to awards.wins:2 or 4 etc
Same with awards.nominations

Hi @NICOLE_REBENTISCH,

I hope you found @Ramachandra_37567’s response helpful. Please let us know if you are still facing any issues.

~ Shubham

I still do not know how this query works and could use some resources or references that explain the syntax of writing queries. I tried adding :2 as suggested but still get the same error message, so I am unsure of what my syntax should look like. Here’s a screenshot. Thank you.

You are adding 2 at the wrong place. A query document must conform to the JSON syntax. You will find more information on the JSON syntax at https://docs.mongodb.com/manual/core/document/.

For your specific case, the key of the field is awards.nominations and the value is 2.

Thank you so much, I was really stumped and didn’t know what to look for. Now that I know I need to learn JSON syntax I should hopefully do better. I appreciate the link as well!

In case anyone else struggled with this, I figured it out. This is what I used:

db.movieDetails.find({$and:[{“awards.nominations”:2},{“awards.wins”:2}]}).count()

And oh heavens, after I submitted my answer they basically gave the answer away anyway. Feeling kind of stupid but also proud that I figured it out on my own and now hopefully I can do it without being given the answer LOL. My version is different than the one given in the assignment but it worked just fine.

I am in a new course but I can’t seem to post any questions for assistance; when I try I get this error message: “There was an error tagging the topic.” Can you help me?

The above message pops up when I try to ask a question on the forum. I have moved on to the M220JS course and cannot seem to post any questions. What’s happening and what can I do? I can’t progress in the course until I solve the problem but I can’t ask for help! Very frustrated and confused.

Thank you,

Nicole

What process you are following?

Click on +add new topic
Choose appropriate course and add your title/subject then describe your problem and save

Hi @NICOLE_REBENTISCH,

This :point_down:

Let us know if you are still facing any issues.

~ Shubham

That is the process I followed but it was not working. I tried again just now and it is working now. I should have done a video to show you but I am just glad my topic can post now.