]> git.r.bdr.sh - rbdr/forum/blame - src/lib/stores/forums.ts
Lint, rm unused code
[rbdr/forum] / src / lib / stores / forums.ts
CommitLineData
6ccc6f60 1import { createClient } from '@supabase/supabase-js';
852ee620
RBR
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
6ccc6f60
RBR
9export const forum = (id: string, withTopics = false) =>
10 single<Forum>(
11 client
12 .from('forums')
13 .select(
14 withTopics
15 ? `*,
852ee620
RBR
16 topics (
17 *
18 )
6ccc6f60
RBR
19 `
20 : '*'
21 )
22 .eq('id', id),
23 null
24 );
852ee620 25export const forums = collection<Forum>(client.from('forums').select('*'), []);