Welcome! Please see the About page for a little more info on how this works.

+3 votes
in Cloud by

Can you use d/with inside a Cloud transaction function? It's not clear from the the docs if the db passed to the tx fn is one created by d/with-db.

1 Answer

+1 vote
by
selected by
 
Best answer

Found this bug and the discussions says it has been fixed https://forum.datomic.com/t/d-with-not-working-inside-tx-fn/1243

So it seems, that it should be possible.

by
I can't seem to get it to work with dev-local though, so difficult to test code:


1. Unhandled java.lang.ClassCastException
   class datomic.core.db.Datum cannot be cast to class
   java.lang.Number (datomic.core.db.Datum is in unnamed module of
   loader 'app'; java.lang.Number is in module java.base of loader
   'bootstrap')

                    tx.clj:  384  datomic.dev-local.tx/datom-lookup-valfn
                    tx.clj:  384  datomic.dev-local.tx/datom-lookup-valfn
             local_log.clj:   56  datomic.dev-local.local-log.LocalLog/valAt
                   RT.java:  760  clojure.lang.RT/get
               btindex.clj:  281  datomic.dev-local.btindex.BTIndex/cons
                   RT.java:  677  clojure.lang.RT/conj
                  core.clj:   85  clojure.core/conj
                  core.clj:   82  clojure.core/conj
                    db.clj: 2319  datomic.core.db.Db/addData
                    db.clj: 3349  datomic.core.db/add-ensured-data
                    db.clj: 3347  datomic.core.db/add-ensured-data
                    db.clj: 3366  datomic.core.db/with-tx
                    db.clj: 3353  datomic.core.db/with-tx
                    db.clj: 2161  datomic.core.db.Db/with
              local_db.clj:   67  datomic.core.local-db/fn
              local_db.clj:   24  datomic.core.local-db/fn
             protocols.clj:  126  datomic.client.api.protocols/fn/G
                   api.clj:  363  datomic.client.api/with
...