From 85441c0dfe6d73f8aa325677515ae50c22875c25 Mon Sep 17 00:00:00 2001 From: Daniel Kirby Date: Sat, 27 Jun 2026 10:11:32 +0100 Subject: [PATCH] fix: replace remaining d1 transactions --- .../dashboard/clients/[id]/contacts/+page.server.ts | 12 ++++++------ src/routes/dashboard/organizations/+server.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/routes/dashboard/clients/[id]/contacts/+page.server.ts b/src/routes/dashboard/clients/[id]/contacts/+page.server.ts index 5f81c45..ef2f517 100644 --- a/src/routes/dashboard/clients/[id]/contacts/+page.server.ts +++ b/src/routes/dashboard/clients/[id]/contacts/+page.server.ts @@ -157,8 +157,8 @@ export const actions: Actions = { if (contact.isPrimary) return message(form, 'Contact is already primary.'); const now = new Date(); - await db.transaction(async (tx) => { - await tx + await db.batch([ + db .update(contacts) .set({ isPrimary: false, updatedAt: now }) .where( @@ -168,9 +168,9 @@ export const actions: Actions = { eq(contacts.isPrimary, true), isNull(contacts.archivedAt) ) - ); + ), - await tx + db .update(contacts) .set({ isPrimary: true, updatedAt: now }) .where( @@ -180,8 +180,8 @@ export const actions: Actions = { eq(contacts.organizationId, activeOrganizationId), isNull(contacts.archivedAt) ) - ); - }); + ) + ]); return message(form, 'Primary contact updated.'); }, diff --git a/src/routes/dashboard/organizations/+server.ts b/src/routes/dashboard/organizations/+server.ts index 9f2b9be..5723d27 100644 --- a/src/routes/dashboard/organizations/+server.ts +++ b/src/routes/dashboard/organizations/+server.ts @@ -24,8 +24,8 @@ export const POST: RequestHandler = async ({ locals, request }) => { const id = crypto.randomUUID(); const now = new Date(); - await db.transaction(async (tx) => { - await tx.insert(organizations).values({ + await db.batch([ + db.insert(organizations).values({ id, name: parsed.data.name, addressLine1: parsed.data.addressLine1, @@ -43,16 +43,16 @@ export const POST: RequestHandler = async ({ locals, request }) => { bankSwift: parsed.data.bankSwift || null, createdAt: now, updatedAt: now - }); + }), - await tx.insert(organizationMemberships).values({ + db.insert(organizationMemberships).values({ organizationId: id, userId: locals.user.id, role: 'admin', createdAt: now, updatedAt: now - }); - }); + }) + ]); await setActiveOrganization(locals, id);