This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-30
Channels
- # announcements (15)
- # beginners (143)
- # boot (2)
- # calva (48)
- # cider (93)
- # cljsrn (2)
- # clojure (127)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-losangeles (8)
- # clojure-nl (10)
- # clojure-spec (67)
- # clojure-uk (51)
- # clojurescript (20)
- # cursive (9)
- # data-science (2)
- # datomic (10)
- # duct (13)
- # figwheel-main (1)
- # fulcro (74)
- # instaparse (10)
- # jobs (3)
- # joker (8)
- # juxt (4)
- # lumo (1)
- # malli (11)
- # nrepl (3)
- # off-topic (4)
- # pathom (5)
- # pedestal (6)
- # planck (5)
- # re-frame (18)
- # reagent (5)
- # reitit (17)
- # shadow-cljs (165)
- # sql (30)
- # vim (12)
- # xtdb (6)
Hi 🙂 not within the normal query as the values themselves are opaque to the query engine, however it might be feasible to use a custom predicate (and DataScript might be viable for a nested query). Note that if the vector (or set) values are IDs then they can be traversed by the query engine as reference attributes.
As a note, it is sort of possible to query vectors in crux. If you submit a vector as a value crux breaks it down into its components and adds them all as individual values on the base level. This means that you can use the :args
key to query for values inside(ish) the vector. As for maps, you can also sort of do that if you namespace maps instead of nest them .i.e {:pocket/right a-thing}
instead of {:pocket {:right a-thing}
. This is on the same line as breaking down the vector into its componets as you can query anything as long as its visible at the root. I wrote some code to try and demonstrate this:
(ns tmt.maplistq
(:require [crux.api :as api]))
(def opts
{:crux.node/topology :crux.standalone/topology
:crux.node/kv-store "crux.kv.memdb/kv"
:crux.kv/db-dir "data/db-dir-1"
:crux.standalone/event-log-dir "data/eventlog-1"
:crux.standalone/event-log-kv-store "crux.kv.memdb/kv"})
(def node
(api/start-node opts))
(api/submit-tx
node
[[:crux.tx/put
{:crux.db/id :me
:list ["carrots" "peas" "shampoo"]
:pockets/left ["lint" "change"]
:pockets/right ["phone"]}]
[:crux.tx/put
{:crux.db/id :you
:list ["carrots" "tomatoes" "wig"]
:pockets/left ["wallet" "watch"]
:pockets/right ["spectacles"]}]])
(api/q (api/db node) '{:find [e l]
:where [[e :list l]]
:args [{l "carrots"}]})
;; => #{[:you "carrots"] [:me "carrots"]}
(api/q (api/db node) '{:find [e p]
:where [[e :pockets/left p]]
:args [{p "watch"}]})
;; => #{[:you "watch"]}
@UNDH5EQRL good point, the values in a top-level vector value are effectively like cardinality-many, so they can be queried (cc @U07FP7QJ0), and you can also make use of the order of the values in that vector My brain is still warming up - first day back on the Slack after a couple of weeks' break 🙂