Skip to content

Instantly share code, notes, and snippets.

@swgillespie
Created August 3, 2014 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swgillespie/7325058250c7190d5881 to your computer and use it in GitHub Desktop.
Save swgillespie/7325058250c7190d5881 to your computer and use it in GitHub Desktop.
(ns dbstuff.model
(:require [monger.core :as mg]
[monger.collection :as mc]))
(defn uuid []
(str (java.util.UUID/randomUUID))) ;; CastClassException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
(deftype Database [conn table]
(create-user [username]
(mc/insert table "documents" { :_id (uuid) :username username })))
(defn init-db []
(let [conn (mg/connect)
table (mg/get-db "main")]
(Database. conn table)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment