This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-01
Channels
- # adventofcode (93)
- # announcements (44)
- # asami (23)
- # aws (1)
- # babashka (48)
- # beginners (112)
- # calva (26)
- # cider (57)
- # clj-kondo (17)
- # cljfx (5)
- # cljs-dev (21)
- # clojure (124)
- # clojure-europe (19)
- # clojure-hungary (40)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (3)
- # clojurescript (3)
- # cursive (81)
- # datalog (11)
- # events (21)
- # exercism (1)
- # fulcro (37)
- # graalvm (1)
- # introduce-yourself (8)
- # jobs (1)
- # lsp (1)
- # malli (5)
- # membrane-term (17)
- # minecraft (3)
- # nextjournal (5)
- # off-topic (14)
- # other-lisps (14)
- # polylith (58)
- # reagent (16)
- # reclojure (3)
- # reitit (6)
- # remote-jobs (1)
- # shadow-cljs (55)
- # spacemacs (15)
- # testing (2)
- # tools-build (7)
- # tools-deps (191)
Hello I'm a bit unsure of how to do recursive datalog queries and am not too sure where to start
I have a query that goes something like this
{:find [?dataset ?group]
:where [[?dataset :id "..."]
[?dataset :group ?group]]}
My data is such that each group may have a parent group indicated by the attribute :parent
Hey π looking at the example(s) in the docs for inspiration https://docs.xtdb.com/language-reference/datalog-queries/#_bound_arguments ...I'd try something similar:
{:find [?dataset ?group ?parent]
:where [[?dataset :xt/id "..."]
[?dataset :group ?group]
(group-parents ?group ?parent)]
:rules [[(group-parents [?group] ?parent)
[?group :parent ?parent]]
[(group-parents [?group] ?parent)
[?group :parent ?subparent]
(group-parents ?subparent ?parent)]]}
adjusting the language of "parent"/"subparent" would probably make things clearer but hopefully you get the idea π
Thanks for the link π was trying see where it might be in the docs. Will take a look when I get back home and let you know if I have any issues! (:
if you also need to return the "height" of all the nested parents, you can do it like this: https://gist.github.com/refset/57a910e2b746332ec7a0a31886f57cfb