Last active
December 28, 2017 00:58
-
-
Save swlkr/f2bb3a152a163d046890760daafbfb4f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 your-proj.models.posts | |
| (:require [coast.db :as db]) | |
| (:refer-clojure :exclude [update])) | |
| (def columns [:title :body]) | |
| (defn all [] | |
| (db/query :posts/all)) | |
| (defn find-by-id [id] | |
| (db/query :posts/find-by-id {:id id})) | |
| (defn insert [m] | |
| (->> (select-keys m columns) | |
| (db/insert :posts))) | |
| (defn update [id m] | |
| (as-> (select-keys m columns) % | |
| (db/update :posts % :posts/where {:id id}))) | |
| (defn delete [id] | |
| (db/delete :posts :posts/where {:id id})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment