This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-16
Channels
- # atom-editor (6)
- # babashka (31)
- # beginners (34)
- # calva (1)
- # cider (21)
- # clj-kondo (5)
- # cljsrn (2)
- # clojars (6)
- # clojure (35)
- # clojure-europe (3)
- # clojure-norway (2)
- # clojurescript (4)
- # conjure (10)
- # cursive (8)
- # data-science (78)
- # fulcro (23)
- # graphql (10)
- # helix (2)
- # luminus (1)
- # off-topic (50)
- # other-languages (1)
- # pathom (8)
- # re-frame (9)
- # reagent (9)
- # reitit (1)
- # rewrite-clj (6)
- # shadow-cljs (134)
- # tools-deps (53)
- # vscode (1)
- # xtdb (4)
when passing in a vector to :args
, can crux return the results in the same order as :args
? or is this best done in application logic
the ordering of Crux query results for a query without an explicit order-by is undefined, but you could include an index variable in the args, and then order the Crux query by that index:
(crux/submit-tx node
[[:crux.tx/put {:crux.db/id :doc-a}]
[:crux.tx/put {:crux.db/id :doc-b}]
[:crux.tx/put {:crux.db/id :doc-c}]
[:crux.tx/put {:crux.db/id :doc-d}]
[:crux.tx/put {:crux.db/id :doc-e}]])
(crux/q db '{:find [?idx ?eid]
:where [[?e :crux.db/id ?eid]]
:order-by [[?idx]]
:args [{?idx 0, ?eid :doc-c}
{?idx 1, ?eid :doc-b}
{?idx 2, ?eid :doc-e}
{?idx 3, ?eid :doc-a}]})
;; => [[0 :doc-c] [1 :doc-b] [2 :doc-e] [3 :doc-a]]