Skip to content

Commit 3ccf52f

Browse files
committed
refactor: rename createField to filterField and improve documentation
1 parent 872db08 commit 3ccf52f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/controllers/transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type TransactionQueryFilter struct {
4040
DestinationAccountID string `form:"destination"`
4141
EnvelopeID string `form:"envelope"`
4242
Reconciled bool `form:"reconciled"`
43-
AccountID string `form:"account" createField:"false"`
43+
AccountID string `form:"account" filterField:"false"`
4444
}
4545

4646
func (f TransactionQueryFilter) ToCreate(c *gin.Context) (models.TransactionCreate, bool) {

pkg/httputil/query.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ func GetURLFields(url *url.URL, filter any) []any {
2525
field := val.Type().Field(i).Name
2626
param := val.Type().Field(i).Tag.Get("form")
2727

28-
// createField is a struct tag that allows to specify if the field is part
29-
// of the fields to filter for on the original struct
30-
createField := val.Type().Field(i).Tag.Get("createField")
28+
// filterField is a struct tag that allows to specify if the field
29+
// is used to filter resources directly (e.g. SourceAccountID on a TransactionQueryFilter)
30+
// or if it is a meta field that is processed by explicit logic outside of
31+
// GetURLFields (e.g. AccountID on a TransactionQueryFilter)
32+
filterField := val.Type().Field(i).Tag.Get("filterField")
3133

32-
if url.Query().Has(param) && createField != "false" {
34+
if url.Query().Has(param) && filterField != "false" {
3335
queryFields = append(queryFields, field)
3436
}
3537
}

0 commit comments

Comments
 (0)