Story points | 5 |
Tags | node sql |
Hard Prerequisites |
|
You are required to create a back-end service that will help capture basic information about prospective students who come to inquire here at Umuzi.
Before you dive into anything too intense, let’s make sure that you can get node to connect to your database. Can you get this Node script to run:
// npm install --save pg
// find out more here: https://node-postgres.com/
const Pool = require("pg").Pool;
const pool = new Pool({
user: "user",
host: "localhost",
database: "db",
password: "pass",
port: 5432
});
const helloWorld = () => {
pool.query(
"SELECT $1::text as message",
["Hello world!"],
(error, results) => {
if (error) {
throw error;
}
console.log(results.rows);
}
);
};
helloWorld();
Create a single index script with the following functions:
addNewVisitor
. This should save the Visitor into the databaseYou will be expected to properly test your code. You can use whatever testing framework you want. If you use something that isn’t taught at Umuzi please justify your choice (if you found something cool we might incorporate it into the syllabus)