Skip to content

Commit

Permalink
update inteface{} usage in query with any for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Mar 3, 2024
1 parent c47104b commit 8ef09e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion backend/pkg/database/gorm_repository_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const TABLE_ALIAS = "fhir"
// Can generate simple or complex queries, depending on the SearchParameter type:
//
// eg. Simple
// SELECT fhir.*
// FROM fhir_observation as fhir, json_each(fhir.code) as codeJson
//
// result = inteface{} ([]database.IFhirResource)
//
// eg. Complex
// SELECT fhir.*
Expand All @@ -54,6 +58,8 @@ const TABLE_ALIAS = "fhir"
// )
// AND (user_id = "6efcd7c5-3f29-4f0d-926d-a66ff68bbfc2")
// GROUP BY `fhir`.`id`
//
// results = []map[string]any{}
func (gr *GormRepository) QueryResources(ctx context.Context, query models.QueryResource) (interface{}, error) {

sqlQuery, err := gr.sqlQueryResources(ctx, query)
Expand All @@ -62,7 +68,7 @@ func (gr *GormRepository) QueryResources(ctx context.Context, query models.Query
}

if query.Aggregations != nil && (query.Aggregations.GroupBy != nil || query.Aggregations.CountBy != nil) {
results := []map[string]interface{}{}
results := []map[string]any{}
clientResp := sqlQuery.Find(&results)
return results, clientResp.Error

Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/models/query_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type QueryResourceAggregations struct {

type QueryResourceAggregation struct {
Field string `json:"field"`
Function string `json:"fn"`
Function string `json:"fn"` //built-in SQL aggregation functions (eg. Count, min, max, etc).
}

func (q *QueryResource) Validate() error {
Expand Down

0 comments on commit 8ef09e3

Please sign in to comment.