Create guest users when creating a poll or comment

This commit is contained in:
Luke Vella 2024-12-19 15:44:24 +00:00
parent e1677059a6
commit 2cd7d5a581
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
2 changed files with 17 additions and 2 deletions

View file

@ -171,6 +171,7 @@ export const polls = router({
},
create: {
id: ctx.user.id,
isGuest: true,
},
},
},

View file

@ -39,9 +39,23 @@ export const comments = router({
const newComment = await prisma.comment.create({
data: {
content,
pollId,
authorName,
userId: ctx.user.id,
poll: {
connect: {
id: pollId,
},
},
user: {
connectOrCreate: {
where: {
id: ctx.user.id,
},
create: {
id: ctx.user.id,
isGuest: true,
},
},
},
},
select: {
id: true,