- Gigi (catMaster24) 🐱
- Georgia (cruiseVoyager25) 🚢
- Sarah (glansFromFrance) 🇫🇷
- Gregor (beardedWizard) ✨
A brave warrior enters their name and some personality traits and is returned the name of the glan they belong to. Glans are calculated based upon personality and each has a unique character.
The user feels a sense of accomplishment being grouped with others into a glanourous glan! Hoorah!
![](https://i.imgur.com/ptPwdaX.jpg =300x360)
- How to build an SQL DB
- How to create a new alias within an SQL query
const getSum = cb => {
databaseConnection.query(
`SELECT glans.glan_name, total.warrior_name FROM glans INNER JOIN (SELECT warrior_name, (warrior_c1 + warrior_c2 + warrior_c3 + 1) AS warrior_total FROM warriors) AS total ON glans.glan_id = total.warrior_total;`
),
- How to return the results in a new table
- Testing the router
- How to join two tables based upon the sum
- (C1+C2+C3+1)
![](https://i.imgur.com/vct9VDR.jpg =600x400)
Splitter:
let getGlan = document.getElementById("getGlan");
getGlan.onclick = function() {
domRequest("/getGlan");
};
} else if(endpoint.startsWith("/getGlan")) {
getGlan(req, res);
let getGlan = (req, res) => {
getData.getSum((error, result) => {
if (error) {
console.log("500, Get data error", error);
res.writeHead(500, "Content-Type:text/html");
res.end("<h1>Sorry, there was a problem getting the users<h1>");
} else {
res.writeHead(200, { "Content-Type": "application:json" });
res.end(JSON.stringify(result));
}
});
};
const getSum = cb => {
databaseConnection.query(`SELECT glans.glan_name, total.warrior_name
FROM glans
INNER JOIN (SELECT warrior_name, (warrior_c1 + warrior_c2 + warrior_c3 + 1)
AS warrior_total FROM warriors)
AS total ON glans.glan_id = total.warrior_total;`, (err, res) => {
if (err) return cb(err);
cb(null, res.rows);
});
};
- Understanding what our goals were, what was involved in the project, agreeing on what the project should contain.
- Understanding Get/Post to the DB
- Did not prevent script injections but looked at FAC16's code and found you can use a $ so that you can use a variable name instead. It was very interesting to learn about.
- Testing the DB