This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-21
Channels
- # calva (11)
- # cider (4)
- # clojure (15)
- # clojure-europe (20)
- # clojurescript (14)
- # clr (45)
- # conjure (2)
- # cursive (1)
- # fulcro (10)
- # helix (4)
- # honeysql (7)
- # hoplon (21)
- # humbleui (2)
- # hyperfiddle (23)
- # introduce-yourself (1)
- # malli (11)
- # matrix (3)
- # off-topic (6)
- # pathom (2)
- # practicalli (1)
- # re-frame (9)
- # releases (1)
- # specter (2)
- # sql (10)
- # xtdb (2)
I want to be able to get a vector out of an attribute that I assigned a vector. I have written the following code.
(xt/submit-tx node [[::xt/put {:xt/id (random-uuid)
:foo "bar"
:baz ["quux" "quux"]}]])
But the following query does not return a vector with two strings. Why not?
(xt/q (xt/db node) '{:find [?baz]
:where [[e :foo "bar"]
[(get-attr e :baz) ?baz]]})
Hey @U0479UCF48H all top-level collection values in the index are decomposed as if they were triples, so get-attr here can only return a set because positional information is not stored in the index. This means the only way to get the original vector out again is to use the entity
API - you should be able to do this within the query like so:
(xt/q (xt/db node) '{:find [?baz]
:where [[e :foo "bar"]
[(xtdb.api/entity $ e) ?doc]
[(get ?doc :baz) ?baz]})
👍 3
2