mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-03 08:28:35 +02:00
Reset legacy poll
This commit is contained in:
parent
e830d0b0f4
commit
08f2524869
3 changed files with 25 additions and 10 deletions
|
@ -46,13 +46,7 @@ export default async function handler(
|
|||
res: NextApiResponse<GetPollApiResponse>,
|
||||
) {
|
||||
const urlId = getQueryParam(req, "urlId");
|
||||
|
||||
const existingPoll = await prisma.poll.findUnique({ where: { urlId } });
|
||||
|
||||
if (existingPoll) {
|
||||
// if the poll already exists with this id then we probably shouldn't be here
|
||||
return res.status(400).end();
|
||||
}
|
||||
const reset = req.query.reset;
|
||||
|
||||
const client = await getMongoClient();
|
||||
if (!client) {
|
||||
|
@ -105,6 +99,10 @@ export default async function handler(
|
|||
});
|
||||
});
|
||||
|
||||
if (reset) {
|
||||
await prisma.poll.delete({ where: { urlId: legacyPoll._id } });
|
||||
}
|
||||
|
||||
const poll = await prisma.poll.create({
|
||||
data: {
|
||||
legacy: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue