API: seznam dnevnih receptov
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { db } from "./db";
|
||||
import { dailyRecipes } from "@shared/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { eq, desc } from "drizzle-orm";
|
||||
|
||||
function todayStr(): string {
|
||||
const d = new Date();
|
||||
@@ -37,3 +37,7 @@ export async function upsertRecipe(data: {
|
||||
const [row] = await db.insert(dailyRecipes).values(values).returning();
|
||||
return row;
|
||||
}
|
||||
|
||||
export async function listRecipes(limit = 200): Promise<any[]> {
|
||||
return await db.select().from(dailyRecipes).orderBy(desc(dailyRecipes.dateStr)).limit(limit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user