Add more options to Players list

This commit is contained in:
Deluan
2020-06-08 15:32:14 -04:00
committed by Deluan Quintão
parent 84ed3eb427
commit c9bcb333ae
3 changed files with 23 additions and 2 deletions
+3
View File
@@ -19,6 +19,9 @@ func NewPlayerRepository(ctx context.Context, o orm.Ormer) model.PlayerRepositor
r.ctx = ctx
r.ormer = o
r.tableName = "player"
r.filterMappings = map[string]filterFunc{
"name": containsFilter,
}
return r
}
+4
View File
@@ -52,6 +52,10 @@ func startsWithFilter(field string, value interface{}) Sqlizer {
return Like{field: fmt.Sprintf("%s%%", value)}
}
func containsFilter(field string, value interface{}) Sqlizer {
return Like{field: fmt.Sprintf("%%%s%%", value)}
}
func booleanFilter(field string, value interface{}) Sqlizer {
v := strings.ToLower(value.(string))
return Eq{field: strings.ToLower(v) == "true"}