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

+1 vote
in On-Prem by
retagged by

Hello folks,

Is there a precise relation between db's T value and the txInstant of an entity?

I have a database and if I do (:t db) I get 7 as value. Fair.

Meanwhile, if I look for a :db/txInstant for an entity via (def query '[:find ?tx :where [?e :person/id _ ?tx]]) I get very long number.

What is the relationship between the two? To give some context, what I am trying to do is:

"Given a certain entity ID, what was the latest t that has introduced/updated such entity?

1 Answer

0 votes
by
selected by
 
Best answer

Hi!

The relationship between t and tx is that each transaction has an associated t time. Every t has associated tx(s). You can use the Datomic On-Prem peer api t->tx api to return the associated txid(s):

https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/t->tx

Alternatively, you can use Datomic On-prem peer api tx->t api to return the t associated with a transaction:

https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/tx->t

by
Thanks a lot or the reply. I've figured it yesterday but good to leave this here for clarity!
by
I have noticed by the way that the Datomic API namespace is in the `com.datomic/datomic-free` and not in dev-local.
...