This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-23
Channels
- # announcements (1)
- # babashka (68)
- # babashka-sci-dev (12)
- # beginners (36)
- # biff (22)
- # calva (20)
- # clerk (1)
- # clj-on-windows (7)
- # clojure (27)
- # clojure-conj (8)
- # clojure-denmark (2)
- # clojure-europe (141)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-uk (2)
- # clojurescript (7)
- # conjure (8)
- # core-async (111)
- # cursive (3)
- # datahike (4)
- # datalevin (18)
- # events (9)
- # gratitude (4)
- # guix (2)
- # helix (3)
- # hyperfiddle (62)
- # introduce-yourself (2)
- # kaocha (4)
- # london-clojurians (3)
- # lsp (7)
- # malli (34)
- # membrane (1)
- # nbb (9)
- # polylith (4)
- # portal (6)
- # reagent (4)
- # releases (2)
- # remote-jobs (4)
- # shadow-cljs (30)
- # sql (2)
- # tools-deps (58)
- # xtdb (9)
Is there any way to control the order of a relation within a pull
query? e.g. given the following:
(xt/pull
(xt/db node)
'[:xt/id
{(:order/_user {:limit 2}) [:xt/id :created]}]
{:user/id ""})
I can limit the number of customer orders returned, but could I achieve something like (:order/_user {:limit 2 :order-by [:created :desc]})
?I have a version of pull queries implemented here using subscriptions: https://github.com/matterandvoid-space/subscriptions/blob/mainline/docs/eql_queries.md
which has support for XTDB queries. The implementation already supports using callbacks to dynamically determine a recursion limit and has :xform
support but only for leaf attributes currently.
The ability to add filtering, ordering, and limiting of collection-valued attributes should be straight forward. If you're interested in that feel free to create an issue :)
> is there any way to control the order of a relation within a pull
query?
As per the other replies you can't do anything quite that sophisticated as things stand today. There might be a way to extend/fork https://github.com/xtdb/xtdb/blob/master/core/src/xtdb/pull.clj with a little bit more functionality like this without too much trouble :thinking_face:
I'm having an issue using xtdb-http-client. I have setup a scratch enviroment:
(ns xtdb-remote.xtdb-remote
"Testing xtdb remote"
(:require [xtdb.api :as xt]))
(def db (xt/new-api-client ""))
(xt/q (xt/db db)
`{:find [e]
:where [[e :xt/id]]})
; => #{[]}
The query I get that returns an empty set:
{:query-id "633b1a80-6d74-497d-b4e4-c402723d585e",
:started-at #inst "2023-02-23T21:52:40.541-00:00",
:finished-at #inst "2023-02-23T21:52:40.543-00:00",
:status :completed,
:query {:find [xtdb-remote.xtdb-remote/e], :where [[xtdb-remote.xtdb-remote/e :xt/id]]},
:error nil}
But the same query run from the xtdb web console which works:
{:query-id "153cbad2-b753-4e25-bd0a-bec86a69d6aa",
:started-at #inst "2023-02-23T21:26:29.325-00:00",
:finished-at #inst "2023-02-23T21:26:29.326-00:00",
:status :completed,
:query {:find [e], :where [[e :xt/id]]},
:error nil}
How can I avoid the namespacing of the query variables using a remote node? Is there an example of using xt/q for http remote access? Every example of xt/q I can find assumes you have the app and the db co-located.Hey @UAB2NMK25 we generally https://docs.xtdb.com/language-reference/1.23.0/datalog-queries/#_quoting against using syntax quoting with ` as it introduces namespaces to the symbols.
See also https://github.com/brandonbloom/backtick (I haven't tried it) and this previous discussion https://app.slack.com/client/T03RZGPFR/CG3AM2F7V