4 ms·
I loved TypeORM initially, but came to the conclusion that it was written by people who really got TypeScript, but didn't really get SQL. For example, we were
by gmac 7y ago
I loved TypeORM initially, but came to the conclusion that it was written by people who really got TypeScript, but didn't really get SQL.
For example, we were converting from Sequelize, where we were catching unique constraint violations and responding appropriately, and we got quite confused that in TypeORM those errors never got thrown ... until we discovered that TypeORM decides unilaterally (and almost unbelievably) to replace your original record in that situation.
We have since ripped out all third-party ORMs and migrated to a system of typed helper functions and tagged templates (where all the typings are generated automatically at compile-time by inpecting the database). This is really rather wonderful — we now have full access to all sorts of goodies like native UPSERT, we know exactly what SQL we're going to get every time we touch the database, and yet the ergonomics are excellent, because everything going in and out of the DB is fully typed, including even column and table names in basically-raw SQL. A blog post (and perhaps eventually a library) is in the works ...
- slow_donkey 7y agoWould love to see your current setup - I also have the same issue with TypeORM and am sticking with sequelize.
- davidspiess 7y agoReally interested in your blog post, especially on generating types for the database. Can you give some short insights on how you achieve it?
- Benjamin_Dobell 7y agoI couldn't agree with this more. I've just started using TypeORM and the TypeScript aspect is great. However, here I am trying to do a simple distinct left join, but it's extremely difficult to write because the query APIs consistently get in the way. We're regularly receiving invalid SQL errors, which from a typed language/API seems particularly odd. We're doing this exact same query on the exact same DB in ActiveRecord/Ruby and it's trivial to both write and understand.
- hardwaresofton 7y agoI've never had this problem (constraint violations result in errors for me) -- did you file a ticket? Like others have said, I'd also love to see if you've written anything about this! How do you deal with queries that are slightly formulaic & different or need to be assembled dynamically? do you use any query builder at all?