I have 4 tables:
Users, Companies, Segments, Segment_screens and Screens.
I’m trying to fetch all the screens from a user based in your companies, companies have a segment and this segment have many screens.
I try this way:
const permissionsUser = await User.query() .where('id', userLogged.id) .with('companies.segment.screens') .fetch()
Is returning the result that i expect, but is returning the data of this user, your companies, the segment of this companie and last, the screens of this segment. I need only the “screens” array object. Someone can help me?
There’s other way to fetch this data with only the screens object?