Datomic.promise

The docs here show getting a map back from a transact but instead I get a datomic.promise object.

#object[datomic.promise$settable_future$reify__7710 0x5a659c9 {:status :ready, :val 
{:db-before datomic.db.Db@2c83a113, :db-after datomic.db.Db@c3049cad, :tx-data 
[#datom[13194139534338 50 #inst "2019-07-23T22:48:36.645-00:00" 
13194139534338 true] #datom[17592186045443 97 "content!" 13194139534338 
true]], :tempids {-9223301668109598061 17592186045443}}}]

This object does not appear to be documented. How do I work with it?

Your example appears to be the return value from a call to the Peer API transact, which returns a future (https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/transact). You can get the result map from the future by dereferencing it:

@(d/transact conn [[:db/add "bar" :db/doc "foo"]])
;; Or
(deref (d/transact conn [[:db/add "bar" :db/doc "foo"]]))

The Client API (which is used in the example you referenced) returns the result map directly (https://docs.datomic.com/client-api/datomic.client.api.html)

1 Like

Thanks, Marhshall!