The library has been upgraded for Goyave v5.
The filters library didn't allow decoupling of the HTTP layer and the data layer because of its dependency to the *goyave.Request
. It was therefore impossible to move its uses to a repository, where they belongs. By creating a DTO for this specific use and changing the error handling, filters can now be properly integrated in the new architecture. They were also upgraded to take advantage of the generics.
filter.Settings
,filter.Scope()
,filter.ScopeUnpaginated()
now take a generic parameter representing the model being filtered.filter.Settings.CaseInsensitiveSort
new option wraps the sort values inLOWER()
if the column is a string, resulting inORDER BY LOWER(column)
.filter.Settings.DefaultSort
new option allows to define a list of sorts to be used if the user request didn't contain any sort.filter.Settings.Scope()
,filter.Settings.ScopeUnpaginated()
,filter.Scope()
,filter.ScopeUnpaginated()
now take a*filter.Request
instead of a*goyave.Request
. This request can be created from a HTTP query with the new functionfilter.NewRequest(query)
.filter.Settings.Scope()
andfilter.Scope()
now return anerror
instead of a*gorm.DB
.filter.Filter.Scope()
,filter.Join.Scope()
,filter.Sort.Scope()
now take afilter.Blacklist
instead of*filter.Settings
.filter.Validation
is now agoyave.RuleSetFunc
, and should be used withroute.ValidateQuery()
.- The field
fields
in a request validated withfilter.Validation
will now always be a[]string
. - The page info and records SQL queries are now executed inside a transaction.
- Validation error messages names had a "goyave-filter-" prefix added.