Fork me on GitHub
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?


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


Those instants will allow you to get the database values.


Mixing cloud and on-prem above. 🙈


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
  [?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 
  [?a :db/ident]
  [?e ?a ?v ?tx ?op]]
Where $ is the db-after

👍 1

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.


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


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


it’s lacking many features


Hmm, it doesn't say anything about embedding, so not sure if that's an ok or not...


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.


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


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


worth asking directly if you are unsure


donno about dev-local


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 😃...


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]: • [1]:


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


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.