mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-31 23:19:15 +02:00
🐛 Check for user exists before merging (#1626)
This commit is contained in:
parent
4dbf992055
commit
8a192f74a1
1 changed files with 11 additions and 0 deletions
|
@ -6,6 +6,17 @@ export const mergeGuestsIntoUser = async (
|
||||||
userId: string,
|
userId: string,
|
||||||
guestIds: string[],
|
guestIds: string[],
|
||||||
) => {
|
) => {
|
||||||
|
const count = await prisma.user.count({
|
||||||
|
where: {
|
||||||
|
id: userId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (count === 0) {
|
||||||
|
console.warn(`User ${userId} not found`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await prisma.$transaction(async (tx) => {
|
await prisma.$transaction(async (tx) => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue