fixes index filterable attributes & auto trail upload

This commit is contained in:
Christian Beutel
2024-06-07 15:06:32 +02:00
parent ad5a4e668b
commit ccb7a4cd3a
11 changed files with 88 additions and 42 deletions

View File

@@ -3,11 +3,21 @@ import { pb } from '$lib/pocketbase';
import { error, json, type RequestEvent } from '@sveltejs/kit';
export async function GET(event: RequestEvent) {
const filter = event.url.searchParams.get('filter') ?? ""
try {
const r: Comment[] = await pb.collection('comments').getFullList<Comment>({
expand: "author",
sort: "-created",
})
for (const comment of r) {
if(!comment.expand?.author) {
comment.expand = {
author: await pb.collection('users_anonymous').getOne(comment.author)
}
}
}
return json(r)
} catch (e: any) {
throw error(e.status, e);