Make recent get more better
This commit is contained in:
@@ -29,14 +29,13 @@ from food
|
||||
order by date desc
|
||||
`)
|
||||
},
|
||||
async GetAllForDate(date: Date) {
|
||||
async GetRecent() {
|
||||
return await db.select<Food[]>(`
|
||||
select ${columns.join(', ')}
|
||||
from foodView
|
||||
where strftime('%Y-%m-%d', date) = strftime('%Y-%m-%d', '2024-06-12')
|
||||
or strftime('%Y-%m-%d', date) = strftime('%Y-%m-%d', date('2024-06-12', '-1 day'))
|
||||
where date > datetime('now', "-48 hours")
|
||||
order by date DESC;
|
||||
`, [date])
|
||||
`)
|
||||
},
|
||||
async Create(food: Food): Promise<[Food, Err]> {
|
||||
if (!food.food) return [food, 'food.food is required']
|
||||
|
@@ -3,7 +3,7 @@ import { type Food, FoodService } from '$lib/database/food'
|
||||
|
||||
|
||||
async function createStore(): Promise<Writable<Food[]>> {
|
||||
const foods = await FoodService.GetAllForDate(new Date())
|
||||
const foods = await FoodService.GetRecent()
|
||||
const { subscribe, update, set } = writable(foods)
|
||||
return {
|
||||
subscribe,
|
||||
|
Reference in New Issue
Block a user