]> git.r.bdr.sh - rbdr/forum/blobdiff - src/lib/stores/supabase.ts
Don't remember what this WIP was about
[rbdr/forum] / src / lib / stores / supabase.ts
index 804141f903e8ce8d4e8e3231ab15e6a2cc4d4f21..5bcd941d14b2cbc0e053fc907fab4f40996c7be8 100644 (file)
@@ -5,34 +5,36 @@ import type { Readable } from 'svelte/store';
 import type { PostgrestFilterBuilder } from '@supabase/postgrest-js';
 import type { StoreState } from './response_builder';
 
-export function collection<T> (query: PostgrestFilterBuilder<T>, initialValue: T[]): Readable<StoreState<T[]>> {
-
-  return readable(initialResponse<T[]>(initialValue), (set) => {
-
-    (async function() {
-      const { data, error } = await query;
-
-      if (error) {
-        return set(errorResponse<T[]>(error));
-      }
-
-      set(response<T[]>(data));
-    })()
-  });
+export function collection<T>(
+       query: PostgrestFilterBuilder<T>,
+       initialValue: T[]
+): Readable<StoreState<T[]>> {
+       return readable(initialResponse<T[]>(initialValue), (set) => {
+               (async function () {
+                       const { data, error } = await query;
+
+                       if (error) {
+                               return set(errorResponse<T[]>(error));
+                       }
+
+                       set(response<T[]>(data));
+               })();
+       });
 }
 
-export function single<T> (query: PostgrestFilterBuilder<T>, initialValue: T): Readable<StoreState<T>> {
-
-  return readable(initialResponse<T>(initialValue), (set) => {
-
-    (async function() {
-      const { data, error } = await query.single();
-
-      if (error) {
-        return set(errorResponse<T>(error));
-      }
-
-      set(response<T>(data));
-    })()
-  });
+export function single<T>(
+       query: PostgrestFilterBuilder<T>,
+       initialValue: T
+): Readable<StoreState<T>> {
+       return readable(initialResponse<T>(initialValue), (set) => {
+               (async function () {
+                       const { data, error } = await query.single();
+
+                       if (error) {
+                               return set(errorResponse<T>(error));
+                       }
+
+                       set(response<T>(data));
+               })();
+       });
 }