This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-15
Channels
- # admin-announcements (90)
- # beginners (36)
- # boot (169)
- # cider (18)
- # clojure (84)
- # clojure-australia (1)
- # clojure-brasil (20)
- # clojure-czech (2)
- # clojure-france (5)
- # clojure-germany (1)
- # clojure-india (8)
- # clojure-italy (39)
- # clojure-japan (14)
- # clojure-korea (2)
- # clojure-russia (9)
- # clojure-sg (1)
- # clojure-spain (16)
- # clojure-ukraine (1)
- # clojurebridge (20)
- # clojurescript (146)
- # code-reviews (48)
- # core-typed (1)
- # datomic (24)
- # editors (59)
- # euroclojure (6)
- # ldnclj (25)
- # off-topic (6)
- # onyx (3)
- # reagent (7)
Hello, I want to use an entity returned by d/touch as if it were a map, assoc'ing new keys, etc. How should I do that? Example:
(let [entity (->> (d/q '[:find ?e .
:where [?e :db/ident ]]
(d/db conn))
(d/entity (d/db conn))
d/touch)]
(assoc entity :answer 42) )
The following code is throwing a CompilerException java.lang.AbstractMethodError.
@lboliveira: why not
(let [entity (->> (d/q '[:find ?e .
:where [?e :db/ident]]
(d/db conn))
(d/entity (d/db conn))
d/touch
(into {}))]
(assoc entity :answer 42))
@hmadelaine: It worked. 😃 Thank you!
@lboliveira: not sure this is the best solution
@hmadelaine: it is small at least.
@lboliveira @hmadelaine: you should use the pull api which returns normal data
(d/pull db ‘[*] your-id-or-lookup-ref-or-entity-reference-here)
http://docs.datomic.com/pull.html
@robert-stuttaford: yes of course, I should have proposed this solution. I was to focused on the code 😉
your suggestion isn’t at all wrong. it’s just pull is more suitable
@robert-stuttaford: thank you. I will use the pull api.
From the day of datomic videos, Stu mentioned that in practise they found they pretty much put ‘index’ on everything
you don’t need to index type ref or anything with unique on it
it’s redundant in both cases. already indexed
yeah. no harm done, just no use either
leandro: EntityMaps (the return type from d/entity) are not Clojure maps. You can't assoc
them. Instead, try d/pull
, which returns real Clojure maps.
oh, scrolling, whatever
ignore me
@stuartsierra: Thank you. Now I am using the pull api. Far better.
You're welcome.