43dd4e9234
Signed-off-by: Anton Nesterov <anton@demiurg.io>
26 lines
497 B
Go
26 lines
497 B
Go
package filters
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"l12.xyz/dal/utils"
|
|
)
|
|
|
|
type Between struct {
|
|
Between []interface{} `json:"$between"`
|
|
}
|
|
|
|
func (f Between) FromJSON(data interface{}) IFilter {
|
|
return FromJson[Between](data)
|
|
}
|
|
|
|
func (f Between) ToSQLPart(ctx Dialect) string {
|
|
if f.Between == nil {
|
|
return ""
|
|
}
|
|
name := ctx.GetFieldName()
|
|
values := utils.Map(f.Between, ctx.NormalizeValue)
|
|
condition := fmt.Sprintf("%v AND %v", values[0], values[1])
|
|
return fmt.Sprintf("%s BETWEEN %v", name, condition)
|
|
}
|