add endpoint for retrieving all requested wines

This commit is contained in:
Adrian Thompson
2020-08-31 12:15:22 +02:00
parent d67c1e77bd
commit dd9edf160e
4 changed files with 31 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ 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 RequestedWine = require(path.join(__dirname + "/../schemas/RequestedWine"));
const PreLotteryWine = require(path.join(
__dirname + "/../schemas/PreLotteryWine"
));
@@ -103,6 +104,13 @@ router.route("/highscore/statistics").get(async (req, res) => {
res.json(highscore);
});
router.route("/wines/all-requested-wines").get(async (req, res) => {
const allWines = await RequestedWine.find({}).populate("wine");
res.json(allWines);
});
router.route("/wines/statistics").get(async (req, res) => {
const wines = await Wine.find();

View File