nodal
nodal copied to clipboard
Joining on columns that don't end with "_id"
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()?
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'?