Simplify cities/regions, and add UPDATE example

This commit is contained in:
fkereki
2018-04-10 10:54:53 -03:00
parent 55f1855e33
commit 831d743e63
3 changed files with 28021 additions and 28011 deletions
+22 -12
View File
@@ -62,14 +62,6 @@ async function addSeekAndDeleteCountry(dbConn) {
const preppedInsert = prepInsert({ code, name });
await dbConn.query(preppedInsert);
/*
1b. Alternative way, with placeholders
await dbConn.query(
"INSERT INTO countries (countryCode, countryName) VALUES (?, ?)",
[code, name]
);
*/
/*
2. Seek the recently added country
*/
@@ -82,15 +74,33 @@ async function addSeekAndDeleteCountry(dbConn) {
);
/*
3. Drop the new country
3. Update the country, but using placeholders
*/
await dbConn.query(
`UPDATE countries SET countryName=? WHERE countryCode=?`,
["NEW NAME", code]
);
/*
4. Check the new data, but returning arrays instead of objects
*/
const adams2 = await dbConn.query(
`SELECT * FROM countries WHERE countryCode=?`,
[code],
{ useArray: true }
);
console.log(adams2.length, adams2[0][0], adams2[0][1]);
/*
5. Drop the new country
*/
await dbConn.query(`DELETE FROM countries WHERE countryCode="42"`);
/*
4. Verify that the country is no more
6. Verify that the country is no more
*/
const adams2 = await dbConn.query(getAdams);
console.log(adams2.length);
const adams3 = await dbConn.query(getAdams);
console.log(adams3.length);
} catch (e) {
console.log("Unexpected error", e);
}
+24039 -24039
View File
File diff suppressed because it is too large Load Diff
+3960 -3960
View File
File diff suppressed because it is too large Load Diff