more fun functions

This commit is contained in:
Kasper Rynning-Tønnesen
2020-01-24 12:52:51 +01:00
parent 396d5c88d8
commit 20d3b6c4a6
4 changed files with 115 additions and 3 deletions

View File

@@ -9,11 +9,19 @@ mongoose.connect("mongodb://localhost:27017/vinlottis", {
const Purchase = require(path.join(__dirname + "/../schemas/Purchase"));
const Wine = require(path.join(__dirname + "/../schemas/Wine"));
const Highscore = require(path.join(__dirname + "/../schemas/Highscore"));
const PreLotteryWine = require(path.join(
__dirname + "/../schemas/PreLotteryWine"
));
router.use((req, res, next) => {
next();
});
router.route("/wines/prelottery").get(async (req, res) => {
let wines = await PreLotteryWine.find();
res.json(wines);
});
router.route("/purchase/statistics").get(async (req, res) => {
let purchases = await Purchase.find()
.populate("wines")