You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
495 B
TypeScript

import { db } from '$lib/db'
import type { PageServerLoad } from './$types'
export const load = (async (event) => {
const user = event.locals.userObject
const shorteners = await db.query.shortener.findMany({
with: {
visitor: true,
project: true,
},
where: (shortener, { eq, and, isNull }) =>
and(eq(shortener.userId, user.id), isNull(shortener.projectId)),
})
const projects = await db.query.project.findMany()
return { shorteners, projects }
}) satisfies PageServerLoad