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