This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-13
Channels
- # bangalore-clj (1)
- # beginners (29)
- # boot (13)
- # braveandtrue (5)
- # clara (5)
- # cljs-dev (42)
- # cljsrn (7)
- # clojure (55)
- # clojure-france (46)
- # clojure-nl (11)
- # clojure-portugal (1)
- # clojure-russia (268)
- # clojure-spec (26)
- # clojure-uk (32)
- # clojurescript (173)
- # clr (2)
- # core-async (46)
- # cursive (22)
- # datomic (33)
- # devcards (1)
- # emacs (5)
- # events (8)
- # figwheel (2)
- # flambo (4)
- # instaparse (8)
- # jobs (11)
- # klipse (46)
- # lein-figwheel (3)
- # london-clojurians (2)
- # nrepl (1)
- # off-topic (29)
- # om (4)
- # om-next (8)
- # pedestal (3)
- # rdf (4)
- # re-frame (51)
- # reagent (104)
- # remote-jobs (1)
- # rum (4)
- # schema (2)
- # specter (19)
- # untangled (16)
- # vim (52)
I know this is kinda silly, but is there a short cut to update a value on a nested ref? e.g.
@(d/transact
conn
[{:root-entity/_ref-attr <eid-on-hand>
:nested-ref/value-attr “updated-value"}])
like that, but obviously that clobbers the entire ref. I’m looking for more of an assoc-in
Reverse refs don't work in transactions afaik
but here’s another example for clarity. Again this doesn’t do what I’m looking to do, because it clobbers the entire ref instead of updating a value. And it’s a silly request because I know I can just use the root entity to query the entity id of the nested value and then use that to transact:
@(d/transact conn
{:db/id <the-db-id-on-hand>
:nested/ref {:ref/attr <new-value>}})
@uwo you need the id of the nested ref. Refs have identity semantics, not value semantics
right, I know that if I already have the eid or a :db.unique/identity attribute I can use that. was just wondering if there was a way to navigate from parent without first looking up
There is no way to do what you want using just transaction maps. You could write a tx function that did what you want, but it would have to work by reading
thought experiment: tx maps work by expanding to the equiv db/add. How would you expand your assoc-in to a db/add without reading the nested id?
heh. I don’t know, but I could imagine expanding a reverse reference with the parent id in the same way that lookup refs are expanded
is using reverse refs in txs a new feature?
reverse refs are no challenge, the :db/id of the map just gets put in the value slot of the :db/add instead of the entity slot
ah yeah
I always wondered why (as I though) it wasn't working because I figured the implementation would be trivial
now I know why - it did work all along 🙂
Datomic 0.9.5561 is now available https://groups.google.com/d/topic/datomic/hHfr_N6m5Q8/discussion
the idea I’m looking at is allowing certain components to depend on certain schema bits being loaded. I don’t think the component model is right for transacting the schema(s), but maybe something along the lines of a component providing the conformity ids that other components can then validate and decide what to do (rather than fail in a query).