update inteface{} usage in query with `any` for clarity.

This commit is contained in:
Jason Kulatunga 2024-03-03 10:04:43 -08:00
parent 7900ccfeb6
commit 0f6e735e3a
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View File

@ -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.*
@ -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)
@ -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

View File

@ -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 {