diff options
Diffstat (limited to 'src/lib/stores/posts.ts')
| -rw-r--r-- | src/lib/stores/posts.ts | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib/stores/posts.ts b/src/lib/stores/posts.ts index f592dca..388eed3 100644 --- a/src/lib/stores/posts.ts +++ b/src/lib/stores/posts.ts @@ -1,23 +1,24 @@ -import { createClient } from '@supabase/supabase-js' -import { single, collection } from './supabase'; +import { createClient } from '@supabase/supabase-js'; +import { single } 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<Post>(client - .from('posts') - .select(withTopic ? `*, +export const post = (id: string, withTopic = false) => + single<Post>( + client + .from('posts') + .select( + withTopic + ? `*, topic:topic_id ( * ) - `: '*' ) - .eq('id', id), - null); -export const postsForTopic = (id: string) => collection<Post>(client - .from('posts') - .select('*') - .eq('topic_id', id) - .order('created_at', { ascending: true }), - []); + ` + : '*' + ) + .eq('id', id), + null + ); |