This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-10
Channels
- # announcements (9)
- # aws (11)
- # babashka (37)
- # beginners (97)
- # biff (2)
- # calva (73)
- # clj-kondo (17)
- # cljfx (3)
- # clojure (89)
- # clojure-europe (45)
- # clojure-norway (12)
- # clojurescript (17)
- # datahike (8)
- # datomic (13)
- # deps-new (4)
- # figwheel-main (1)
- # graalvm (2)
- # hyperfiddle (8)
- # introduce-yourself (6)
- # leiningen (38)
- # lsp (57)
- # malli (13)
- # nbb (46)
- # off-topic (40)
- # pathom (3)
- # polylith (8)
- # rum (4)
- # shadow-cljs (14)
- # spacemacs (1)
- # sql (11)
- # xtdb (10)
Stumbled over a strange behaviour the other day. Wonder if this is known before I try to create a minimal reproducing example.
When using a map ::xt/id
with metadata in a transaction including ::xt/match
and ::xt/put
ops, the transaction seems to be committed, but has no effect. Or maybe it does create a new document, not sure. Fetching the document by ::xt/id
without metadata later on does not include any changes introduced by the ::xt/put
.
I stumbled across this by using select-keys
to build my ::xt/id
from some properties of my entity map. The entity map has metadata that was preserved by select-keys
. Explicitly removing this metadata with (with-meta (select-keys entity keyseq) nil)
does the trick for me.
I don't think metadata is not serialized in xtdb and actually we ended up trimming/converting in application code cause we also ran into some kind of REPL problem
I created an issue for this, including a reproducing example: https://github.com/xtdb/xtdb/issues/1799
Hello, i’m new to clojure and xtdb, i want to order some players by player name, but want to return the whole entity.
(xt/q (xt/db node) '{:find [n (pull e [*])]
:where [[e :player/name n]
[e :xt/id id]]
:order-by [[n :asc]]})
;; => ["Breshad Perriman", {:player/name "Breshad Perriman", ... rest of keys/vals of entity
Can i order without returning the name first, just the whole entity?
i would expect this to work, but it does not (from what i read order-by works on the find)
(xt/q (xt/db node) '{:find [(pull e [*])]
:where [[e :player/name n]
[e :xt/id id]]
:order-by [[n :asc]]})
I think you need to include the binding from order-by in the find, you can ignore it in the results though, (map first (xt/q node ‘{:find [(pull) n] :where …
thx for the reply, thats what i ended up doing, but it felt weird, looks like i’m the right track than
One pattern I use a lot is this:
(->> (xt/q db '{:find [(pull e [*]) ...] :where ...})
(map first))
E.g. I’m only interested in the first value of each result. Then you can easily append attributes you need for ordering, without changing the results.
When your query produces one unique result, use ffirst
to get the first value of the first tuple.