Conversation
…d at the same time.
…onents, created new components, and added a favicon.
…to development
…getting a single book by id but frontend needs a new utility to get a single book.
…n the front end trying to reach the update page.
…te route for each book.
Feature: CRUD operation update merge into development branch
…le/db but doesn't refresh the page after deletion.
Merging the delete feature from feature-delete into development
Development branch merge into main
| const HOST = "0.0.0.0"; | ||
|
|
||
| const book = await BookSchema.findAll(); | ||
| console.log(book); |
There was a problem hiding this comment.
Console log not needed here.
There was a problem hiding this comment.
forgot to take this out, used to confirm there was a book
|
|
||
| app.use("/", router); | ||
|
|
||
| BookSchema.create({ |
There was a problem hiding this comment.
Interacting with database in index file doesn't make a lot of sense. If database needs to be seeded it should be in separate file.
There was a problem hiding this comment.
I left this in there to see the database be built out and show information in there, can take out as it is not needed
| const { books, loading, error, refetch } = FetchBooks(); | ||
| const router = useRouter(); | ||
|
|
||
| const handleDelete = async (id) => { |
There was a problem hiding this comment.
Why are fetch calls in separate utilities folder but update and delete are directly in components/pages.
There was a problem hiding this comment.
Delete and update are in the page.jsx for the table to re-render it after either deleting or updating a book.
| return ( | ||
| <section className="center-wrap"> | ||
| <div className="card"> | ||
| {(title || subtitle || actions) && ( |
There was a problem hiding this comment.
I am not exactly clear on what is happening here. Are you checking that they all three exist before rendering?
There was a problem hiding this comment.
These are placeholder sections for the Centercard template used by each page where the card header can have a title, subtitle, and actions.
| }, [fetchBooks]); | ||
|
|
||
| // Return refetch function so that other components can trigger updates | ||
| return { books, loading, error, refetch: fetchBooks }; |
There was a problem hiding this comment.
What is a refetch function? Does this allow you to "refetch" outside in other components?
There was a problem hiding this comment.
Yes, it does. It's used in the delete function for the books table to re-fetch the page after deleting a book.
| const data = await dataLayer.getAllBooks(); | ||
| res.status(200).json({ | ||
| message: "success", | ||
| data |
There was a problem hiding this comment.
Inconsistent with line 19 where you assign book to data, but that same practice is not followed here on line 7.
There was a problem hiding this comment.
the data here is all our books while in line 19 is a singular book
| export const deleteBook = async (id) => { | ||
| return await BookSchema.destroy({ | ||
| where: { | ||
| id |
There was a problem hiding this comment.
Inconsistent again with not assigning any id specifically to your where clause.
There was a problem hiding this comment.
It is how it is supposed to be returned in order for sequelize to delete an item
Tech Stack:
Implemented Features:
All CRUD API endpoints are documented in the project README.