datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
unbalanced 2020-10-08T16:02:16.015100Z

You can do arbitrary predicates, but it's not well documented

unbalanced 2020-10-08T16:02:21.015300Z

let me see if I can get an example

unbalanced 2020-10-08T16:02:35.015500Z

You can also do transaction functions

unbalanced 2020-10-08T16:02:50.015800Z

IIRC the trick is to use fully qualified symbols

unbalanced 2020-10-08T16:03:58.017100Z

i.e.,

(defn my-pred=+1 [a b]
  (= a (inc b))

(d/q '[:find ?e 
       :where 
       [?e :a ?a]
       [?e :b ?b]
       [(#'my-pred ?a ?b) ?c]]
  @conn)

👍 1
lilactown 2020-10-08T16:13:39.017600Z

How does that even work under advanced compilation

zane 2020-10-08T17:01:23.018100Z

That’s interesting. What we’ve been doing is passing the predicates in as inputs to the query.

👍 1
2020-10-08T17:47:26.018500Z

I think it is even in the documentation.