Generating model types from DB schema (could improve DX) #58
Replies: 2 comments 2 replies
-
I was thinking about it and decided not to do that. The reason is schema evolving. Sooner or later, you will add some props and deprecate the other. But after the release, you can't remove deprecated props because there could be data with such deprecated props waiting to be synced. I don't believe some generic model would survive for a longer time. There would be deprecated props. The right approach is to redeclare the props you are going to use. For example, you rarely will need a full "Todo model" in a listing. Only a few props like ID and title. You probably will not need the full "Todo model" in detail either because you will use joins. "duplication is cheaper than the wrong abstraction”, so be explicit and type the props you will use. Feel free to disagree. Also, check https://github.com/evoluhq/evolu/wiki/Nullability-and-version-less-schema |
Beta Was this translation helpful? Give feedback.
-
Evolu already has that |
Beta Was this translation helpful? Give feedback.
-
Take README example:
now when I'd like to have a component, that takes a
todo
record as a prop, I don't have a simple way, how to type it. When querying the DB:the type of a single row is (at least according to my IDE):
Could there be a way, how I could get a nice model type from the DB schema? Or maybe a different way, how to specify the model first?
Beta Was this translation helpful? Give feedback.
All reactions