How to connect every Model with its user

Hey all - just looking for a tip on how to structure my DB. I’m building an app that allows people to build websites. This is the basic structure:

User -> Project -> Website -> Components

A user has many projects, which have many websites etc.

Where I’m struggling is how to associate the website or component with the user.

The reason being, I only want to allow people to create a website or component, if they own the project.

Obviously its easy to associate project with user, because it has a belongsto relationship. Do I have to create a relationship with user for every part underneath project in the hierachy too? Or is there a better way?

New to this, so all advice appreciated :slight_smile:

One other idea I have is to import the Project model into everything below, and run a check through that model?

This is a design and database issue, not AdonisJs related.
Take time to think about it yourself. From my experience, do not even trust people to advice you on such things. You will find answers in your old school CS lessons.

1 Like

That is the most straightforward option, yes.