import { type Writable, writable } from 'svelte/store' import { type AggregatedWeight, WeightService } from '$lib/database/weight' import { FoodService } from '$lib/database/food' async function createStore(): Promise> { let [rows, err] = await WeightService.GetDaily() if (err) { rows = [] console.error(err) } const { subscribe, update, set } = writable(rows) return { subscribe, update, set, // @ts-ignore refresh: async () => { const rows = await WeightService.GetDaily() set(rows[0]) } } } export const dailyWeightStore = await createStore()