Closed madaley1 closed 3 months ago
I want to add some thoughts here for my future reference: I may be on the wrong track with this. My goal was to avoid redundant code, but it's possible that this can become a headache due to potential complexity. The general flow I want is as follows:
Spin up new instance of library -> No tables in db exist, and no resource tables in ui exists -> user creates new library from template (movie or game or book or show), or chooses a blank template (they will fill out what is required and what isn't, as well as generating columns themselves) -> all types should be modifiable afterward, with warnings that deletion of certain columns may wipe table
It may benefit to allow for backing up and rollbacks of tables at a later stage of the project. I feel like it behooves me to create a generic get all function as the only thing changing is the key for the specific model or table. If they're dynamic too it doesn't make a ton of sense to make specific hardcoded checks, instead it makes more sense to query prisma for what is necessary and what types everything is and have a function to loop through the push/update and ensure everything is correct, and throw an error if something is incorrect. It would be even better if this was checked both in the UI and in the API, maybe having the types returned to the redux store when relevant modals are opened.
As I'm writing I'm remembering why I wanted to go with /[id]
over per type, so I probably will keep trying to make this work, but it seems like Prisma may not have been designed with this use-case in mind. I'm trying not to make this a patchwork job and constantly re-type things, so we'll see what's possible with the ootb types.
Remember to check the open question here for updates in case someone knows something you don't: https://stackoverflow.com/questions/78465555/how-to-use-a-dynamic-key-to-call-a-resource-from-prisma/78465847#78465847
Referencing another issue here, as it is mandatory to complete before more progress can be made on this issue: https://github.com/madaley1/nova-library/issues/5
Closing, not because it was completed, but because I generally need to re-evaluate the architecture of the app.