zac
Add attribute using `many_to_many` relationship DSL
I don’t think this is possible, but thought I’d pose the question (I did see this, which is similar but specifically asking if the relationships DSL somehow makes it easier to implement).
Is it possible to create a many to many relationship with an attribute, e.g., along these lines:
relationships do
many_to_many :members App.Accounts.User do
through App.Team.Members
source_attribute_on_join_resource :team_id
destination_attribute_on_join_resource :user_id
> attribute :role, :atom do # this bit... can't be done?
> allow_nil? false
> constraints [one_of: [:team_member, :team_lead]]
> end
end
end
From what I can see in the relationships DSL adding attributes like this isn’t supported. I can see how that could get difficult.
On the other hand – having very simple support would be awesome, e.g., in this case I just want a :role identifier that must be set. No magic and no tricky other stuff. It could potentially save a good bit of overhead (defining a new property, etc., etc.)
Is this worth writing up as a feature request?
First Post!
sevenseacat
You’d add that attribute as normal onto your App.Team.Members resource.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








