Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns shouter.models.mark
- (:require [clojure.java.jdbc :as sql]))
- (defmacro with-conn [form]
- (list 'sql/with-connection (System/getenv "DATABASE_URL") form))
- (defn all []
- (with-conn
- (sql/with-query-results results
- ["select * from marks order by id desc"]
- (into [] results))))
- (defn one [id]
- (with-conn
- (sql/with-query-results results
- [(str "select * from marks where id = " id)]
- (first (into [] results)))))
- ; I'm trying to make a macro like below
- (defmacro get-results [query]
- (list 'with-conn (list 'sql/with-query-results results [query] (into [] results))))
- ; So that I can call something like this
- (defn all []
- (get-results "select * from marks"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement