statistics lol

This commit is contained in:
Flummi 2018-02-19 18:28:06 +01:00
parent 85becbb8a4
commit 26be5bf757

View File

@ -1,5 +1,11 @@
import express from "express";
import db from "../../lib/sql";
const queries = {
statistic: "select count(*) as sum from `pastes`"
};
export default express.Router()
.get("/", (req, res) => {
res.render("about");
@ -11,5 +17,8 @@ export default express.Router()
res.render("contact");
})
.get("/statistics", (req, res) => {
res.render("statistics");
db.exec(queries.statistic).then(rows => {
const r = rows[0];
res.render("statistics", { pastes: r.sum });
}).catch(err => console.log(err));
});