Create guest user in user table when creating a participant

This commit is contained in:
Luke Vella 2024-12-19 15:26:43 +00:00
parent 346ef136f0
commit 65192f95c9
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
5 changed files with 20 additions and 7 deletions

View file

@ -92,9 +92,14 @@ export const participants = router({
const participant = await prisma.participant.create({
data: {
pollId: pollId,
name: name,
email,
locale: user.locale ?? undefined,
poll: {
connect: {
id: pollId,
},
},
user: {
connectOrCreate: {
where: {
@ -102,12 +107,15 @@ export const participants = router({
},
create: {
id: user.id,
isGuest: true,
},
},
},
locale: user.locale ?? undefined,
},
include: {
select: {
id: true,
name: true,
email: true,
poll: {
select: {
id: true,