parent
91ef014ee5
commit
bd9f8c9a60
@ -0,0 +1,35 @@ |
||||
import sqlite3 from "sqlite3"; |
||||
|
||||
const DATABASE_PATH = "catalogue.db"; |
||||
|
||||
async function getBook(id: number) { |
||||
const database = new sqlite3.Database(DATABASE_PATH, sqlite3.OPEN_READONLY); |
||||
const sql = |
||||
"SELECT isbn, lccn, title, subtitle, authors, edition, publisher, publish_year, publish_month, publish_location, pages, pagination, weight, last_updated, deleted FROM books WHERE id = ? "; |
||||
|
||||
await database.get(sql, [id], (err: Error | null, book: DetailedBook) => { |
||||
if (err) { |
||||
return console.error(err.message); |
||||
} |
||||
console.log(book); |
||||
}); |
||||
|
||||
database.close(); |
||||
} |
||||
|
||||
export interface DetailedBook { |
||||
isbn: string | null; |
||||
lccn: string | null; |
||||
title: string; |
||||
authors: string | null; |
||||
edition: string | null; |
||||
publisher: string | null; |
||||
publish_year: string | null; |
||||
publish_month: string | null; |
||||
publish_location: string | null; |
||||
pages: string | null; |
||||
pagination: string | null; |
||||
weight: string | null; |
||||
last_updated: Date | null; |
||||
deleted: boolean | null; |
||||
} |
Loading…
Reference in new issue