This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-26
Channels
- # announcements (2)
- # babashka (55)
- # beginners (107)
- # calva (65)
- # cider (5)
- # clara (4)
- # clj-kondo (17)
- # cljs-dev (38)
- # cljsrn (16)
- # clojure (117)
- # clojure-australia (8)
- # clojure-europe (13)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-provo (2)
- # clojure-sweden (9)
- # clojure-taiwan (1)
- # clojure-uk (41)
- # clojurescript (40)
- # code-reviews (1)
- # conjure (40)
- # cursive (4)
- # datomic (11)
- # events (2)
- # fulcro (33)
- # graalvm (1)
- # jobs (2)
- # jobs-discuss (19)
- # lsp (18)
- # off-topic (58)
- # polylith (2)
- # quil (2)
- # react (28)
- # reagent (35)
- # reitit (3)
- # remote-jobs (1)
- # ring (9)
- # sci (76)
- # shadow-cljs (19)
- # sql (10)
- # testing (5)
- # vim (13)
- # xtdb (5)
For this project, I had a few advanced queries (search, dynamic filters) to first do with Clojure Next.jdbc / HoneySQL. Does a query like this sound reasonable to you? https://github.com/prestancedesign/clojure-inertia-pingcrm-demo/blob/main/src/pingcrm/models/users.clj#L16-L35
Some suggestions for improvement?
@admin055 I think that’s fine. Personally, I’d probably use cond->
to thread the various where clauses but that’s just a stylistic issue.
As an example (from part of our codebase still using HoneySQL v1):
([self status exclude items qualifier]
(cond-> (-> (select [:uc.senderuserid :id])
(from [:usercovalence :uc])
(where [:= :uc.receiveruserid (:id self)])
(user-status :uc.senderuserid)
(user-gender :uc.receiveruserid))
;; WS-13047 status must be conditional because it can be nil:
status
(merge-where [:= :uc.covalence status])
qualifier
(merge-where qualifier)
(seq items)
(within-items items :user-id :uc.senderuserid)
(seq exclude)
(merge-where [:not-in :uc.senderuserid exclude])))
I use HoneySQL v2 and merge-where
helper is not here anymore.
What replaces it please?
OK just where
, right? I see the generic
function.
See https://cljdoc.org/d/com.github.seancorfield/honeysql/2.0.0-rc2/doc/differences-from-1-x#helpers
Awesome, thx!
Perfect, thank @seancorfield
Yeah, I like the cond->
style too.. Brilliant!