From ef7445ab1067fd1a5d07cc649b8b04548f173a4b Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sun, 19 Nov 2023 20:51:29 +0900 Subject: [PATCH] delete --- library.ts | 5 +++-- main.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/library.ts b/library.ts index c8b9270..3b3b5a4 100644 --- a/library.ts +++ b/library.ts @@ -16,8 +16,9 @@ export function createLibrary(db: Database) { readerUrl, platform, ); - - console.log(readerUrl); + }, + async delete(id: number) { + await db.run(`delete from books where id = ?`, id); }, async getBooks(): Promise> { const books: Array = await db.all( diff --git a/main.ts b/main.ts index 5477b24..65f1093 100644 --- a/main.ts +++ b/main.ts @@ -42,6 +42,14 @@ const options = { await library.add(args.values.add!); }, }, + delete: { + type: "string", + async run() { + const db = await createDatabase(args.values.db!); + const library = createLibrary(db); + await library.delete(Number(args.values.delete)); + }, + }, list: { type: "boolean", short: "l",