Using relational databases in a typed language is a pain unless you have great libraries to support you. There’s a lot of different libraries for TypeScript, but they all have their own advantages and flaws. Since it’s hard to find anything other than TypeORM, this is a short list of the possibilities (not an extensive review).
I’m only including SQL libraries for TypeScript that fulfill the following criteria. If I’m missing a library, please let me know.
In an ORM you declare the schema completely in the host language (TypeScript). The ORM then completely manages synchronization between your objects / classes and the corresponding database tables.
I’m not a huge fan of ORMs since they always have the same issues: If you have somewhat complex queries, you will get to the limit of the ORM and not be able to represent that query in it without escape hatching. You also lose direct control over how the queries are handled, and thus may get surprising performance issues when the ORM uses suboptimal SQL queries in the background.
A different approach from the other two, it’s a bit of a mix between a query builder and an ORM where you declare your model and relationships in TypeScript but filter the results with raw SQL.