Fork me on GitHub
#datascript
<
2022-07-22
>
seepel00:07:56

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

Niki21:07:31

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)

seepel22:07:51

@U050UBKAA Awesome! Thank you, that was the distinction I was missing!