This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-03
Channels
- # babashka (12)
- # beginners (15)
- # biff (2)
- # calva (17)
- # clj-kondo (19)
- # clj-on-windows (3)
- # clj-otel (1)
- # clojure (3)
- # clojure-europe (5)
- # conjure (2)
- # graalvm (2)
- # helix (5)
- # introduce-yourself (1)
- # nbb (24)
- # off-topic (32)
- # polylith (3)
- # reitit (21)
- # releases (1)
- # reveal (3)
- # scittle (1)
- # squint (56)
- # tools-deps (4)
- # xtdb (6)
This is taken from the bottom of XTDB tx/match
tutorial.
• https://nextjournal.com/xtdb-tutorial/match
Why does the query below only return the single item in the list, and not return the entire list?
The behaviour doesn’t seem to match any of XTDB Datalog’s :in
type.
• https://docs.xtdb.com/language-reference/datalog-queries/#in
(xt/submit-tx
node
[[::xt/put
{:xt/id :manifest
:pilot-name "Johanna"
:id/rocket "SB002-sol"
:id/employee "22910x2"
:badges ["SETUP" "PUT" "DATALOG-QUERIES" "BITEMP" "MATCH"]
:cargo ["stereo" "gold fish" "slippers" "secret note"]}]])
(xt/sync node)
(xt/q (xt/db node)
'{:find [belongings]
:where [[e :cargo belongings]]
:in [belongings]}
"secret note")
;; Returns... #{["secret note"]}) ... not #{["stereo" "gold fish" "slippers" "secret note"]}
Or said another way 👆:skin-tone-5: What would be the query for… “i. Find the entity, ii. whose vector attribute contains X… and return the entire vector”?
Interesting question! This works for me:
(xt/q (xt/db node)
'{:find [c]
:where [[e :cargo belongings]
[e :cargo c]]
:in [belongings]}
"secret note") ; #{["slippers"] ["secret note"] ["gold fish"] ["stereo"]}
Or
(xt/q (xt/db node)
'{:find [(pull e [:cargo])]
:where [[e :cargo belongings]]
:in [belongings]}
"secret note") ; #{[{:cargo ["stereo" "gold fish" "slippers" "secret note"]}]}
@UJY23QLS1 Ooooh I get it. In my original query, :find
returns the belongings
comparator / binding I submitted. But you created a separate c
binding that is the actual vector.
Got it. Cheers mate 👍:skin-tone-5: