Server-Side Scripting/Key-Value Databases/Node.js (Express)

routes/lesson11.js
";   return result; }

async function getCountries { try { keys = await client.keys("*"); return keys; } catch (error) { console.log(error); return error; } }

async function getCountry(country) { try { const value = await client.get(country); return value; } catch (error) { console.log(error); return error; } }

async function countryExists(country) { try { const exists = await client.exists(country); return exists; } catch (error) { console.log(error); return error; } }

async function insertCountry(country, temperature) { try { await client.set(country, temperature); } catch (error) { console.log(error); return error; } }

async function updateCountry(country, temperature) { try { await client.set(country, temperature); } catch (error) { console.log(error); return error; } }

async function deleteCountry(country) { try { await client.del(country); } catch (error) { console.log(error); return error; } }

module.exports = router;

Try It
See ../../Routes and Templates/Node.js (Express) to create a test environment.