Join Query in Go Buffalo pop

I have models created for each table in my DB (which have the defined struct with fields mapped to table columns).
Now when I have to query I store the output of query to the struct of that particular table.

tableStruct := []models.ModelX{} // Assuming ModelX is a model with struct of the format of some table column.
models.DB.Where("column_name = ?", "abc").All(&tableStruct)

But when I have to do a join query with two tables, is it necessary have a struct defined with the columns of both tables?


I am getting the table names from some api and the join needs to be created between those tables. So creating the struct beforehand is not an option for me, because there are multiple tables and all possible combinations of join will be a lot.

Let me know if there’s some way to fetch data from a join without creating the struct beforehand.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.