Data structure for tv shows

Hello, i’m trying to define a data structure for my tv shows app. The first solution that i came up was to have a content named show and inside that content have a blok of contents named season, and inside the seasons have a blok of contents named episodes. This simplifies the life of the people who will be feeding the content. But i’m having trouble with queries. Since i couldn’t find a way to query a single episode or a single season. There’s some way i can query nested bloks by it’s _uids? If not how can i achieve this kind of relationship in storyblok?

Thanks in advance.

Hello @rafaelhaertel,

there are many different ways for how you can structure the content. I would suggest looking into a folder structure similar to this one as it allows you to fetch the single items (shows and their episodes) better:

  1. You can create a folder for all shows and in that folder an own folder for every show:
  2. (Optional) A subfolder could contain the Episodes of the shows.

The content structure of the stories for the shows could contain the name, which can also be translated with field-level translation (Internationalization - Storyblok) when needed, as well as a description and a gallery of images (Schema Configuration - Storyblok):

The Episode content type could contain a similar content structure and additionally information about the actual episode to which it belongs, the actors of the main roles, etc:

The actual structure allows you to use the starts_with parameter to get all episodes from a show:
https://api.storyblok.com/v1/cdn/stories?version=draft&token=NmKDJA8r7frrX3zkohI2ngtt&cv=1618941493&starts_with=shows/my-awesome-show/episodes

You can also search for episodes in which an actor played a role in the case that is something that you want to add to the content. The actors are also stories from which you need to have the UUIDs so you can filter for them with the ´filter_query´ parameter:
https://api.storyblok.com/v1/cdn/stories?version=draft&token=NmKDJA8r7frrX3zkohI2ngtt&cv=1618941493&starts_with=shows/my-awesome-show/episodes&filter_query[Actors][in_array]=b6d623b6-51f5-4f11-81fb-9ebf415c3d6f

Here are some articles that can help you to understand how you can use relations for different use-cases:

In case there are further questions feel free to ask!

I also passed the example space to you so you can take a look at the example configuration. The name of the space is “tv_shows_app”.

Best regards
Hannes

Hello @Hannes, thanks for the quick response.

I’ve came up with a solution that looks a lot like yours, but now i’m having some trouble with queries.

For example: I’ve created a multi-option relation from shows to seasons and from seasons to episodes. And this works pretty well if I want to have the seasons of a show in one query or even the episodes of a season. But i’m having trouble if I want to query for an episode and bring the show the this episode belongs to. Is there a way to use resolve_relations kinda like “backwards”?

Thanks in advance.

Hello @rafaelhaertel,

when you have the UUID of an episode you can use the filter_query parameter and as you’re using a multi-option field you need to use the in_array operator like in my previous example https://api.storyblok.com/v1/cdn/stories?version=draft&token=NmKDJA8r7frrX3zkohI2ngtt&cv=1618941493&starts_with=shows/my-awesome-show/episodes&filter_query[Actors][in_array]=b6d623b6-51f5-4f11-81fb-9ebf415c3d6f

You can also find more information here: Storyblok API Documentation & Storyblok API Documentation

Best regards
Hannes