armorform
PPrisma
•Created by armorform on 4/24/2024 in #help-and-questions
Many to many on the same model, multi directional?
I have a fairly simple question and have been struggling long enough that I thought it warranted a question.
I have a simple concept: one model is an Artist and I want to have a “related artist” array.
I am familiar with the many to many and relations attribute to set up and have both models populate. I have a RelatedArtist model that houses both an artist and a related artist on it. It works fine and I’m able to join the records using this model.
What I’m confused with or wondering is this:
Depending on how I connect the model, the children are different when I retrieve the record. for example, if I connect artist A to artist B, and in artist A want to pull the related model for B, I use “artist.relatedArtists” to pull the data.
However, in model B, I have a different field name so i use “artist.artists” to pull artist A.
Is there a more clever or better way to do this?
5 replies