Parallelize Database Queries #19
@@ -9,15 +9,16 @@ import * as v from 'valibot';
|
|||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
|
|
||||||
export const load: PageServerLoad = async (event) => {
|
export const load: PageServerLoad = async (event) => {
|
||||||
const akti = await db.query.aktis.findFirst({
|
const [akti, r] = await Promise.all([
|
||||||
|
db.query.aktis.findFirst({
|
||||||
where: eq(aktis.id, event.params.aktiId),
|
where: eq(aktis.id, event.params.aktiId),
|
||||||
with: { author: true }
|
with: { author: true }
|
||||||
});
|
}),
|
||||||
|
db.query.ratings.findMany({
|
||||||
const r = await db.query.ratings.findMany({
|
|
||||||
with: { user: true },
|
with: { user: true },
|
||||||
where: eq(ratings.aktiId, event.params.aktiId)
|
where: eq(ratings.aktiId, event.params.aktiId)
|
||||||
});
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
if (!akti) {
|
if (!akti) {
|
||||||
error(404, { message: 'Die Akti gits garnid, sorry...' });
|
error(404, { message: 'Die Akti gits garnid, sorry...' });
|
||||||
|
|||||||
Reference in New Issue
Block a user