From 9e16d87ec44cb26305a4f62defa37c225062c4fa Mon Sep 17 00:00:00 2001 From: Florian Obernbrger <99478384+florian-obernberger@users.noreply.github.com> Date: Thu, 2 Jun 2022 21:44:35 +0200 Subject: [PATCH] Add holds and notHolds operators --- query.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/query.go b/query.go index c95b501..33f93bf 100644 --- a/query.go +++ b/query.go @@ -27,6 +27,8 @@ const ( signStartsWith = "startsWith" signIn = "in" signNotIn = "notIn" + signHolds = "holds" + signNotHolds = "notHolds" signLenEq = "leneq" signLenNotEq = "lenneq" @@ -192,6 +194,16 @@ func notIn(x, y interface{}) (bool, error) { return !b, err } +// holds checks if x contains y e.g: holds("[1,2,3]", 1) +func holds(x, y interface{}) (bool, error) { + return in(y, x) +} + +// notHolds checks if x doesn't contain y e.g: notHolds("[1,2,3]", 1) +func notHolds(x, y interface{}) (bool, error) { + return notIn(y, x) +} + // lenEq checks if the string/array/list value is equal func lenEq(x, y interface{}) (bool, error) { yv, ok := y.(int) @@ -307,6 +319,9 @@ func loadDefaultQueryMap() map[string]QueryFunc { queryMap[signIn] = in queryMap[signNotIn] = notIn + queryMap[signHolds] = holds + queryMap[signNotHolds] = notHolds + queryMap[signLenEq] = lenEq queryMap[signLenNotEq] = lenNotEq