Skip to content

Instantly share code, notes, and snippets.

@swlkr
Last active December 28, 2017 00:58
Show Gist options
  • Select an option

  • Save swlkr/f2bb3a152a163d046890760daafbfb4f to your computer and use it in GitHub Desktop.

Select an option

Save swlkr/f2bb3a152a163d046890760daafbfb4f to your computer and use it in GitHub Desktop.
(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