fix: update akti
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { aktis, ratings } from '$lib/server/db/schema';
|
||||
import { error, redirect, type Actions } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { and, eq } from 'drizzle-orm';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { ensureAuth } from '$lib/auth';
|
||||
import { extractFormData } from '$lib/extractFormData';
|
||||
@@ -56,11 +56,11 @@ export const actions = {
|
||||
|
||||
if (!changeRequest) return error(400);
|
||||
|
||||
const res = await db
|
||||
.insert(aktis)
|
||||
.values({ ...changeRequest, author: user.id, version: akti[0].version + 1 })
|
||||
.returning({ id: aktis.id });
|
||||
await db
|
||||
.update(aktis)
|
||||
.set({ ...changeRequest, version: akti[0].version + 1 })
|
||||
.where(and(eq(aktis.author, user.id), eq(aktis.id, event.params.aktiId)));
|
||||
|
||||
return redirect(303, resolve(`/akti/[aktiId]`, { aktiId: res[0].id }));
|
||||
return redirect(303, resolve(`/akti/[aktiId]`, { aktiId: event.params.aktiId }));
|
||||
}
|
||||
} satisfies Actions;
|
||||
|
||||
Reference in New Issue
Block a user