Created
June 10, 2014 17:22
-
-
Save anonymous/f9a12fb49bd8585c4738 to your computer and use it in GitHub Desktop.
This file contains 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
(ns test.db.core | |
(:use korma.core | |
[korma.db :only (defdb)]) | |
(:require [test.db.schema :as schema])) | |
(comment | |
(ns test.db.schema) | |
(def db-spec | |
{:subprotocol "mysql" | |
:subname "//localhost:3306/test" | |
:user "root" | |
:password "*******"}) | |
) | |
(defdb db schema/db-spec) | |
(defentity users) | |
(defn create-user [user] | |
(insert users | |
(values user))) | |
(defn update-user [id first-name last-name email] | |
(update users | |
(set-fields {:first_name first-name | |
:last_name last-name | |
:email email}) | |
(where {:id id}))) | |
(defn get-user [id] | |
(first (select users | |
(where {:id id}) | |
(limit 1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment