Created
January 27, 2018 13:21
-
-
Save linuxsoares/fb9ba756a5a22a26a5796a733c0e0919 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 todo.query | |
(:require [todo.database] | |
[korma.core :refer :all])) | |
(defentity items) | |
(defn get-todos [] | |
(select items)) | |
(defn add-todo [title description] | |
(insert items | |
(values {:title title :description description}))) | |
(defn delete-todo [id] | |
(delete items | |
(where {:id [= id]}))) | |
(defn update-todo [id title is-complete] | |
(update items | |
(set-fields {:title title | |
:is_complete is-complete}) | |
(where {:id [= id]}))) | |
(defn get-todo [id] | |
(first | |
(select items | |
(where {:id [= id]})))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment