datomic

souenzzo 2025-07-04T17:44:14.460529Z

is it possible to access :db/txInstant via presto/analytics/metaschema? Could you provide an example? https://docs.datomic.com/analytics/analytics-metaschema.html

favila 2025-07-04T19:37:37.886249Z

It’s possible to access as a table, and join where tx is a value (column) in another table

favila 2025-07-04T19:38:34.125779Z

It’s not possible to get the “tx” slot of a datom, as that is lost when projecting to a table

✅ 1
favila 2025-07-04T19:38:51.091569Z

I don’t have an example but it’s no different than any other table

favila 2025-07-09T11:20:21.916539Z

Correct. You can access tx when it is an E (“access as a table”) or a V (“join where tx is a value”). You cannot access tx when it is a TX (“not possible to get the ‘tx’ slot…”)

👍 1
souenzzo 2025-07-09T11:37:34.805429Z

so basically, we need to have created-at and updated-at fields, as our ancestors did, if we want to access via SQL

🤣 1
favila 2025-07-09T11:41:59.644519Z

The granularity of a tx is a single assertion (e + a + v, table + column + row). Created-at/updated-at is table + row

favila 2025-07-09T11:43:58.140259Z

The reason tx is not available via presto is the rectangle/table model simply doesn’t have a natural place to put it

favila 2025-07-09T11:50:02.605509Z

Here are two alternatives: entity attribute value columns (ie just datoms), but no SQL-ista would prefer that, and typing means you need a different column or table per V type. Or a new _tx virtual column per column, so you get twice as many columns

souenzzo 2025-07-09T11:52:48.340429Z

Maybe access via an extra __tx in the field SELECT user__name__tx FROM user And we could control which fields have it in Metaschema file

cch1 2025-07-09T14:01:56.886439Z

I have found value in adding two globally applicable schema attributes: st.db/created-by and st.db/updated-by which point to the relevant transaction entity. The bonus is that I have access to any additional tx metadata (like attribution/who and provenance and ...) for "free". So these attrs get you more than just the -at of our ancestors timestamps. Also, https://vvvvalvalval.github.io/posts/2017-07-08-Datomic-this-is-not-the-history-youre-looking-for.html.

cch1 2025-07-07T13:16:08.472949Z

"It’s possible to access as a table, and join where tx is a value (column) in another table" This sounds like the technique where you have a ref attribute in an entity that refers to the asserting tx. I name mine :mycompany.db/tx and add them in some cases where I want pull and/or analytics to have access to the tx . Is there another way?

souenzzo 2025-07-07T16:51:55.948809Z

I still don't undestand how to access the 4th element of the tuple.

cch1 2025-07-07T17:42:15.551719Z

AFAIK, it's not possible to access it directly. You must create an attribute that points to the desired transaction (a create tx or perhaps an update tx). I would love to be wrong on this.