Build gorm query step by step

I am trying to build query step by step which seems successful(using gorm) if I pass the struct(model/schema). But as I (can)have more than 100 tables, it needs to be independent of the struct. So I pass interface as

func QueryBuilder(db *gorm.DB , model interface{},param schemas.Query) interface{}{
  db = BuildSelect(db , param.Select)
  db = BuildWhere(db , param.Where)
      // Everything ok till here but gorm complaints, it needs a slice or struct. 
  db = BuildWhereOr(db , param.Or).Find(&model)
  fmt.Println("after Build")
  return model

}

How can I get back results in desired structs/schemas. Any help or workaround is really appreciated

Basically I am building different parts of the query step by step based on the input provided

You can do two step queries in one step using JOIN, CTE or subqueries. If you create a fiddle and give the desired output, I can give you an example.

This was not even a problem. I just passed a reference of struct to gorm and it worked. Thank you so much for showing interest and trying to help me

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