]> git.r.bdr.sh - rbdr/forum/blame - src/lib/stores/forums.ts
Use supabase
[rbdr/forum] / src / lib / stores / forums.ts
CommitLineData
852ee620
RBR
1import { createClient } from '@supabase/supabase-js'
2import { single, collection } from './supabase';
3import { supabase } from '$lib/config/config';
a7cf03c1 4
be1ce532
RBR
5import type { Forum } from '$lib/data/types';
6
852ee620
RBR
7const client = createClient(supabase.url, supabase.key);
8
9export 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);
18export const forums = collection<Forum>(client.from('forums').select('*'), []);