Fork me on GitHub
#datomic
<
2022-07-05
>
Quentin Le Guennec07:07:33

Hello, is there a way to get the transaction data (db-before, db-after, tx-data, etc) as when a given entity was last transacted in the database?

jcf10:07:42

You can query for the transactions associated with a particular entity and get each transaction instant.

jcf10:07:55

Those instants will allow you to get the database values.

jcf11:07:55

Mixing cloud and on-prem above. 🙈

souenzzo16:07:50

Find the "given entity was last transacted in the database" Well, an entity has many attributes. Each attribute has its last transaction. For now, we will ignore the attributes and get the "newer one"

'[:find (max ?tx)
  :in $ ?e
  :where 
  [?e _ _ ?tx]]
Now we can use (d/as-of db tx), as @U06FTAZV3 said, to get the :db-after To get :db-before is a little tricky: (d/as-of db (dec tx)) The :tempids values is impossible to "recreate" The tx-data value is tricky too:
'[:find ?e ?a ?v ?tx ?op 
  :in $ ?tx 
  :where 
  [?a :db/ident]
  [?e ?a ?v ?tx ?op]]
Where $ is the db-after

👍 1
folcon11:07:21

I'm almost certain the answer to this is going to be no, but is there a version of datomic that is embeddable? If I was writing an application that was deployed to end-users for example? Is there some flavour of datomic that I can bundle into a dmg? I have an application that I've been writing that needs to run both in the cloud and as a local instance. I've been handling the local version via datascript, but now that requirements have shifted, I'm wondering if swapping to datomic makes sense. If I do end up doing that, it would be nice to be able only have to worry about one type of db.

favila12:07:05

I think datomic-free license allows embedding and redistribution, but check.

favila12:07:28

datomic-free is a very old datomic on-prem though

favila12:07:35

it’s lacking many features

folcon13:07:34

Hmm, it doesn't say anything about embedding, so not sure if that's an ok or not... https://www.datomic.com/datomic-free-edition-license.html

folcon13:07:51

Hmm, ok, what about dev-local, I can't seem to find the license for that, I'm assuming it's a no by default, but would be good to check.

favila13:07:06

I think section 3 and 4 together allow datomic-free embedding with restrictions

favila13:07:38

NAL and not speaking for Cognitect but I believe that was the intent

favila13:07:48

worth asking directly if you are unsure

favila13:07:04

donno about dev-local

folcon13:07:16

Yea, it would be good if someone from cognitect can answer this 😃... If the response is a no, that's fine. Just want some clarity 😃...

folcon13:07:46

Hmm, ok, this thread[0] is a little concerning, on the one hand it seems like what you're suggesting with datomic free may be acceptable behaviour, Joe[1] says we need something to include as a dependency for our libs and Marshall doesn't tell him that he's not allowed to do that. So this is perhaps viable. On the other hand, it seems like there's no further movement on this, so if I proceed here I'll have to accept some divergence between my embedded and cloud / ions versions, which is frustrating. It may be worthwhile seeing if datascript may be the answer to the local embedded approach and then see how much api difference exists between it and cloud / ions. Alternatively datascript written straight to s3 or dynamodb may also be viable. Thanks for the suggestion @U09R86PA4 =)... • [0]: https://forum.datomic.com/t/datomic-free-being-out-phased/1211/9 • [1]: https://forum.datomic.com/t/datomic-free-being-out-phased/1211/7

Huahai00:07:25

There are several alternatives that are embeddable, e.g. Datalevin, Datahike, Asami, etc.

folcon15:07:47

Sure, though with those there's some question around what difference of api exist? I do want to take a small but complex example and try and benchmark it within various dbs.