Fork me on GitHub
#datomic
<
2023-01-29
>
hanDerPeder21:01:26

Does datomic expose the function called by transact that turns a map into a vector of datoms?

ghadi22:01:07

No but it is straightforward to convert

ghadi22:01:37

The id of the map becomes the e of every assertion

hanDerPeder22:01:05

sure, but it's a strange thing to omit, right? It's right there!

ghadi22:01:50

What do you need it for?

hanDerPeder23:01:21

Integrating with malli. Datomic schema is generated from malli schema and I run a malli transformer over every attribute that needs encoding. Instants to dates, etc. Easier to do that generically if the transaction data is a flat list of datoms.

ghadi01:01:53

There is no special magic. descend into nested maps.. i feel like a schema transformer would have just as easy time on kvs inside maps, as much as the kv in the vec form

ghadi01:01:08

I guess, why transform at all?

👍 2
hanDerPeder05:01:31

:thinking_face: good point

souenzzo08:01:48

This transformation is not simple. It should consider nested relations, tuples, etc. Will be schema dependent. maybe use d/with and get the :tx-data from the results ?

☝️ 2
souenzzo12:01:51

btw, into a vector of datoms does not make sense. Some operations, like :db/cas can't be represented as :db/add operations.