Actually I’m making an custom api to practice Phoenix, so actually I’m having a problem with a complex relationship with Ecto, if someone can help me to solve it please n.n
{
"producers": ["23\/Bandai_Visual", "Bandai Visual"],
"licensors": [["102\/FUNimation_Entertainment", "FUNimation Entertainment"], ["233\/Bandai_Entertainment", "Bandai Entertainment"]],
"studios": ["14\/Sunrise", "Sunrise"],
"related": {
"Adaptation": [["Cowboy Bebop", "\/manga\/173\/Cowboy_Bebop"], ["Shooting Star Bebop: Cowboy Bebop", "\/manga\/174\/Shooting_Star_Bebop__Cowboy_Bebop"]],
"Side story": [["Cowboy Bebop: Tengoku no Tobira", "\/anime\/5\/Cowboy_Bebop__Tengoku_no_Tobira"], ["Cowboy Bebop: Ein no Natsuyasumi", "\/anime\/17205\/Cowboy_Bebop__Ein_no_Natsuyasumi"]],
"Summary": ["Cowboy Bebop: Yose Atsume Blues", "\/anime\/4037\/Cowboy_Bebop__Yose_Atsume_Blues"]
}
}
I wanted to return this json on a REST/GraphQl request, but my problem its on “related”, “producer”, “licensors” and “studios” field.
for “producers”, “licensors” and “studios” every return value its related to the same table “anime_producers” (the id 23, 102, 233 etc… are this table)
for “related” its the most complext of all, it have 12 possible categories, and every category can have a manga or anime or both
I can figure out the “producers”, “licensors” and “studios” with a table for many_to_many (correct me if I’m wrong), but related I can’t figure out what is the solution for this one
Greetings