-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Alishka-databases-w4 #38
Conversation
There was a problem hiding this 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
Country: { $first: '$Country' }, | ||
Year: { $first: '$Year' }, | ||
Age: { $first: '$Age' }, | ||
Male: { $sum: '$Male' }, | ||
Female: { $sum: '$Female' }, | ||
TotalPopulation: { $sum: { $add: ['$Male', '$Female'] } } |
There was a problem hiding this comment.
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 } }, |
There was a problem hiding this comment.
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'] } } |
There was a problem hiding this comment.
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
No description provided.