PR feedback
This commit is contained in:
parent
955c906f4e
commit
0414c01776
13
lib/books.ts
13
lib/books.ts
|
@ -6,7 +6,7 @@ export async function getBook(id: number): Promise<DetailedBook> {
|
||||||
const database = new sqlite3.Database(DATABASE_PATH, sqlite3.OPEN_READONLY);
|
const database = new sqlite3.Database(DATABASE_PATH, sqlite3.OPEN_READONLY);
|
||||||
|
|
||||||
const sql =
|
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 = ? ";
|
"SELECT isbn, lccn, title, subtitle, authors, edition, publisher, publish_year, publish_month, publish_location, pages, pagination, weight, last_updated, deleted FROM books WHERE id = ? AND deleted = 0";
|
||||||
|
|
||||||
const book: Promise<DetailedBook> = new Promise((resolve, reject) => {
|
const book: Promise<DetailedBook> = new Promise((resolve, reject) => {
|
||||||
database.get(sql, [id], (err: Error | null, book: DetailedBook) => {
|
database.get(sql, [id], (err: Error | null, book: DetailedBook) => {
|
||||||
|
@ -20,17 +20,6 @@ export async function getBook(id: number): Promise<DetailedBook> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// .then((newBook) => {
|
|
||||||
// book = new Promise((resolve) => {
|
|
||||||
// resolve(newBook);
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// console.error(err);
|
|
||||||
// })
|
|
||||||
// .finally(() => {
|
|
||||||
// database.close();
|
|
||||||
// });
|
|
||||||
|
|
||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ interface Props {
|
||||||
export async function getServerSideProps() {
|
export async function getServerSideProps() {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
book: await getBook(2),
|
book: await getBook(44),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue