MongoDB Query return true and false

Information about all the users on our app.

   "calories_per_day":1800, // Maximum calorie per day as set by user.

Information about the meals added by different users in our app. A user can add as many meals as he wants in a day. Each meal item will have the following info

   "datetime":"2020-12-20T16:00:00Z", // Date and time when the meal was consumed.
   "food_name":"pasta", // Name of food.
   "calorie":300, // Calorie contained in the food.
   "description":"Red Sauce Pasta",
   "_id":"123", // Unique Id for the entry, this could be the object ID (_id field) of mongoDB
   "username": "bhaveshs" // User for which the entry is added.

Steps to solve for this assignment:
. Based on your design, populate your database with 5 dummy users and 30 dummy meals (6 for each user).
. For each query to support, submit your response in the following format.
QUERIE to solve:

  1. Write a query which for a specific user (bhaveshs) for a specific date (2020-12-20), returns true if he has exceeded his daily limit and false otherwise (i.e true if sum of calories of all meals on that day > calories_per_day).

I need help to solve this, how to solve this query?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.