import { hugsqlVersion } from '@site/src/version.js'
Within your Clojure code, you will need to explicitly set the adapter. You can do this globally (i.e., at app startup) with hugsql.core/set-adapter!
, or you can specify the :adapter
as an option when defining your functions with hugsql.core/def-db-fns
, or you can pass in an :adapter
option when calling your defined function.
(ns my-app
(:require [hugsql.core :as hugsql]
[hugsql.adapter.next-jdbc :as next-adapter
[next.jdbc.result-set :as rs]]]))
(defn app-init []
(hugsql/set-adapter! (next-adapter/hugsql-adapter-next-jdbc)))
;; OR override the :builder-fn behavior
(defn app-init []
(hugsql/set-adapter! (next-adapter/hugsql-adapter-next-jdbc {:builder-fn result-set/as-unqualified-maps})))
OR
(ns my-db-stuff
(:require [hugsql.core :as hugsql]
[hugsql.adapter.next-jdbc :as next-adapter]))
(hugsql/def-db-fns "path/to/db.sql"
{:adapter (next-adapter/hugsql-adapter-next-jdbc)})
OR
(ns my-db-stuff
(:require [hugsql.core :as hugsql]
[hugsql.adapter.next-jdbc :as next-adapter]))
(def db ;;a db-spec here)
(hugsql/def-db-fns "path/to/db.sql")
(my-query db {:id 1}
{:adapter (next-adapter/hugsql-adapter-next-jdbc)})
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close