This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-07
Channels
- # announcements (12)
- # autochrome-github (4)
- # babashka (27)
- # babashka-sci-dev (2)
- # beginners (80)
- # calva (34)
- # cider (8)
- # clj-kondo (77)
- # clojars (34)
- # clojure (50)
- # clojure-europe (35)
- # clojure-nl (4)
- # clojure-uk (5)
- # clojured (2)
- # clojurescript (26)
- # core-async (4)
- # cursive (4)
- # datahike (4)
- # datomic (40)
- # emacs (7)
- # etaoin (1)
- # fulcro (12)
- # google-cloud (143)
- # hyperfiddle (1)
- # integrant (2)
- # jobs (1)
- # malli (15)
- # membrane (17)
- # off-topic (38)
- # pathom (1)
- # reagent (4)
- # releases (2)
- # remote-jobs (2)
- # sci (1)
- # shadow-cljs (10)
- # spacemacs (7)
- # tools-deps (5)
- # vim (6)
- # xtdb (37)
In this https://clojurians.slack.com/archives/C03RZMDSH/p1618440859298300 from last year, there is an example pull call like so:
(d/pull (d/db conn) '[:user/type] [:user/id "a"])
=> #:user{:type #:db{:id 87960930222153, :ident :user.type/a}}
The returned value for :user/type has the :db/id and the :db/ident.
When I run a similar pull, I only get the :db/id. If I want the :db/ident value then I have to put it in the pull pattern explicitly. My schema is very similar to the enumerations example in datomic docs.
Any ideas why I don't see the :db/ident
key/value in my returned map?when you don’t specify what to retrieve from a ref attribute (i.e. you did [:user/type]
not [{:user/type [:my/attr]}]
, what happens depends on the isComponent-ness of the attribute
Thanks. Agreed about specifying the attributes. I was curious about the difference in results.
@U09R86PA4 any hint on this ^^?
With datomic on-prem, what is the return type of custom aggregation functions? The one example that I have found is in the docs and returns a single value for making an aggregate that returns only 1 item, but how does this work when the aggregation function wants to return N items? And if the answer is simply to return a sequence, how does datomic keep track of the order of the items? I would assume it can't be metadata since not all types that datomic can store can have metadata.
> And if the answer is simply to return a sequence, how does datomic keep track of the order of the items?
results may be unordered, but the results from an aggregation may be tied to other values, in e.g. this query:
[:find ?title (max n ?year)
:in $ n
:where [?entity :movie/year ?year]
[?entity :movie/title ?title]]
Oh, then maybe I have misunderstood how exactly this works. My understanding was that it would attempt to take the top n
title/year pairs based on the year.
Hmm. Is there a way to do this?
if that’s not an option, a custom aggregate which accepts a tuple of all results and does the sort and top-n inside of it
if you’re on on-prem, there is no overhead to sorting all results outside the query--that data was literally all just fetched in your peer anyway, and the full result set already made, so nothing is saved by pushing that work into the query
for client api, sometimes that result went over a wire, so yeah, it would be nice to reduce the result size before returning it
right, that makes sense.
Thanks!
Hi. Is it possible to specify a txInstant
value directly within a pullspec?
I know that my entity was transacted in a oner
(but I suppose datomic cannot assume that...)
oh? How would I do that?
I mean; can I do that within the single call to (d/transact
?
or do I have to make a second transaction to poke the tx ref into the domain entity?
"datomic.tx"
is the tempid of the current transaction, so yes, like this [:db/add my-entity :ref-to-tx "datomic.tx"]
perfect. thankyou
you can also set db/txInstant (in some circumstances) the same way: https://docs.datomic.com/cloud/transactions/transaction-processing.html#explicit-txinstant
well. I'm too lazy to put an explicit timestamp into my domain entity
Tread carefully. I feel like most uses of the tx entity for domain info are better suited to be modeled with attributes under your control.
so I am hoping to get a timestamp for free
thanks