This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-25
Channels
- # aleph (18)
- # announcements (7)
- # asami (18)
- # babashka (15)
- # babashka-sci-dev (79)
- # beginners (61)
- # calva (4)
- # clj-kondo (23)
- # cljfx (16)
- # cljs-dev (6)
- # clojure (63)
- # clojure-bay-area (3)
- # clojure-europe (33)
- # clojure-nl (1)
- # clojure-survey (4)
- # clojure-uk (5)
- # clojurescript (136)
- # conjure (1)
- # cursive (8)
- # datahike (7)
- # datalevin (1)
- # datomic (30)
- # emacs (10)
- # events (2)
- # figwheel (2)
- # fulcro (20)
- # google-cloud (1)
- # lsp (6)
- # luminus (4)
- # malli (5)
- # music (3)
- # nextjournal (1)
- # off-topic (9)
- # other-languages (3)
- # pathom (16)
- # polylith (34)
- # re-frame (14)
- # reagent (19)
- # releases (6)
- # sci (2)
- # shadow-cljs (33)
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
thankswhen I’m fetching a datomic entity, is there a way to get the timestamp of the transaction too?
(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)
gives:
[[17592186045418] [17592186045419] [17592186045420]]
But what about the time when the entity was created?did you find: https://github.com/Datomic/day-of-datomic/blob/master/tutorial/time-rules.clj
although, getting stuff from the history is slower than from the present
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
(This is the concept being referred to: https://vvvvalvalval.github.io/posts/2017-07-08-Datomic-this-is-not-the-history-youre-looking-for.html, 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?
@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?
you can assert that attributes are present
but; I believe that to only be positive, so only that an entity has certain attributes; not that it cannot have others
(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.
I stand corrected, I was talking about the required attribute feature
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?
Just to close the loop: I used this docker: https://github.com/alexanderkiel/datomic-free 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