Get All Books API #13
Loading…
Reference in New Issue
No description provided.
Delete Branch "feat/api-all-books"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #2
This PR implements the getAllBooks function that can be used to get summary information about all the books, in order to display them on the main page.
I'm not sure why I waited so long to create this PR, but I suspect that we were blocked by #11 (which has now been merged).
@ -0,0 +23,4 @@
}
export interface SimpleBook {
authors: string;
There are data rows where authors is NULL, isbn is NULL, and title is NULL. How are we going to handle this?
Good catch! I can think of a couple of ways to handle this:
null
values with empty strings.string | null
, and then accomodate fornull
values appropriately on the "frontend".I don't really like option 1 because:
a) I feel like the
getAllBooks()
function should only be responsible for getting the information from the database, and not for performing additional logic on it.b) Although replacing with an empty string might work for null strings, what would we do for fields that are supposed to be numbers or booleans or another data type?
So I have implemented option 2.
Agreed, I also used this solution
@ -0,0 +24,4 @@
export interface SimpleBook {
authors: string;
isbn: string;
id
is the primary key in the database, do we want that in the interface as well?Ya, I think
id
is worth adding since the permalink for the one book page will probably be based on the ID.