banana
/
definma-api
Archived
2
Fork 0

Add simple prediction comparison

This commit is contained in:
Kai S. K. Engelbart 2021-02-25 11:33:14 +01:00
parent 3bad5416a8
commit f23f580a25
2 changed files with 10 additions and 1 deletions

View File

@ -2,7 +2,10 @@ import mongoose from 'mongoose';
const PredictionSchema = new mongoose.Schema({
name: String,
name: {
type: String,
unique: true
},
value: Number
});

View File

@ -16,5 +16,11 @@ router.post('/prediction/new', (req, res, next) => {
});
});
router.post('/prediction/compare', async (req, res, next) => {
const valA = (await PredictionModel.findOne({ name: req.body.nameA })).value;
const valB = (await PredictionModel.findOne({ name: req.body.nameB })).value;
res.json(valB - valA);
});
module.exports = router;