Fork me on GitHub
Andrej Golcov10:02:50

Hi, One more question, related to my previous question. We have parent-child relations in datomic, something like:

 { :rootId "1" :childIds [{:childType "a" :childId "2"} {:childType "b" :childId "3"}]}
 { :rootId "2" :childIds [{:childType "b" :childId "4"}}
IOW, root entity references child enitity. Child entity has a type ("a", "b" in the example above) Q: how I can query all root entities with child entities of specific type (e.g. "a") or nil/defaultValue if there is not such childType (kind of outer join). For example above, I need the following rows:
rootId - childIdOfTypeA
"1" - "a"
"2" - nil/orSomeDefaultValue


when I’m fetching a datomic entity, is there a way to get the timestamp of the transaction too?


which transaction?


(def first-movies [{:movie/title "The Goonies"
                    :movie/genre "action/adventure"
                    :movie/release-year 1985}
                   {:movie/title "Commando"
                    :movie/genre "action/adventure"
                    :movie/release-year 1985}
                   {:movie/title "Repo Man"
                    :movie/genre "punk dystopia"
                    :movie/release-year 1984}])
(d/transact conn {:tx-data first-movies})
I can get entities:
(def all-movies-q '[:find ?e 
                    :where [?e :movie/title]])
(d/q all-movies-q db)
[[17592186045418] [17592186045419] [17592186045420]]
But what about the time when the entity was created?

Lennart Buit16:02:13

although, getting stuff from the history is slower than from the present


> But what about the time when the entity was created?


“creation” has an application-defined meaning


You could ask for the time an entity id was minted (i.e. a tempid in tx-data was replaced with a new entity id), but that’s likely not meaningful to the application except with a pile of assumptions. You can do this because the “T” part of the entity id interleaves with the T of the transaction entity


(although I’m not sure this is true in cloud--I’ve heard rumors it isn’t)

Lennart Buit16:02:13

(This is the concept being referred to:, you shouldn’t use the history for your applications core functionality. You could use it for auditing purposes)


just the time of the entity tx, is there a way to get it by default? If not what’s the idiomatic way to store the entity time?


does :db/txInstant exist by default?


> If not what’s the idiomatic way to store the entity time?


make an attribute, and write the appropriate time


> does :db/txInstant exist by default


it always exists, but only on the transaction entity


@U01F1TM2FD5 you have one "modified date" for each attribute/value in the entity


Is there a way to ensure that when I’m transacting an entity, that certain attributes exist in the tx and others don’t, or is it something that should be checked in the application level?

Lennart Buit16:02:48

you can assert that attributes are present

Lennart Buit16:02:06

but; I believe that to only be positive, so only that an entity has certain attributes; not that it cannot have others

Lennart Buit16:02:50

(like how maps are ‘open’ in clojure as well, intentionally)


The entity predicate can do anything it wants, including check that an attribute is not asserted.


but without writing code, entity specs can only require that an attribute is asserted

Lennart Buit16:02:56

I stand corrected, I was talking about the required attribute feature

Lone Ranger18:02:40

I have a really old .h2 datomic database file that I need to recover some data from. We have a pro on-prem license. Is there any way I can access that without having to build a special purpose project with datomic free?

Lone Ranger18:02:15

Just to close the loop: I used this docker: and attached the data directory as a volume, then I was able to use

(d/get-database-names "datomic:")
to get the name of the databases and recover the data


you can use the dev mode storage in datomic pro