Skip to content

Conversation

@hussam-it-max
Copy link

No description provided.

@hussam-it-max hussam-it-max changed the title Assignment-w4-database Hussam-w4-database Sep 16, 2025
@yunchen4 yunchen4 self-assigned this Sep 19, 2025
Copy link

@yunchen4 yunchen4 left a 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!

Comment on lines 21 to 30
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();
}

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.

Comment on lines +28 to +33
if (!fromAcc || !toAcc) {
throw new Error("Account not found");
}
if (fromAcc.balance < amount) {
throw new Error(`Insufficient funds in account ${fromAccount}`);
}

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.

Comment on lines 29 to 32
$group: {
_id: "$Continent",
totalPopulation: { $sum: "$totalPopulation" },
},

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.

Copy link

@yunchen4 yunchen4 left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants