nodal icon indicating copy to clipboard operation
nodal copied to clipboard

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

Open brianlove opened this issue 8 years ago • 1 comments

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 avatar Sep 21 '16 19:09 brianlove

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'?

brianlove avatar Sep 25 '16 20:09 brianlove