initial commit

This commit is contained in:
Tholut A 2026-08-08 17:55:56 +07:00
commit 7e466e29d2
28 changed files with 17360 additions and 0 deletions

35
utils/todo-repo.ts Normal file
View file

@ -0,0 +1,35 @@
import type { Todo } from "./types"
import type { ExtensionDatabase } from "./database"
export interface TodosRepo {
getAll(): Promise<Todo[]>
getOne(id: string): Promise<Todo | undefined>
insert(input: Todo): Promise<void>
update(input: Todo): Promise<void>
delete(input: Todo): Promise<void>
}
export function createTodosRepo(_db: Promise<ExtensionDatabase>): TodosRepo {
return {
async getAll() {
const db = await _db;
return await db.getAll("todos");
},
async getOne(id) {
const db = await _db;
return await db.get("todos", id);
},
async insert(input) {
const db = await _db;
await db.add("todos", input)
},
async update(input) {
const db = await _db;
await db.put("todos", input)
},
async delete(input) {
const db = await _db;
await db.delete("todos", input.id)
}
}
}