Handle books without title, authors, isbn

This commit is contained in:
Amy 2022-02-22 22:07:56 -05:00
parent 337af21679
commit 5d98b8ef8e
2 changed files with 9 additions and 8 deletions

View File

@ -7,7 +7,7 @@ export async function getAllBooks() {
const books = new Promise<SimpleBook[]>((resolve, reject) => {
database.all(
"SELECT title, authors, isbn FROM books",
"SELECT id, title, authors, isbn FROM books WHERE deleted = 0",
(error: Error | null, rows: SimpleBook[]) => {
if (error) {
reject(error);
@ -23,7 +23,8 @@ export async function getAllBooks() {
}
export interface SimpleBook {
authors: string;
isbn: string;
title: string;
id: number;
title: string | null;
authors: string | null;
isbn: string | null;
}

View File

@ -4,15 +4,15 @@ import { getAllBooks, SimpleBook } from "../lib/books";
export default function Home(props: Props) {
return (
<ol>
<ul>
{props.books.map((book, idx) => {
return (
<li key={`${idx}_${book.isbn}`}>
{book.title}; {book.authors}; {book.isbn}
<li key={`${idx}_${book.isbn ?? ""}`}>
{book.id}; {book.title}; {book.authors}; {book.isbn}
</li>
);
})}
</ol>
</ul>
);
}