This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-25
Channels
- # aleph (6)
- # beginners (6)
- # boot (94)
- # cider (34)
- # cljs-dev (36)
- # cljsrn (12)
- # clojure (124)
- # clojure-dev (41)
- # clojure-dusseldorf (6)
- # clojure-italy (3)
- # clojure-norway (1)
- # clojure-russia (161)
- # clojure-sg (7)
- # clojure-spec (71)
- # clojure-uk (95)
- # clojurescript (38)
- # core-async (16)
- # cursive (14)
- # data-science (1)
- # datascript (12)
- # datomic (15)
- # emacs (22)
- # funcool (2)
- # hoplon (15)
- # jobs-rus (2)
- # juxt (9)
- # liberator (7)
- # lumo (1)
- # off-topic (136)
- # onyx (24)
- # pedestal (39)
- # perun (2)
- # planck (20)
- # re-frame (23)
- # spacemacs (31)
- # unrepl (5)
- # untangled (1)
- # vim (1)
- # yada (29)
I think I don't understand how or is supposed to work, I've tried many combinations found in the tests but can't get anything working. (tests: https://github.com/tonsky/datascript/blob/master/test/datascript/test/query_or.cljc)
The result of that query is an error #object[Error Error: Cannot compare :something to [?fail-or-success :item/succ ?entity]]
(let [conn (ds/create-conn
{:items {:db/valueType :db.type/ref :db/cardinality :db.cardinality/many}
:item/succ {:db/valueType :db.type/ref :db/cardinality :db.cardinality/one}
:item/fail {:db/valueType :db.type/ref :db/cardinality :db.cardinality/one}})
rules '[[(fail-or-success ?e ?i) [?e :item/succ ?i]]
[(fail-or-success ?e ?i) [?e :item/fail ?i]]]]
(ds/transact! conn [{:db/id -1 :items [-2 -3 -4]}
{:db/id -2 :something :successful}
{:db/id -3 :something :in-progress}
{:db/id -4 :something :failing}
{:db/id -5 :item/succ -2}
{:db/id -6 :item/fail -4}])
(ds/q '[:find (pull ?items [*]) (pull ?e [*])
:in $ %
:where
(fail-or-success ?e ?i)
[?items :items ?i]]
@conn rules))
=>
([{:db/id 1, :items [{:db/id 2} {:db/id 3} {:db/id 4}]}
{:db/id 5, :item/succ {:db/id 2}}]
[{:db/id 1, :items [{:db/id 2} {:db/id 3} {:db/id 4}]}
{:db/id 6, :item/fail {:db/id 4}}])