Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alishka-databases-w4 #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Alishka-Space
Copy link

No description provided.

@sarlam sarlam self-assigned this Sep 1, 2024
Copy link

@sarlam sarlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the few mistakes on the field of your objects and the continent aggregation, the code looks neat

It is missing the second exercises for this week on how to do a transaction using MongoDB

Comment on lines +44 to +49
Country: { $first: '$Country' },
Year: { $first: '$Year' },
Age: { $first: '$Age' },
Male: { $sum: '$Male' },
Female: { $sum: '$Female' },
TotalPopulation: { $sum: { $add: ['$Male', '$Female'] } }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are only looking for the total population, the rest should not be here as a group.

In addition, when you parse the CSV in importData.js and add it into your database you add the field M and F but no Male nor Female field.

const collection = db.collection('populationData');

const result = await collection.aggregate([
{ $match: { Year: year, Age: age } },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query do not filter on the Country field, we would like to only see the continent

{
$group: {
_id: '$Year',
countPopulation: { $sum: { $add: ['$Male', '$Female'] } }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to importData.js you add the field M and F to your object but not Male nor Female

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants