2024-08-08 09:09:17 +00:00
|
|
|
package filters
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Or struct {
|
|
|
|
Or []string `json:"$or"`
|
|
|
|
}
|
|
|
|
|
2024-08-12 18:21:34 +00:00
|
|
|
func (f Or) ToSQLPart(ctx Dialect) (string, Values) {
|
2024-08-08 09:09:17 +00:00
|
|
|
if f.Or == nil {
|
2024-08-12 18:21:34 +00:00
|
|
|
return "", nil
|
2024-08-08 09:09:17 +00:00
|
|
|
}
|
|
|
|
value := strings.Join(f.Or, " OR ")
|
2024-08-12 18:21:34 +00:00
|
|
|
return fmt.Sprintf("(%s)", value), nil
|
2024-08-08 09:09:17 +00:00
|
|
|
}
|
|
|
|
|
2024-08-08 17:26:29 +00:00
|
|
|
func (a Or) FromJSON(data interface{}) IFilter {
|
2024-08-08 09:09:17 +00:00
|
|
|
return FromJson[Or](data)
|
|
|
|
}
|