diff options
| author | Fuwn <[email protected]> | 2024-07-25 00:19:44 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-07-25 00:20:23 -0700 |
| commit | 2d9235070856c0a5032ddf47f7b1dc7cc5cceb60 (patch) | |
| tree | 4677f0355872a0f7f55d38a372ec5e3870771182 /src/lib/Database/Supabase/groups.ts | |
| parent | feat(notifications): allow unsubscribe (diff) | |
| download | due.moe-2d9235070856c0a5032ddf47f7b1dc7cc5cceb60.tar.xz due.moe-2d9235070856c0a5032ddf47f7b1dc7cc5cceb60.zip | |
refactor(Database): separate providers
Diffstat (limited to 'src/lib/Database/Supabase/groups.ts')
| -rw-r--r-- | src/lib/Database/Supabase/groups.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/Database/Supabase/groups.ts b/src/lib/Database/Supabase/groups.ts new file mode 100644 index 00000000..b2770e4a --- /dev/null +++ b/src/lib/Database/Supabase/groups.ts @@ -0,0 +1,32 @@ +import supabase from '../supabase'; + +export interface Group { + id: number; + created_at: string; + updated_at?: string; + members: number[]; + avatar: string; + banner: string; + description?: string; + name: string; + anilist_id: number; + anilist_username: string; + badge?: string; + badge_description?: string; +} + +export const getGroups = async () => { + const { data, error } = await supabase.from('groups').select('*'); + + if (error) return []; + + return data as Group[]; +}; + +export const getGroup = async (slug: string) => { + const { data, error } = await supabase.from('groups').select('*').eq('anilist_username', slug); + + if (error || data.length === 0) return null; + + return data[0] as Group; +}; |