import { createClient } from '@supabase/supabase-js' import { single, collection } from './supabase'; import { supabase } from '$lib/config/config'; import type { Post } from '$lib/data/types'; const client = createClient(supabase.url, supabase.key); export const post = (id: string, withTopic = false) => single(client .from('posts') .select(withTopic ? `*, topic:topic_id ( * ) `: '*' ) .eq('id', id), null); export const postsForTopic = (id: string) => collection(client .from('posts') .select('*') .eq('topic_id', id) .order('created_at', { ascending: true }), []);