mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 01:55:10 +02:00
Add basic transactions
This commit is contained in:
parent
c8676ce06a
commit
2f328fc719
22 changed files with 548 additions and 459 deletions
|
@ -98,15 +98,17 @@ export async function deleteRole(
|
|||
);
|
||||
}
|
||||
|
||||
// move all users from the userOrgs table with roleId to newRoleId
|
||||
await db
|
||||
.update(userOrgs)
|
||||
.set({ roleId: newRoleId })
|
||||
.where(eq(userOrgs.roleId, roleId));
|
||||
|
||||
// delete the old role
|
||||
await db.delete(roles).where(eq(roles.roleId, roleId));
|
||||
await db.transaction(async (trx) => {
|
||||
// move all users from the userOrgs table with roleId to newRoleId
|
||||
await trx
|
||||
.update(userOrgs)
|
||||
.set({ roleId: newRoleId })
|
||||
.where(eq(userOrgs.roleId, roleId));
|
||||
|
||||
// delete the old role
|
||||
await trx.delete(roles).where(eq(roles.roleId, roleId));
|
||||
});
|
||||
|
||||
return response(res, {
|
||||
data: null,
|
||||
success: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue