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