Archived
2

Override existing predictions

This commit is contained in:
Kai S. K. Engelbart 2021-03-09 16:25:50 +01:00
parent dc662046b1
commit f49b18d19b

View File

@ -7,10 +7,10 @@ import PredictionModel from '../models/prediction';
const router = express.Router();
router.post('/prediction/new', (req, res, next) => {
router.post('/prediction/new', async (req, res, next) => {
console.log("New Prediction");
console.log(JSON.stringify(req.body));
new PredictionModel(req.body).save((err, data) => {
await PredictionModel.findOneAndUpdate( { name: req.body.name }, { value: req.body.value }, { upsert: true, new: true }, (err, data) => {
if(err) return next(err);
db.log(req, 'predictions', {_id: data._id}, data.toObject());
});