Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (36 sloc) 1.12 KB
(ns libekorma.sample
(:use [korma.core]
(defdb dbconnection dbcon)
(defn insert-sample-tags []
(insert tag
[{:tag "health"}
{:tag "leisure"}
{:tag "paperwork"}])))
(defn insert-sample-tasks []
(insert task
[{:title "Write down some stuff" :created_time (cur-time)}
{:title "Do pull-ups" :description "12-12-12" :created_time (cur-time)}
{:title "Buy some milk" :created_time (cur-time)}
{:title "Pick a movie for the weekend" :description "Maybe MiB3 or something" :created_time (cur-time)}])))
(defn insert-sample-tasktags []
(let [pullups-task (first (select task (where {:title [like "%pull-ups"]})))
health-tag (first (select tag (where {:tag "health"})))]
(if (or (nil? pullups-task) (nil? health-tag))
(throw (Exception. "Task or tag not found"))
(insert tasktag
[{:task_id (:task_id pullups-task)
:tag_id (:tag_id health-tag)}])))))
(defn insert-demo-data []
(delete tasktag)
(delete task)
(delete tag)