Skip to content

Commit

Permalink
Merge pull request #80 from spradnyesh/master
Browse files Browse the repository at this point in the history
upgraded monger from 1.7.0 to 2.0.0
  • Loading branch information
yogthos committed Aug 25, 2014
2 parents 94624c0 + 10eac87 commit 30fccb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/leiningen/new/luminus.clj
Expand Up @@ -110,7 +110,7 @@

(defmethod post-process :+mongodb [_ project-file]
(add-mongo-dependencies project-file
['com.novemberain/monger "1.7.0"])
['com.novemberain/monger "2.0.0"])
(let [docs-filename (str *name* "/resources/public/md/docs.md")]
(spit docs-filename (str (*render* "dbs/mongo_instructions.html") (slurp docs-filename)))))

Expand Down
11 changes: 6 additions & 5 deletions src/leiningen/new/luminus/dbs/mongodb.clj
Expand Up @@ -5,17 +5,18 @@

;; Tries to get the Mongo URI from the environment variable
;; MONGOHQ_URL, otherwise default it to localhost
(let [uri (get (System/getenv) "MONGOHQ_URL" "mongodb://127.0.0.1/{{name}}")]
(mg/connect-via-uri! uri))
(defonce db (let [uri (get (System/getenv) "MONGOHQ_URL" "mongodb://127.0.0.1/{{name}}")
{:keys [conn db]} (mg/connect-via-uri uri)]
db))

(defn create-user [user]
(mc/insert "users" user))
(mc/insert db "users" user))

(defn update-user [id first-name last-name email]
(mc/update "users" {:id id}
(mc/update db "users" {:id id}
{$set {:first_name first-name
:last_name last-name
:email email}}))

(defn get-user [id]
(mc/find-one-as-map "users" {:id id}))
(mc/find-one-as-map db "users" {:id id}))

0 comments on commit 30fccb4

Please sign in to comment.