]>
Commit | Line | Data |
---|---|---|
852ee620 RBR |
1 | import { createClient } from '@supabase/supabase-js' |
2 | import { single, collection } from './supabase'; | |
3 | import { supabase } from '$lib/config/config'; | |
a7cf03c1 | 4 | |
be1ce532 RBR |
5 | import type { Forum } from '$lib/data/types'; |
6 | ||
852ee620 RBR |
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('*'), []); |