epicweb-dev / data-modeling

Model and query your data with confidence
https://www.epicweb.dev
Other
155 stars 63 forks source link

Always delete noteImages suggestion #33

Closed matiasleidemer closed 10 months ago

matiasleidemer commented 11 months ago

Here there, Kent 👋

I'm doing the EpicWeb course, which has been really good so far; thank you! I would like to leave a suggestion to the 07. UPDATING DATA / 02. UPDATE solution page:

What if, instead of checking if we have new images or image updates, we always delete and recreate them (if any)? We wouldn't need to transform the NoteEditorSchema and would make the code easier to follow. The downside is that we would always bust the image cache (which isn't a big deal in this case specifically).

Maybe it would be nice to leave a note on the solution page mentioning that the approach above is possible. WDYT?

Thank you!

kentcdodds commented 10 months ago

Thanks for the suggestion. Once we get to the last part of this exercise the resulting code is quite nice and optimized for our use case: https://data.epicweb.dev/07/04/solution

What do you think of the final solution?

matiasleidemer commented 10 months ago

The final solution looks great, and once all the imageUpdates and newImages are set, updating them using Prisma is a breeze.

But, in my opinion, getting the updates and new images adds a lot of complexity, and it could be avoided if we delete and recreate everything all the time. It's all good, however, I just wanted to share this alternative solution. 😄

kentcdodds commented 10 months ago

The problem is it's just a lot of extra work on the server and database for only subjective minimal benefit.

Thanks for the feedback though!