Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joining on columns that don't end with "_id" #298

Open
brianlove opened this issue Sep 21, 2016 · 1 comment
Open

Joining on columns that don't end with "_id" #298

brianlove opened this issue Sep 21, 2016 · 1 comment

Comments

@brianlove
Copy link

I'm trying to have a model with a 'created_by' column that joins to the 'id' column of a user model. Since the name of the column is not of the format 'MODELNAME_id', it looks like I need to provide join() with an array to specify the comparisons. However, the documentation doesn't specify what this array should look like.

What should be the format of the comparisonsArray parameter for join()?

@brianlove
Copy link
Author

Turns out I was looking in the wrong place - last night I found the 'via' entry in the options parameter of joinsTo(). Now I have the user information that I want included in the response. However, it is appearing as 'user', instead of 'created_by'. I tried several combinations of values for the 'name', 'via', and 'as' options, but the response still comes back as either 'user' or an error. How can I get the response to be 'created_by'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant