This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-22
Channels
- # announcements (7)
- # babashka (17)
- # beginners (45)
- # biff (2)
- # cider (16)
- # clj-on-windows (3)
- # cljs-dev (12)
- # clojure (27)
- # clojure-austin (1)
- # clojure-europe (18)
- # clojure-norway (5)
- # clojurescript (36)
- # conjure (35)
- # core-async (2)
- # datascript (4)
- # datomic (4)
- # emacs (15)
- # fulcro (23)
- # holy-lambda (12)
- # hyperfiddle (1)
- # introduce-yourself (5)
- # nbb (11)
- # off-topic (37)
- # pathom (34)
- # pedestal (9)
- # reitit (4)
- # releases (1)
- # remote-jobs (1)
- # sci (5)
- # scittle (3)
- # shadow-cljs (88)
- # tools-build (4)
I'm trying to execute a query using the missing?
rule should I expect this to work?
(d/q '[:find ?e
:where (missing? $ ?e :parent)]
@conn)
I get an error about not passing rules in, do I need push built-in rules myself? If so, where would I find them?
Missing rules var '%' in :in
From the tests, it looks like missing?
is a built-in rule: https://github.com/tonsky/datascript/blob/cd129b7a9ef2fc31fa95873c376691f272752832/test/datascript/test/query_fns.cljc#L47-L52
There are two things:
• missing is built-in predicate, not rule. Datomic and DataScript make a distinction between the two. To invoke rule you go (rule-name args...)
and to invoke predicate [(pred-name args...)]
• predicates should work on existing vars, they can’t define their own. Think of them as function calls. [(missing? $ ?e :parent)]
means “from all known ?e that we’ve seen so far, only keep those that return truth in (missing ?e :parent)”. But ?e must already be defined somehow, normally through simple pattern-matching
Try
(d/q '[:find ?e
:where [?e _ _]
[(missing? $ ?e :parent)]]
@conn)
@U050UBKAA Awesome! Thank you, that was the distinction I was missing!