Handle books without title, authors, isbn
This commit is contained in:
parent
337af21679
commit
5d98b8ef8e
|
@ -7,7 +7,7 @@ export async function getAllBooks() {
|
||||||
|
|
||||||
const books = new Promise<SimpleBook[]>((resolve, reject) => {
|
const books = new Promise<SimpleBook[]>((resolve, reject) => {
|
||||||
database.all(
|
database.all(
|
||||||
"SELECT title, authors, isbn FROM books",
|
"SELECT id, title, authors, isbn FROM books WHERE deleted = 0",
|
||||||
(error: Error | null, rows: SimpleBook[]) => {
|
(error: Error | null, rows: SimpleBook[]) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
@ -23,7 +23,8 @@ export async function getAllBooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SimpleBook {
|
export interface SimpleBook {
|
||||||
authors: string;
|
id: number;
|
||||||
isbn: string;
|
title: string | null;
|
||||||
title: string;
|
authors: string | null;
|
||||||
|
isbn: string | null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,15 @@ import { getAllBooks, SimpleBook } from "../lib/books";
|
||||||
|
|
||||||
export default function Home(props: Props) {
|
export default function Home(props: Props) {
|
||||||
return (
|
return (
|
||||||
<ol>
|
<ul>
|
||||||
{props.books.map((book, idx) => {
|
{props.books.map((book, idx) => {
|
||||||
return (
|
return (
|
||||||
<li key={`${idx}_${book.isbn}`}>
|
<li key={`${idx}_${book.isbn ?? ""}`}>
|
||||||
{book.title}; {book.authors}; {book.isbn}
|
{book.id}; {book.title}; {book.authors}; {book.isbn}
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ol>
|
</ul>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue