Fork me on GitHub
#datomic
<
2019-11-19
>
onetom05:11:00

how can i access the result of a built-in transaction function like :db/retractEntity so i can modify it? i would need to replace some of the retractions with assertions containing new computed values

onetom06:11:47

answering my question:

(->> :db/retractEntity (d/entity db) d/touch :db/code)
reveals how it works:
=> "(clojure.core/fn [db e] (datomic.builtins/build-retract-args db e))"
and indeed it works:
(datomic.builtins/build-retract-args db :x)
=> [[2 17592186045418 10 :x]]
however, since it's not documented anywhere, im bit hesitant to use it 😕

❤️ 4
favila12:11:33

Use d/invoke instead

favila13:11:40

(d/invoke db :db/retractEntity db :x)

❤️ 12
Dustin Getz16:11:20

Datomic forum is down

Alex Miller (Clojure team)16:11:57

seems operational to me?

adamfeldman16:11:01

I also saw it was down, back up for me too

Dustin Getz16:11:18

Still down for me

mavbozo16:11:29

I still can not connect to datomic forum

dvingo19:11:12

not sure why this isn't on the datomic site (at least that I could see), or why there's no testing page in general, but this is super useful: https://www.youtube.com/watch?v=JaZ1Tm6ixCY

👍 12
dvingo20:11:41

hmm, not as useful as I thought - it looks like a db created from the datomic.api ns cannot be passed to (d/q) in datomic.client.api..

dvingo20:11:59

Getting: Query args must include a database when doing so

dvingo20:11:14

(shrug) will just do this then:

(defn get-user-settings*
  ([db username]
   (get-user-settings* d/q db username)) ;; <-- this is datomic.client.api 
  ([q db username] ;; <-- in tests pass in datomic.api/q
   (->> (q query-all-settings db username)
        xform-user-settings)))

csm21:11:53

someone wrote a lib for testing datomic.client.api with an in-mem DB; I think it’s this: https://github.com/ComputeSoftware/datomic-client-memdb

dvingo21:11:46

ooh very cool. I'll take a look, thank you