mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-09 22:21:49 +02:00
Create guest users when creating a poll or comment
This commit is contained in:
parent
e1677059a6
commit
2cd7d5a581
2 changed files with 17 additions and 2 deletions
|
@ -171,6 +171,7 @@ export const polls = router({
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
id: ctx.user.id,
|
id: ctx.user.id,
|
||||||
|
isGuest: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -39,9 +39,23 @@ export const comments = router({
|
||||||
const newComment = await prisma.comment.create({
|
const newComment = await prisma.comment.create({
|
||||||
data: {
|
data: {
|
||||||
content,
|
content,
|
||||||
pollId,
|
|
||||||
authorName,
|
authorName,
|
||||||
userId: ctx.user.id,
|
poll: {
|
||||||
|
connect: {
|
||||||
|
id: pollId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
connectOrCreate: {
|
||||||
|
where: {
|
||||||
|
id: ctx.user.id,
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
id: ctx.user.id,
|
||||||
|
isGuest: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue