This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-07
Channels
- # announcements (2)
- # asami (2)
- # babashka (15)
- # babashka-sci-dev (31)
- # beginners (130)
- # boot (4)
- # cider (5)
- # circleci (12)
- # clj-kondo (10)
- # cljs-dev (8)
- # clojure (7)
- # clojure-czech (14)
- # clojure-europe (19)
- # clojure-france (5)
- # clojure-uk (2)
- # clojured (23)
- # clojurescript (11)
- # conjure (8)
- # datomic (5)
- # emacs (1)
- # etaoin (8)
- # events (2)
- # fulcro (10)
- # graalvm (18)
- # gratitude (1)
- # holy-lambda (16)
- # honeysql (4)
- # introduce-yourself (1)
- # jobs (2)
- # kaocha (3)
- # london-clojurians (1)
- # lsp (53)
- # off-topic (16)
- # other-languages (2)
- # pathom (4)
- # pedestal (3)
- # podcasts-discuss (1)
- # portal (10)
- # re-frame (69)
- # reitit (2)
- # shadow-cljs (11)
- # vim (7)
- # xtdb (29)
Hello everyone 👋 I am currently working on a small project and i need help with something.. I want to stack my queries...
(defn users
([db]
(users db nil))
([db {:keys [cond]}]
(let [q (cond->
'{:find [(pull ?eid [*])]
:where [[?eid :user/created]]}
(map? cond) (concat (map (partial cons '?eid) cond)))]
(map first (d/q q db)))))
Here is test for this:
(let [cond {:user/firstname "dummy-value" :user/region :dummy-value}
q (cond->
'{:find [(pull ?eid [*])]
:where [[?eid :user/created]]}
(map? cond) (concat (map (partial cons '?eid) cond))]
q)
;; ([:find [(pull ?eid [*])]] [:where [[?eid :user/created]]] (?eid :user/firstname "dummy-value") (?eid :user/region :dummy-value)) THIS IS MY RETURN VALUE ( BAD )
;; {:find [(pull ?eid [*])] :where [[?eid :user/created] [?eid :user/firstname "dummy-value"] [?eid :user/region :dummy-value]]} THIS IS RETURN VALUE I WANT ( GOOD )
I am kind of stuck here 😓
Any reference to a documentation or suggestion will help..
Thank you in advance..You’re using “map” on a map. I think you meant something like (update :where into (map #(into ['?eid] %)) cond)
try using let only instead of cond->
so that the intermediates are named and it’s less “clever”. I think the mistake will be more obvious.
Thank you very much. 😊