Many To Many Relationship Example
After reading https://www.ash-hq.org/docs/guides/ash/latest/topics/relationships.md#has-many and https://ash-hq.org/docs/dsl/ash/latest/ash-resource-dsl/relationships/many_to_many I am a little bit confused since the examples use different code. I am looking for a simple example which I can copy and paste. Something like a blog post which has multiple tags associated via a many to many relationship:
- What do I have to change in the existing files?
- How do I have to do the third resource?
- How would I add a tag to a blog post the Ash way?
3 Replies
There should probably be a guide specifically for this. Here is how I'd typically set it up:
I can write a tutorial for this or enrich the examples in the current docs. Let's have that discussion in #documentation
Bonus question: What is "the Ash" way of adding a
Tag
to a Post
? I know how to do this in Ecto
but I am still unsure how an Ash developer tackles this best.There are two ways:
manage_relationship
and a custom change.
manage_relationship:
custom change