mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-03 09:34:48 +02:00
Add basic transactions
This commit is contained in:
parent
c8676ce06a
commit
2f328fc719
22 changed files with 548 additions and 459 deletions
|
@ -118,16 +118,20 @@ export async function acceptInvite(
|
|||
);
|
||||
}
|
||||
|
||||
// add the user to the org
|
||||
await db.insert(userOrgs).values({
|
||||
userId: existingUser[0].userId,
|
||||
orgId: existingInvite[0].orgId,
|
||||
roleId: existingInvite[0].roleId
|
||||
await db.transaction(async (trx) => {
|
||||
// add the user to the org
|
||||
await trx.insert(userOrgs).values({
|
||||
userId: existingUser[0].userId,
|
||||
orgId: existingInvite[0].orgId,
|
||||
roleId: existingInvite[0].roleId
|
||||
});
|
||||
|
||||
// delete the invite
|
||||
await trx
|
||||
.delete(userInvites)
|
||||
.where(eq(userInvites.inviteId, inviteId));
|
||||
});
|
||||
|
||||
// delete the invite
|
||||
await db.delete(userInvites).where(eq(userInvites.inviteId, inviteId));
|
||||
|
||||
|
||||
return response<AcceptInviteResponse>(res, {
|
||||
data: { accepted: true, orgId: existingInvite[0].orgId },
|
||||
success: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue