0

I would like some help to build something a la https://pokeapi.co/ .

I have a problem when I try to make the following structure:

"forms": [
        {
            "url": "https://pokeapi.co/api/v2/pokemon-form/1/",
            "name": "bulbasaur"
        }
    ],
"stats": [
    {
        "stat": {
            "url": "https://pokeapi.co/api/v2/stat/6/",
            "name": "speed"
        },
        "effort": 0,
        "base_stat": 45
    },
]

Directus works fine when I have one relation field such as forms (make a new relation field to forms, get Bulbasaur, done)

I would have build monster and the stat table, and I need to give a value to the relation field stat (in that case, speed) of 45.

I tried to fiddle around with Directus with no success.

  • Hey André – could you explain the issue you're having a bit more? It seems like you're not getting all relational data returned, but I want to be sure. Perhaps you could write the JSON you'd like to get and what you're actually getting? – RANGER Feb 26 '18 at 17:41
  • Sorry I wasn't clear. https://pokeapi.co/api/v2/pokemon/1/ < this is the closest structure I want to get and as you see in `stats` and many other fields is the goal I want to achieve, for one Pokemon, I want many stats that has its own value and these stats has its own table (with its own data) – André Nakazato Feb 26 '18 at 18:09

1 Answers1

1

Hey André – it seems like this is more of a database architecture question. But here is a schema I would use:

  • monsters
    • id
    • name
    • stats (ALIAS: Many-to-Many interface relationship)
  • monster_stats (Junction table for the many-to-many)

    • id
    • monster_id
    • stat_id
  • stats

    • id
    • name
    • effort
    • base_stat
RANGER
  • 1,643
  • 2
  • 17
  • 31