Is this (sql/query ds ["SELECT COUNT(1) FROM \"user\" WHERE email = ?" "<mailto:some@email.com|some@email.com>"])
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)
Thanks, will definitely keep them when the result is coming from more than one table