Closed vemv closed 4 months ago
I'll think about it -- I really don't want to expand the "Friendly SQL Functions": I'd rather folks used HoneySQL for more complex SQL and plan/select-one!
to get a single column value out of a result set.
Yes, agreed. I much appreciate Honey but in my current context, socially we decided to stick to next.jdbc.sql
for the time being.
How would you feel about this:
(aggregate-by-keys ds :table "count(*)" :total where-map opts)
;; would call:
(-> (find-by-keys ds :table where-map (assoc opts :columns [["count(*)" :total]])) first :total)
This would allow for more general aggregation. Perhaps the alias keyword (:total
here) could be some weird, internal gensym'd name so you didn't need to specify it at all...?
Yes the :total
would seem like some friction for users.
Other than that, it looks reasonable to me!
Nice, thank you!
Is your feature request related to a problem? Please describe.
I'd like to sql-
count
more easily while usingfind-by-keys
.I can pass
:columns [["count(*)" :total]]
and then-> ,,, first :total
the result.But neither bit seems intuitive to me.
Describe the solution you'd like
An option in
find-by-keys
that translates to a count, maybe?Describe alternatives you've considered
A separate function in the same ns that takes similar options to
find-by-keys
, but that performs a count and returns a number (the count) rather than a coll of results.Thanks - V