fixes index filterable attributes & auto trail upload
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user