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

LidiiaStarshynova-w4-Databases #27

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

starshynova
Copy link

No description provided.

@yunchen4 yunchen4 self-assigned this Jan 24, 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 Lidiia,
Your assignment looks good to me. There is only one small comment that you need to rework.
Please let me know once you finish the rework. Have a good weekend!

Comment on lines 17 to 31
const yearAgePopulation = await collection.aggregate([
{$match: {Year: year, Age: age}},
{$addFields: {
TotalPopulation: { $add: ["$M", "$F"] },
}},
{
$project: {
Country: 1,
Year: 1,
Age: 1,
M: 1,
F: 1,
TotalPopulation: 1,
},}
]).toArray()

Choose a reason for hiding this comment

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

Need to work: the question asks about the total population of each continent. If you take a look at data you may notice in column Country there are AFRICA, ASIA etc separating from the real countries. Try to use those continent name values in the country column.

Comment on lines +27 to +40
const destinationAccountDoc = await collection.findOne({ account_number: destinationAccount.accountNumber },
{ session });

const maxChangeNumberSource = sourceAccountDoc.account_changes.length > 0
? Math.max(...sourceAccountDoc.account_changes.map(change => change.change_number))
: 0;

const maxChangeNumberDestination = destinationAccountDoc.account_changes.length > 0
? Math.max(...destinationAccountDoc.account_changes.map(change => change.change_number))
: 0;

if (!sourceAccountDoc || sourceAccountDoc.balance < transferAmount) {
throw new Error("There is not enough money to execute the operation.");
}

Choose a reason for hiding this comment

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

Very good check before doing actual transfer!

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