]> git.r.bdr.sh - rbdr/forum/blame - src/lib/stores/posts.ts
Don't remember what this WIP was about
[rbdr/forum] / src / lib / stores / posts.ts
CommitLineData
6ccc6f60
RBR
1import { createClient } from '@supabase/supabase-js';
2import { single } from './supabase';
852ee620 3import { supabase } from '$lib/config/config';
a7cf03c1 4
be1ce532
RBR
5import type { Post } from '$lib/data/types';
6
852ee620
RBR
7const client = createClient(supabase.url, supabase.key);
8
6ccc6f60
RBR
9export const post = (id: string, withTopic = false) =>
10 single<Post>(
11 client
12 .from('posts')
13 .select(
14 withTopic
15 ? `*,
852ee620
RBR
16 topic:topic_id (
17 *
18 )
6ccc6f60
RBR
19 `
20 : '*'
21 )
22 .eq('id', id),
23 null
24 );