top | item 42335151

(no title)

plopz | 1 year ago

My feelings are similar and I cringe every time I see a "typesafe" db interface that doesn't run time validate the data.

discuss

order

bluepnume|1 year ago

Runtime validate at the database boundary? Isn't it better to just do runtime validation at the api boundary instead? Then any of the types that make it into the database should be mostly guaranteed by TS (and of course, whatever types are enforced by the database schema itself).

jadbox|1 year ago

What do you use for runtime? I've used pgtyped in the past and it does a good job at taking raw SQL and generating the return types from runtime: https://github.com/adelsz/pgtyped

lerp-io|1 year ago

typescript people want types on everything cuz it feels good that way.

nikisweeting|1 year ago

Also it allows AI tools in IDEs like Cursor to work a lot more effectivley because they can leverage type/lint errors to make sure suggestions are correct on the first try.