-
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
Assignment Week4 <Ozlem Karaboga> #33
base: main
Are you sure you want to change the base?
Assignment Week4 <Ozlem Karaboga> #33
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.
Excellent work!
The second aggregation per continent is not working as expected, feel free to ask around
|
||
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.
At the moment this only aggregate per age and year, it is lacking something to also group per continent
const accountsCollection = database.collection("accounts"); | ||
|
||
const session = client.startSession(); | ||
session.startTransaction(); |
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 looks really good, really easy to read.
Another way of doing the exact same thing would be to use withTransaction
I am mentioning it as you might see it in someone else work
@@ -44,11 +45,9 @@ const getContinentInformationByYearAndAge = async (year, age) => { | |||
}, | |||
{ | |||
$addFields: { | |||
TotalPopulation: { $add: ["$M", "$F"] } | |||
TotalPopulation: { $add: ["$M", "$F"] }, | |||
Country: "$Country", |
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 adds the fields to your result but it does not filter or aggregate per continent.
What we are looking for is something that in the end would have one object per continent year and age, lucky for us, the dataset already have those information, At this point you will need to look into the dataset itself to find if you have some data about continents instead of countries (maybe search for Europe and see what it result on)
I would advise, since the data is stored in mongodb to use the power from mongodb and javascript to figure our what the Country field can be and maybe search into it what could be used to have the data per continents
{ Country: { $regex: /^[A-Z]+$/ } }, | ||
{ Country: { $not: { $regex: /world/i } } }] |
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 will work but I will have the same remarks that I had here https://github.com/HackYourAssignment/databases-cohort48/pull/37/files#r1760597771
Thanks for updating your code :) |
No description provided.