diff --git a/.vscode/launch.json b/.vscode/launch.json index 787b44f..302a0b7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,5 +3,23 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", - "configurations": [] + "configurations": [ + { + "name": "Attach to Process", + "type": "go", + "request": "attach", + "mode": "local", + "processId": 157645 + }, + { + "name": "Connect to server", + "type": "go", + "request": "attach", + "mode": "remote", + "remotePath": "${workspaceFolder}", + "port": 8080, + "host": "127.0.0.1" + } + + ] } \ No newline at end of file diff --git a/backend/db/repos_db.go b/backend/db/repos_db.go index 54f75b3..a91f380 100644 --- a/backend/db/repos_db.go +++ b/backend/db/repos_db.go @@ -9,7 +9,6 @@ import ( ) func GetReposByFilters(filter any) ([]types.Repo, error) { - log.Println("Getting repos by filters", filter) collection := GetCollection("repos") // Specify options to use for string comparison diff --git a/backend/utils/construct_filters.go b/backend/utils/construct_filters.go index 9b1d081..55c72ad 100644 --- a/backend/utils/construct_filters.go +++ b/backend/utils/construct_filters.go @@ -16,11 +16,15 @@ func ConstructFilters(r *http.Request, model interface{}) bson.D { for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) - param := strings.ToLower(field.Name) + + bsonTag := field.Tag.Get("bson") + if bsonTag == "" { + continue + } + param := strings.Split(bsonTag, ",")[0] if values, ok := r.URL.Query()[param]; ok && len(values) > 0 { if field.Type.Kind() == reflect.Slice { - // Split the comma-delimited string into a slice of strings elements := strings.Split(values[0], ",") filter = append(filter, bson.E{Key: param, Value: bson.D{{Key: "$in", Value: elements}}}) } else {