Fork me on GitHub
#datalevin
<
2023-03-01
>
brunex18:03:41

Hi guys, I’m trying to use dtlv from babashka, when I transact, the return value is: {:datoms-transacted 3}

brunex18:03:54

says it should be

{ :db-before ...
   :db-after  ...
   :tx-data   [...]     ; plain datoms that were added/retracted from db-before
   :tempids   {...}     ; map of tempid from tx-data => assigned entid in db-after
   :tx-meta   tx-meta } ; the exact value you passed as `tx-meta
`

brunex18:03:05

is there any way of “guessing” the :db/ids of the just transacted entities?

brunex18:03:12

example of a transact:

(d/transact! conn [{:value 10 :memo "Hello " :new true}])

brunex18:03:38

now I want to know the db entity ? :db/id what would be the best approach

Huahai18:03:36

babashka is not Clojure, the objects such as Datom, Entity, etc. do not exist in that environment, only plain EDN works in there, hence the difference. Use lookup refs instead of :db/id , which are implementation details anyway.

Huahai18:03:08

We could have serialized those objects into EDN, PR welcome.

brunex18:03:04

can you give a example of what you mean by “use lookup refs” ?

Huahai18:03:12

Anywhere you expect a :db/id, a lookup ref can be used instead

Huahai19:03:51

These are low hanging fruits that are good candidates for contributing to Datalevin.

🎉 4
brunex19:03:34

checking it

Huahai17:03:25

this is fixed now