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