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