This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-18
Channels
- # atom-editor (5)
- # babashka (15)
- # beginners (80)
- # calva (11)
- # cestmeetup (6)
- # chlorine-clover (15)
- # cider (22)
- # circleci (3)
- # clojure (57)
- # clojure-europe (19)
- # clojure-italy (1)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-switzerland (1)
- # clojure-uk (88)
- # clojurescript (92)
- # code-reviews (1)
- # cursive (6)
- # data-science (5)
- # datascript (6)
- # datomic (12)
- # events (7)
- # figwheel-main (2)
- # fulcro (55)
- # graalvm (2)
- # helix (6)
- # juxt (6)
- # kaocha (11)
- # luminus (2)
- # off-topic (82)
- # pathom (27)
- # portal (1)
- # re-frame (3)
- # reitit (25)
- # remote-jobs (8)
- # sci (11)
- # shadow-cljs (29)
- # slack-help (2)
- # spacemacs (9)
- # specter (4)
- # sql (9)
- # tree-sitter (1)
- # uncomplicate (1)
- # xtdb (26)
Hi, I'm getting started with datascript and I'm confused at what is probably a dumb newbie error. I have a query expression
(d/q '[:find ?t :where [?t :tile/pop ?p] (< 0 ?p)] db)
where 'db' is a db value. I want to get all entities with a :tile/pop greater than 0. I'm getting an error that says "Missing rules var '%' in :in". I don't believe that I really need an :in here at all. But if I add ":in %", I get another confusing error "Don't know how to create ISeq from: clojure.lang.Keyword". I'm not really sure how to interpret these errors.try adding :in $
?
and just a shot in the dark, but maybe try (> ?p 0)
instead?
the first error indicates that writing conditions like (< ...)
needs a "rules" collection passed in. that means including, at minimum the database (`$`) and rules (`%`) in :in $ %
and as arguments in the same order.
but <
and >
should be built-in and not need a rules object. at least that's how it works in Datomic; I'm not sure about DataScript.
> In ClojureScript, custom query functions and aggregates should be passed as source instead of being referenced by symbol (due to lack of `resolve` in CLJS) > — https://github.com/tonsky/datascript#project-status @ochuckles Probably this? ☝️:skin-tone-2: Try something like:
(d/q '[:find ?t
:in $ ?<
:where
[?t :tile/pop ?p]
[(?< 0 ?p)]]
db
<)
EDIT: Probably not this! See @encube.ul’s comment below.