Implement model

This commit is contained in:
2024-06-11 21:59:51 +02:00
parent 54eed02ddd
commit babeed7c53
3 changed files with 41 additions and 33 deletions

18
src/lib/database/food.ts Normal file
View File

@@ -0,0 +1,18 @@
import { db } from '$lib/database'
export type Food = {
rowid: number,
food: string,
amount: number,
per100: number,
energy: number,
}
const FoodService = {
async GetAll() {
return await db.select<Food[]>('SELECT rowid, food, amount, per100, energy FROM food ORDER BY date DESC')
},
async SetAll(data: Food[]) {}
}
export {FoodService}

View File

@@ -0,0 +1,3 @@
import Database from 'tauri-plugin-sql-api'
export const db = await Database.load('sqlite:food.db')