Hi, how do I find records where opposite values of an attribute are a match. I want to find records where quantity 200 and -200 will match. it is right now giving me empty list as result
data [{:db/id -1
:date "2024/03/01"
:payee "Swiggy"
:quantity 200}
{:db/id -3
:date "2024/03/02"
:payee "Test"
:quantity 300}
{:db/id -4
:date "2024/03/02"
:payee "Test"
:quantity 300}
{:db/id -2
:date "2024/03/01"
:quantity -200
:payee "Swiggy"}]
f #(db/q '[:find
(pull ?t [*]) (pull ?t2 [*])
:in $
:where
[?t :quantity ?q]
[?t2 :quantity ?q2]
;; [(= (clojure.core/abs ?q) (clojure.core/abs ?q2))]
[(= ?q (clojure.core/* -1 ?q2))]
[(not= ?t ?t2)]]
%)I was able to use a custom function
(defn opp [x y] (= x (- y))
to make it work.