ORMs are a leaky abstraction -- there is a sweet spot (mostly basic queries/relationships) where they provide lots of value, but there is a veritable infinity of scenarios beyond where they are a hindrance. Also they tend to introduce
lots of hidden complexity when they try to introduce flexibility to match the landscape.
I'd argue that most of the time what you really need is a query builder with the right combinators, and maybe some higher order combinators to wrap those together for even better ergonomics.
For those writing NodeJS one of the best ORMs that I've found is typeorm[0], check it out.
Here are some reasons I like it:
- Typescript-first
- Provides the repository pattern (ex. repository.findOne) & the entity manager pattern (ex. manager.findOne) so you can use whichever you prefer
- Annotation-based entity markup
- Ability to drop down to raw SQL query easily at any time
- Query building ability, special handling for relation queries, it's even got support for building with where params like and and or
- Great documentation
- Ability to programmatically use the introspection that it does for you (accessing the metadata from code is trivial)
- Handles migrations (you can generate them, run them, etc), easy to use programmatically as well
- Supports some low level concepts from my own favorite RDBMS, postgres
[0]: https://github.com/typeorm/typeorm