3 ms·
Ecto isn't an ORM since Elixir isn't OO. Terminology aside, Ecto identifies more as an Integrated Query Language in a similar vein as LINQ does in the .NET ecos
by rubiquity 11y ago
Ecto isn't an ORM since Elixir isn't OO. Terminology aside, Ecto identifies more as an Integrated Query Language in a similar vein as LINQ does in the .NET ecosystem.
As someone who has used lots of ORMs I find the switch to a libary like Ecto very refreshing. It has an intuitive and very composable querying API and friendly DSLs for defining schemas and validations. These are the baseline features of any database/modeling library and Ecto satisfies them nicely.
But by far my favorite feature that has come in handy is that Ecto's concept of Repos does not couple you to a specific database. Unlike traditional ORMs that couple your objects to a specific database (read: the my_cool_app database in MySQL or Postgres) it's easy to support different databases within the same type of RDBMS or different RDBMS entirely. Since all querying in Ecto goes through Repo modules all you need to do is just create more Repo modules and configure them accordingly.
For some people this feature might not sound useful but if you've ever worked on an Enterprise or older app with multiple data sources or want to switch from MySQL to Postgres, this is a killer feature. Doing this with Rails' ActiveRecord is ugly, buggy, a pain and will bring you to your knees during Rails upgrades any time there are major changes in ActiveRecord.
- rufugee 11y agoI've worked with multiple ORMs (Hibernate, Rails ActiveRecord, and Grails GORM), and I've always been able to easily switch betweens RDBMS's unless I specifically decided to step out of the ORM and use a DB-specific feature or query. I'm not sure what you mean here?
- rubiquity 11y agoBy switching I mean I want one query to go to this database and another query to go to a completely different database at the same time. Can you do this in other ORMs? Yes. Does it almost always involve a third party library that monkey patches your ORM's connection pool? Yes.
- rufugee 11y agoOk, that's more clear. I've only had to do this once, and I did indeed use a third-party plugin that monkeyed all over.