diff --git a/client/src/db/crud/timerCrud.ts b/client/src/db/crud/timerCrud.ts index 43b8535..a0170e8 100644 --- a/client/src/db/crud/timerCrud.ts +++ b/client/src/db/crud/timerCrud.ts @@ -1,6 +1,6 @@ import { getDb } from "@/db/initDb"; -import { SELECT_TIMERS } from "@/db/dml/timerDML"; -import { TimersRow } from "@/types/timerType" +import { SELECT_TIMERS, SELECT_TIMER } from "@/db/dml/timerDML"; +import { TimersRow, TimerRow } from "@/types/timerType"; /** Получает список таймеров */ @@ -8,3 +8,9 @@ export async function getTimers(): Promise { const db = await getDb(); return await db.select(SELECT_TIMERS); } + +/* Получает таймер по его id **/ +export async function getTimer(TimerId: number): Promise { + const db = await getDb(); + return await db.select(SELECT_TIMER, [TimerId]); +} diff --git a/client/src/db/dml/timerDML.ts b/client/src/db/dml/timerDML.ts index f1f4414..95f4014 100644 --- a/client/src/db/dml/timerDML.ts +++ b/client/src/db/dml/timerDML.ts @@ -4,3 +4,4 @@ export const INSERT_SEED_DB = ` INSERT INTO timer (title, pomodoro_time, break_time, break_long_time, count_pomodoro) VALUES ('Timer mini example', 10, 3, 15, 2), ('Timer max example', 90, 10, 40, 8) ` +export const SELECT_TIMER = 'SELECT * FROM timer WHERE id = ?'