Migrating from clj-time to java-time

Hey! Looking at the internals our datomic api we do have some automatic conversion going on. This is my first time diving into that code, but here is what I can understand from skimming it:

The way we wire up automatic conversions is by introducing a new :db/transformer attribute to our datomic schemas.
Then our LocalDateTimes are stored as insts with the :db/transform attribute set to :date-time.

To store and retrieve values tagged with :date-time we essentially do (fn [inst] (java.time.LocalDateTime/ofInstant (java.time.Instant/ofEpochMilli (.getTime inst)) java.time.ZoneOffset/UTC)) and (fn [local-date-time] (-> local-date-time (.toInstant java.time.ZoneOffset/UTC) .toEpochMilli java.time.Date.)) respectively.
We use this setup for other data-types like edn and urls.

What is especially nice about all this and allows developers to ignore all these details, is that we have a plumatic schema to datomic schema converter. Engineers interact with datomic by manipulating objects that satisfy plumatic schemas. Under the hood plumatic schemas are registered with datomic automatically and values read from datomic are transformated automatically.

Of course, take all this at face value; I am simply a user of this setup and am skimming the code for the first time. For instance, there seems to be plenty of caching and lazy resolution of datomic results to make the whole plumatic thing work

3 Likes