is it possible to access :db/txInstant via presto/analytics/metaschema?
Could you provide an example?
https://docs.datomic.com/analytics/analytics-metaschema.html
It’s possible to access as a table, and join where tx is a value (column) in another table
It’s not possible to get the “tx” slot of a datom, as that is lost when projecting to a table
I don’t have an example but it’s no different than any other table
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…”)
so basically, we need to have created-at and updated-at fields, as our ancestors did, if we want to access via SQL
The granularity of a tx is a single assertion (e + a + v, table + column + row). Created-at/updated-at is table + row
The reason tx is not available via presto is the rectangle/table model simply doesn’t have a natural place to put it
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
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
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.
"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?
I still don't undestand how to access the 4th element of the tuple.
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.