How to model nested relationship?

default discord avatar
6 months ago
2 1

I have a simple relationship as follows:

  • One courses has many chapters.
  • One chapters has many lessons.
  • One chapters belongs to only one courses.
  • One lessons belongs to only one chapters.
  • Only authorized users can access courses, and the permission is inherited by children lessons.

What do you think is a good way to implement this in Payload? How about even more nested relationships? Technically, I can create 3 collections respectively, but that might not be the cleanest way for data entry due to applying repetitive changes (roles, relationship pointers) at different locations.
This seems achievable via Payload Nested Docs Plugin, but I'm not sure if it is the right solution as I don't require a nested URL slug.

  • default discord avatar
    6 months ago

    It appears the Array collection is applicable in this use case. The good thing is that it can be nested so I can consolidate content under one courses. Probably there are performance and query implications using this way, but I will see how it goes.

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.