F1Manager-Calc/pages/api/report_vals.js

18 lines
512 B
JavaScript
Raw Normal View History

2023-04-13 10:01:20 +02:00
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2023-04-18 07:40:11 +02:00
import {databasePromise} from "../../libs/cloud/mongodb";
2023-04-13 10:01:20 +02:00
2023-04-21 06:59:37 +02:00
export const handler = async (req, res) => {
2023-04-13 10:01:20 +02:00
let db = await databasePromise;
const { uid, track, values } = req.body;
await db.collection('values').updateOne(
{ track },
{
$inc: { [`feedback_cnt`]: 1 },
$push: { [`values`]: {uid, track, values} },
},
{ upsert: true },
);
res.status(200).json({status: "ok"});
2023-04-21 06:59:37 +02:00
};
export default handler;