4 ms·
Javascript and ORMs have a (fairly well-known) interesting set of problems: * There aren't many * Those that you can find, don't support Typescript, so it's a
by samhuk 4y ago
Javascript and ORMs have a (fairly well-known) interesting set of problems:
* There aren't many
* Those that you can find, don't support Typescript, so it's all guesswork.
* Don't have much (if any) support for related data queries
So I've been working on a ORM for PostgreSQL and Typescript for a few months now in my spare time [0]. It's been probably one of the biggest, challenging, and interesting problems I have embarked on solving.
Some things i've observed along the road:
* Typescript is weird and wonderful when you push it to it's limits, particularly around recursive structures. Strange workarounds exist, nicely provded by all of the two Stack Overflow Typescript gurus that exist.
* PostgreSQL doesn't have some of the features that you would expect from other DB technologies (i.e. certain table alterations, limit on update and delete, etc.). Weird and wonderful workarounds exist, but it always leaves you thinking _why aren't those workarounds just the de facto way for doing those things?_.
[0] https://github.com/samhuk/ts-pg-orm https://github.com/samhuk/ts-pg-orm
- jiggawatts 4y agoI’m interested to hear what those PostgreSQL limitations are more specifically.
- samhuk 4y agoI don't want to get too much in the weeds, but one well-known example is missing support for LIMIT on DELETE and UPDATE statements. The workarounds that exist range from fairly pedestrian (like using the scary ctid column) to totally wild (like creating temp tables or using transactions and all sorts). The rabbit hole goes.
- rjbwork 4y agoPostgres still doesn't support SQL:2011, and the temporal_table extension doesn't support the proper syntax, and is a bit jank to boot. If you have any kind of complex DW or SCD needs Postgres is pretty much immediately out the window. I think MSSQL probably has the best support for that, unfortunately.
- slekker 4y agoPrisma and TypeORM both are made for TypeScript. The first works wonderfully well
- samhuk 4y agoI quite liked Prisma when I used it, I'm glad someone brought it up. The issues with Prisma are that it had moderately weak support for Typescript, and doesn't robustly support related data querying (inc. recursively), or exotic inter-object relations (e.g. many-to-many with join tables, etc.). As I said, a lot of the ORMs you find out there tend to be quite simple, missing some QoL features.