Last active
August 29, 2015 14:11
-
-
Save laser/9ca0d865709445f2f454 to your computer and use it in GitHub Desktop.
Adding database connectivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def db-config "jdbc:h2:mem:pipeline;DB_CLOSE_DELAY=-1") | |
(defn create-note | |
"Given a note's text, insert into database and return autogenerated id" | |
[{text :text}] | |
(try [(-> (query :notes) | |
(insert {:text text}) | |
(exec db-config) | |
first | |
vals | |
first)] | |
(catch org.h2.jdbc.JdbcSQLException e [nil (str e)]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment