Skip to content

Many-to-many relationship and pivot columns. #261

Answered by stephenafamo
hiendaovinh asked this question in Q&A
Discussion options

You must be logged in to vote

The complexity of trying to

If I understand correctly what you're trying to do, you have a few options:

1. Have two separate relationships.

  1. One from users to organization_user
  2. Another from organization_user to organizations
models.Users.Query(
  models.ThenLoadUserOrganizationUsers(
    sm.Columns(...), // filter the join table columns
    models.PreloadOrganizationUsersOrganization,
  ),
)

2. Use a view

Create a "Joined View" and define your relationship to the view.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by stephenafamo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #259 on July 28, 2024 07:26.