fix: replace remaining d1 transactions
This commit is contained in:
@@ -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.');
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user