-
Notifications
You must be signed in to change notification settings - Fork 6
Hussam-w4-database #27
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
base: main
Are you sure you want to change the base?
Hussam-w4-database #27
Conversation
yunchen4
left a comment
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.
Hi Hussam,
The assignment is very good. Only a small point that needs rework.
Please let me know once you finish the rework. Have a nice weekend!
| async function getInformationOfPopulation(client, year, age) { | ||
| const res = await client | ||
| .db(dbName) | ||
| .collection("population") | ||
| .aggregate([ | ||
| { $addFields: { totalPopulation: { $add: ["$M", "$F"] } } }, | ||
| { $match: { Age: age, Year: year } }, | ||
| ]); | ||
| return res.toArray(); | ||
| } |
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.
Needs rework: The exercise asks about the total population per continent. Please find out how to aggregate this info in the provided data. But I have to say the data provided in this exercise is not very good, as it mixes the continent and countries.
| if (!fromAcc || !toAcc) { | ||
| throw new Error("Account not found"); | ||
| } | ||
| if (fromAcc.balance < amount) { | ||
| throw new Error(`Insufficient funds in account ${fromAccount}`); | ||
| } |
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.
Very good that you check whether the accounts exist and the balance beforehand.
| $group: { | ||
| _id: "$Continent", | ||
| totalPopulation: { $sum: "$totalPopulation" }, | ||
| }, |
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.
Needs rework: Did I miss anything? I didn't see there is a Continent field in the sample data.
yunchen4
left a comment
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.
LGTM
No description provided.