clojure - Use event time instead of transaction time in Datomic? -


background

i'm using datomic store projections of events generated other systems (projections in case can regarded entity in datomic). these events have timestamp associated them tells when event (for example) created. not same transaction time datomic assign transaction when stores new attribute (based on event) in projection. users of application not interested in transaction time rather event time. reason why i'm using datomic in first place able entity (or query database) @ specific time. time should not datomic transaction time rather event time. example want able entity based on event time:

(datomic/entity (datomic/as-of db event-time) id) 

possible solution

one idea i'm thinking of set :db/txinstant each transaction event time i've been advised not general principle. potential problem can't assign :db/txinstant older schema (which will case in application). solution set :db/txinstant transaction creating schema.

question

how 1 typically deal event time rather transaction time in datomic? how "possible solution" hold up?

in general, datomic's transaction time (t) intended record when system found out fact, not domain time of fact.

if need handle domain time (i.e. time occurred in 'real world', or event time in example), i'd recommend modeling domain time explicitly attribute (you can use attribute of type :db.type/instant). allow set dates without restriction query both domain time , system time separately questions "when did x happen , when did database find out x happening?".


Comments