aboutsummaryrefslogtreecommitdiff
path: root/src/lib/stores/forums.ts
blob: 40a3f2cc89d580c0abb8e477926558f9471701a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { createClient } from '@supabase/supabase-js'
import { single, collection } from './supabase';
import { supabase } from '$lib/config/config';

import type { Forum } from '$lib/data/types';

const client = createClient(supabase.url, supabase.key);

export const forum = (id: string, withTopics = false) => single<Forum>(client
  .from('forums')
  .select(withTopics ? `*, 
    topics (
      *
    )
  `: '*' )
  .eq('id', id),
  null);
export const forums = collection<Forum>(client.from('forums').select('*'), []);