This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-10
Channels
- # babashka (37)
- # babashka-sci-dev (22)
- # beginners (16)
- # biff (12)
- # calva (40)
- # cider (6)
- # clj-kondo (7)
- # clojure (183)
- # clojure-austin (20)
- # clojure-doc (22)
- # clojure-europe (16)
- # clojure-nl (2)
- # clojure-norway (39)
- # clojure-romania (1)
- # clojure-uk (9)
- # clojuredesign-podcast (9)
- # clojurescript (29)
- # core-typed (66)
- # cursive (19)
- # data-science (14)
- # docker (5)
- # fulcro (6)
- # hyperfiddle (46)
- # java (5)
- # malli (19)
- # missionary (3)
- # off-topic (84)
- # pedestal (5)
- # portal (36)
- # reitit (35)
- # releases (2)
- # shadow-cljs (30)
- # web-security (2)
- # yamlscript (1)
@tony.kay is there a way to get :db/id
of an entity from the auto-generated datomic resolvers in fulcro-rad-datomic? It seems that com.fulcrologic.rad.database-adapters.datomic-common/fix-id-keys
makes it go away 🥲
Context: I need to sort entities by creation date but do not have any attribute tracking it, and pull doesn’t make it possible to get the transaction timestamp. But I have been told that the value of db/id contains a time component, that I could extract and use for this purpose. I just need to figure out how to get it out of the resolvers…
fix-id-keys (result = {:db/id 79164837200017, :order-line/id #uuid "018a1478-8d0f-8781-a404-059c1cd9cbd8", ...} => {nil 79164837200017, :order-line/id #uuid "018a1478-8d0f-8781-a404-059c1cd9cbd8", ...}
- so db/id becomes nil, I believe due to this line https://github.com/fulcrologic/fulcro-rad-datomic/blob/main/src/main/com/fulcrologic/rad/database_adapters/datomic_common.clj#L109 (since id-key in this context is nil, b/c for some reason it isn’t included in the query [and even if it was, db/id wouldn’t be preserved]). Any tips? 🙏
I think you’re looking at native ID support, where you don’t use UUIDs. So, you can mark attributes as identity and native. The native will use :db/id and rename it (as that line is doing), but only if it is marked as native. If it isn’t marked as native, then you could just add a :long attribute to your RAD model named :db/id and set it’s ao/identities to all of the id
attributes that you want it to be supported by
The :db/id renaming shouldn’t happen if native isn’t marked, but there could be a bug for that since no one has ever tried it.
Yeah, that line of code you’re pointing to should ONLY rename it if it is marked as native. That’s a bug
> If it isn’t marked as native, then you could just add a :long attribute to your RAD model named :db/id and set it’s ao/identities to all of the id
attributes that you want it to be supported by
Yes, that is what I tried to do, and I guess the :ladybug: got in the way.