December 2018
Intermediate to advanced
642 pages
15h 5m
English
Finally, let's do some updates. We will first add a new (invented!) country; we will then check whether it exists; we will update it and check the changes, then we will proceed to delete it, and finally we'll verify that it's gone:
// ...continuedasync function addSeekAndDeleteCountry(dbConn) { try { const code = "42"; const name = "DOUGLASADAMSLAND"; /* 1. Add the new country via a prepared insert statement */ const prepInsert = dbConn.prepare( "INSERT INTO countries (countryCode, countryName) VALUES (:code, :name)" ); const preppedInsert = prepInsert({ code, name }); await dbConn.query(preppedInsert); /* 2. Seek the recently added country, return an array of objects */ const getAdams = `SELECT * FROM countries WHERE ...Read now
Unlock full access