Get All Books API #13
Merged
a258wang
merged 10 commits from feat/api-all-books
into main
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feat/api-all-books'
Deleting a branch is permanent. It CANNOT be undone. 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).
}
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
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.2a308e1f37
into main 1 year agoReviewers
2a308e1f37
.