Signed-off-by: dusk y.bera003.06@protonmail.com
+7
appview/db/db.go
+7
appview/db/db.go
···
741
741
func FilterIs(key string, arg any) filter { return newFilter(key, "is", arg) }
742
742
func FilterIsNot(key string, arg any) filter { return newFilter(key, "is not", arg) }
743
743
func FilterIn(key string, arg any) filter { return newFilter(key, "in", arg) }
744
+
func FilterBetween(key string, arg1, arg2 any) filter {
745
+
return newFilter(key, "between", []any{arg1, arg2})
746
+
}
744
747
745
748
func (f filter) Condition() string {
746
749
rv := reflect.ValueOf(f.arg)
747
750
kind := rv.Kind()
748
751
752
+
if f.cmp == "between" {
753
+
return fmt.Sprintf("%s %s ? and ?", f.key, f.cmp)
754
+
}
755
+
749
756
// if we have `FilterIn(k, [1, 2, 3])`, compile it down to `k in (?, ?, ?)`
750
757
if (kind == reflect.Slice && rv.Type().Elem().Kind() != reflect.Uint8) || kind == reflect.Array {
751
758
if rv.Len() == 0 {