Skip to content

Conversation

@888i888
Copy link

@888i888 888i888 commented Sep 10, 2025

No description provided.

@yunchen4 yunchen4 self-assigned this Sep 12, 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.

LGTM, only one small point for rework: I didn't see the answer for SQL injection question 1. Please let me know after you fill in the answer.

Comment on lines +1 to +11
function getPopulation(Country, name, code, cb) {
conn.query(
"SELECT Population FROM ?? WHERE Name = ? AND code = ?",
[Country, name, code],
function (err, result) {
if (err) return cb(err);
if (result.length === 0) return cb(new Error("Not found"));
cb(null, result[0].Population);
}
);
}

Choose a reason for hiding this comment

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

Needs rework: I didn't see the answer to question 1 in exercise 3?

Comment on lines +9 to +14
// Deduct from account 101
await conn.execute(`UPDATE account SET balance = balance - 1000 WHERE account_number = 101`);
await conn.execute(
`INSERT INTO account_changes (account_number, amount, remark) VALUES (?, ?, ?)`,
[101, -1000, "Transfer to 102"]
);

Choose a reason for hiding this comment

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

Suggestion: no need to change your implementation for transactions, but it is better to check whether the accounts exist and whether the balance is enough before doing actual transactions.

* It seems an errand episode has gotten into our data.
* This is episode 14 in season 31. Please remove it and verify that it has been removed!
*/
const bobRossCollection = client.db("databaseWeek3").collection("bob_ross_episodes");

Choose a reason for hiding this comment

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

Suggestion: you may notice this line appears multiple times in this file. In this case, you can extract it into another function. You can also have two string constants for "databaseWeek3" and "bob_ross_episodes", so you can reuse those strings and avoid typos in future. And in future if you want to change database name, you don't need to change them one by one.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants