Handle books without title, authors, isbn

pull/13/head
Amy 1 year ago
parent 337af21679
commit 5d98b8ef8e
  1. 9
      lib/books.ts
  2. 8
      pages/index.tsx

@ -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;
}

@ -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>
);
}

Loading…
Cancel
Save