-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: main
Are you sure you want to change the base?
LidiiaStarshynova-w4-Databases #27
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.
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!
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() |
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.
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.
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."); | ||
} |
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 check before doing actual transfer!
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.