]>
Commit | Line | Data |
---|---|---|
1 | import { createClient } from '@supabase/supabase-js' | |
2 | import { single, collection } from './supabase'; | |
3 | import { supabase } from '$lib/config/config'; | |
4 | ||
5 | import type { Forum } from '$lib/data/types'; | |
6 | ||
7 | const client = createClient(supabase.url, supabase.key); | |
8 | ||
9 | export const forum = (id: string, withTopics = false) => single<Forum>(client | |
10 | .from('forums') | |
11 | .select(withTopics ? `*, | |
12 | topics ( | |
13 | * | |
14 | ) | |
15 | `: '*' ) | |
16 | .eq('id', id), | |
17 | null); | |
18 | export const forums = collection<Forum>(client.from('forums').select('*'), []); |