Back
read-column-by-label (clj)
(source)protocol
(read-column-by-label val label)
Function for transforming values after reading them via a column label.
Examples
kit-clj/kit
(ns kit.edge.db.mysql
(:require
[next.jdbc]
[next.jdbc.prepare :as prepare]
[next.jdbc.result-set :as result-set])
(:import
[java.sql Array PreparedStatement Timestamp]
[java.time Instant LocalDate LocalDateTime]))
(extend-protocol result-set/ReadableColumn
Array
(read-column-by-label [^Array v _] (vec (.getArray v)))
(read-column-by-index [^Array v _2 _3] (vec (.getArray v))))
luminus-framework/examples
(ns guestbook.db.core
(:require
[next.jdbc.date-time]
[next.jdbc.result-set]
[conman.core :as conman]
[mount.core :refer [defstate]]
[guestbook.config :refer [env]]))
(extend-protocol next.jdbc.result-set/ReadableColumn
java.sql.Timestamp
(read-column-by-label [^java.sql.Timestamp v _]
(.toLocalDateTime v))
(read-column-by-index [^java.sql.Timestamp v _2 _3]
(.toLocalDateTime v))
java.sql.Date
(read-column-by-label [^java.sql.Date v _]
(.toLocalDate v))
(read-column-by-index [^java.sql.Date v _2 _3]
(.toLocalDate v))
java.sql.Time
(read-column-by-label [^java.sql.Time v _]
(.toLocalTime v))
(read-column-by-index [^java.sql.Time v _2 _3]
(.toLocalTime v)))
bjtj/tjsamples
(ns guestbook.db.core
(:require
[next.jdbc.date-time]
[next.jdbc.result-set]
[conman.core :as conman]
[mount.core :refer [defstate]]
[guestbook.config :refer [env]]))
(extend-protocol next.jdbc.result-set/ReadableColumn
java.sql.Timestamp
(read-column-by-label [^java.sql.Timestamp v _]
(.toLocalDateTime v))
(read-column-by-index [^java.sql.Timestamp v _2 _3]
(.toLocalDateTime v))
java.sql.Date
(read-column-by-label [^java.sql.Date v _]
(.toLocalDate v))
(read-column-by-index [^java.sql.Date v _2 _3]
(.toLocalDate v))
java.sql.Time
(read-column-by-label [^java.sql.Time v _]
(.toLocalTime v))
(read-column-by-index [^java.sql.Time v _2 _3]
(.toLocalTime v)))