(ns training-clj.querys
(:require [honey.sql :as honey]
[next.jdbc.sql :as jdbc]))
(defn get-by-username
[db username]
(let [query (honey/format {:select [:*]
:from [:user]
:where [:= :username username]]})]
(jdbc/query db query)))
I'm doing a query in the db (postgresql) per user and I have a return similar to this: ({:id 2 :username "random" :age 18 :telephone 3120-4587})
and given this code base that I defined, I want to apply the PostgreSQL LOWER() function to the :username key, what are the ways I can do this?
You're using HoneySQL, so calling a PostgreSQL function should be done via HoneySQL's DSL. The relevant part is described here.
As for your specific question, it's unclear what the
lower
function must be applied to since:*
returns all columns.But let's assume that you want to return
:first-name
, just lower-case. Then it would be something like this:or