blob: 1842a4d368ba488152caf8791bb2b3449c2befb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import { createClient } from '@supabase/supabase-js';
import { single, collection } from './supabase';
import { supabase } from '$lib/config/config';
import type { Topic } from '$lib/data/types';
const client = createClient(supabase.url, supabase.key);
export const topic = (id: string, withPosts = false) =>
single<Topic>(
client
.from('topics')
.select(
withPosts
? `*,
forum: forums (*),
tags: topic_tags (*),
posts (
*,
author:author_id (*)
)
`
: '*'
)
.eq('id', id),
null
);
export const topicsForTag = (id: string) =>
collection<Topic>(
client
.from('topics')
.select(
`
*,tags!inner(*)
`
)
.eq('tags.tag', id),
[]
);
|