3 ms·
If the programming language can offer type safety for queries, it's a big win. For instance in the .Net framework, Entity Framework continues to be the default
by jeswin 5y ago
If the programming language can offer type safety for queries, it's a big win. For instance in the .Net framework, Entity Framework continues to be the default choice after a decade because it is well integrated with the language and also allows you to use SQL if needed. Meanwhile in say JS, an ORM has less to offer.
So really, just like most other programming decisions, the answer is "it depends".
- kristiandupont 5y agoI generate Typescript types directly from a Postgres database. That works great with Knex and a bit of custom code I've written on top.
- madeofpalk 5y agoHow do you know you're saving and retrieving data that correctly matches your typescript definition? Or are you just saying "trust me"?
- kristiandupont 5y agoKnex has some built-in support for it, but I've made a wrapper that does it quite well. So I can write db.select('member', { displayName: 'John' }) -- and because I specify the table name in the first parameter, I get type checking on the second.
- hebrox 5y agoThis has been an issue for me as well. I created https://github.com/wwwouter/typed-knex https://github.com/wwwouter/typed-knex to mitigate this. At first I had to do a lot of weird things, but with the evolution of TypeScript, it is getting more and more like 'normal' Knex.js. The end goal is to be nothing more than a very small wrapper, if any.