Skip to content

Instantly share code, notes, and snippets.

@ccfontes
Created June 10, 2013 11:36
Show Gist options
  • Save ccfontes/5748146 to your computer and use it in GitHub Desktop.
Save ccfontes/5748146 to your computer and use it in GitHub Desktop.
(defn insert
"Insert user registration invitation."
[to_email]
(let [invite-id (make-random)]
(db/insert :invites
{:id invite-id
:to_email to_email
:created_at (to-sql-date (now))
:users_id (app.session/get :id)})
(.toString invite-id)))
; db/insert call to the function below
(defn insert [table & [record]]
"insert that assumes all tables have ids"
(let [record (filter-existent-columns table record)
record (assoc record :id (or (:id record) (app.session/get :id)))]
(korma.core/insert table
(values record))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment