Skip to content

Instantly share code, notes, and snippets.

@linuxsoares
Created January 27, 2018 13:21
Show Gist options
  • Save linuxsoares/fb9ba756a5a22a26a5796a733c0e0919 to your computer and use it in GitHub Desktop.
Save linuxsoares/fb9ba756a5a22a26a5796a733c0e0919 to your computer and use it in GitHub Desktop.
(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