This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-19
Channels
- # announcements (4)
- # asami (1)
- # babashka (48)
- # beginners (84)
- # bristol-clojurians (1)
- # calva (15)
- # chlorine-clover (11)
- # cider (37)
- # clj-kondo (17)
- # clojure (72)
- # clojure-europe (13)
- # clojure-italy (43)
- # clojure-nl (6)
- # clojure-spec (8)
- # clojure-uk (19)
- # clojuredesign-podcast (7)
- # clojurescript (132)
- # code-reviews (7)
- # conjure (3)
- # cursive (24)
- # datascript (10)
- # datomic (61)
- # docker (4)
- # duct (24)
- # emacs (2)
- # figwheel-main (8)
- # fulcro (43)
- # graalvm (5)
- # juxt (1)
- # keechma (14)
- # malli (2)
- # off-topic (120)
- # re-frame (111)
- # reagent (6)
- # reitit (13)
- # shadow-cljs (118)
- # spacemacs (3)
- # tools-deps (32)
- # uncomplicate (5)
- # xtdb (6)
I guess you need [(< 0 ?p)]
to express a predicate, right now datascript thinks it's a rule expression.
https://docs.datomic.com/on-prem/query.html#expression-clauses
wondering if some one can help I am playing with datascript and the a bit confused on :db/ref if i query some thing that has a ref I get it returned as #:db{:id 1} can that not auro resolve back the attributes ?
(def schema {:type/id {:db/unique :db.unique/identity}
:product/id {:db/unique :db.unique/identity}
:product/type {:db/valueType :db.type/ref}})
(def conn (d/create-conn schema))
(d/transact!
conn
[{:type/id 1 :type/name "type 1"}
{:type/id 2 :type/name "type 2"}
{:product/id 1 :product/name "p1" :product/type [:type/id 1]}
{:product/id 2 :product/name "p2" :product/type [:type/id 2]}])
(d/q '[:find (pull ?e [*])
:where
[?e :product/id]] @conn)
That's my simple example which returns
0. [ { :db/id 4, :product/id 1, :product/name "p1", :product/type { :db/id 1 } } ]
I am wondering if I can make it return :type/name in the row and other type related attributes instead of :product/type {:db/id 1}
feel free to point me at docs, could be I have just been missing or mis understanding how it works
@oliver.marks I believe *
only gets all of the attributes one level deep. you could try playing around with something like:
(d/q '[:find (pull ?e [* {:product/type [*]}])
:where
[?e :product/id]] @conn)
@lilactown spot on that's works perfectly 🙂