by ajx1001 · 1y ago · 0 comments
It is the middle layer between DB (Ecto) and Phoenix (with or without LiveView) -- where your actual application lives.
The difference between a Resource and a Model (or ActiveRecord) is Models typically define attributes and relationships vs a Resource defines attributes, relationships, actions (read, write, destroy, custom...), behaviours (i.e. multi-tenancy, jobs) and what I call facets (i.e. JSON api, GraphQL).
When you read the code for a Resource, you grok all of this in a nice, consistent way (we have 100* resources - all are consistent). This is because of the DSL.
When compiled, it all boils down to a Struct that you can easily inspect. That Struct enables all kinds of stuff.
No comments yet.