Parallelize Database Queries #19

Merged
schreifuchs merged 1 commits from issue-5 into main 2026-04-03 13:42:19 +02:00
+10 -9
View File
@@ -9,15 +9,16 @@ import * as v from 'valibot';
import { resolve } from '$app/paths';
export const load: PageServerLoad = async (event) => {
const akti = await db.query.aktis.findFirst({
where: eq(aktis.id, event.params.aktiId),
with: { author: true }
});
const r = await db.query.ratings.findMany({
with: { user: true },
where: eq(ratings.aktiId, event.params.aktiId)
});
const [akti, r] = await Promise.all([
db.query.aktis.findFirst({
where: eq(aktis.id, event.params.aktiId),
with: { author: true }
}),
db.query.ratings.findMany({
with: { user: true },
where: eq(ratings.aktiId, event.params.aktiId)
})
]);
if (!akti) {
error(404, { message: 'Die Akti gits garnid, sorry...' });