This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-21
Channels
- # admin-announcements (1)
- # beginners (3)
- # boot (242)
- # clara (1)
- # cljsrn (8)
- # clojars (2)
- # clojure (68)
- # clojure-russia (23)
- # clojure-spec (28)
- # clojure-uk (11)
- # clojurescript (7)
- # datavis (3)
- # datomic (21)
- # emacs (2)
- # events (2)
- # hoplon (56)
- # jobs (3)
- # lambdaisland (1)
- # mount (20)
- # off-topic (4)
- # om (13)
- # onyx (17)
- # other-languages (2)
- # parinfer (7)
- # proto-repl (2)
- # proton (2)
- # protorepl (53)
- # re-frame (13)
- # reagent (3)
- # ring-swagger (22)
- # specter (5)
(defn get-locations [conn]
(->> (d/q '[:find [(pull ?locations [*]) ...]
:in $
:where [?locations :location/id]]
(d/db conn))
(map c/db->loc)))
I was assuming that the wild card for the pull would recursively fetch attributes for the space
actual: ({:address "19 Foobar Street",
:postal-code "S890123",
:space {:db/id 277076930200554}}
{:address "19 Barbaz Street",
:postal-code "S123456",
:space {:db/id 277076930200554}})
I believe the space needs to be marked as :db/isComponent true
: http://blog.datomic.com/2013/06/component-entities.html
you can also recursively pull referenced entities, i believe the syntax was [* {:space [*]}]
touching is giving up 🙂
also, d/touch
only works with d/entity
results
(defn get-locations [conn]
(->> (d/q '[:find [(pull ?locations [* {:location/space [*]}]) ...]
:in $
:where [?locations :location/id]]
(d/db conn))
(map c/db->loc)))
> Wildcard Specifications The wildcard specification * pulls all attributes of an entity, and recursively pulls any component attributes:
this was from http://docs.datomic.com/pull.html
@jethroksy just to note this, that documentation specifies component attributes only, and those attributes are set with isComponent/true :: https://github.com/Datomic/mbrainz-sample/blob/master/schema.edn#L266 — also see the blog post: http://blog.datomic.com/2013/06/component-entities.html (though that’s in the context of touch
, same applies to pull wildcard pull spec).