My advice: go straight to PG. And avoid ORMs.

In the JVM world, jOOQ is great happy-medium technology between the extremes of string SQL and full-blown ORM:

- Type-safe DSL generated from your schema that looks like SQL

- (If you can write the SQL, you can write it in jOOQ)

- SQL-injection protection

- Strong multi-dialect and vendor-specific support

- Custom-type mappers

- Composable queries

- Compile-time, schema-aware query safety

- Fine-grained transaction control

- And so much more...

There are various non-ORM database libraries for TypeScript too. I develop Zapatos, but Slonik and pg-typed are probably better known.

https://jawj.github.io/zapatos/

https://github.com/gajus/slonik

https://pgtyped.vercel.app/