This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-21
Channels
- # announcements (3)
- # aws (11)
- # babashka (5)
- # beginners (116)
- # cider (30)
- # clara (1)
- # clj-kondo (15)
- # clojure (17)
- # clojure-dev (9)
- # clojure-europe (2)
- # clojure-italy (1)
- # clojure-uk (3)
- # clojurescript (9)
- # conjure (3)
- # duct (22)
- # exercism (1)
- # fulcro (8)
- # graalvm (5)
- # graphql (3)
- # helix (3)
- # joker (3)
- # kaocha (2)
- # off-topic (9)
- # pathom (4)
- # re-frame (1)
- # rum (6)
- # shadow-cljs (81)
- # sql (6)
- # xtdb (9)
Is this (sql/query ds ["SELECT COUNT(1) FROM \"user\" WHERE email = ?" "
how to count in next.jdbc or there is a shortcut to it?
Also, is it possible to drop the table prefix on returned results?.. to use (:id user)
instead of (:user/id user)
in:
(let [user (first (find-by-keys datasource :user {:email "some@email"}))
id (:user/id user)
@somedude314 The most common way folks count stuff in SQL is something like SELECT COUNT(*) AS n FROM ...
and then run that through (-> (sql/query ...) (first) :n)
(or whatever you alias the count as).
As for the qualified column names -- try to learn to live with them. It's a deliberate design decision and namespaced keywords are idiomatic Clojure.
(you could use a :builder-fn
to provide unqualified names but I strongly recommend you try to get used to them and work with them before just abandoning them: Spec relies heavily on namespaced keywords and you'll see them crop up in Datomic and other query languages)