Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Commit

Permalink
Add mongo-db test page
Browse files Browse the repository at this point in the history
  • Loading branch information
jbochi committed Jul 5, 2012
1 parent 3a82f0a commit 202d7c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ We use midje for testing. Simply run
$ heroku create --stack cedar
$ git push heroku master
$ heroku scale web=1
$ heroku addons:add mongohq:free
$ curl http://stewie.herokuapp.com
Welcome to Stewie!

Expand Down
14 changes: 12 additions & 2 deletions src/stewie/app.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(ns stewie.app
(:use stewie.core)
(:use noir.core)
(use stewie.core
stewie.db
noir.core
somnium.congomongo)
(:require [noir.server :as server]
[noir.response :as response]))

Expand All @@ -21,6 +23,14 @@
data (assoc data :density density)]
(response/json data)))

(defpage "/test-db" []
(maybe-init :stewie)
(let [counter (fetch-and-modify :stewie
{:_id "counter"}
{:$inc {:value 1} }
:return-new true :upsert? true)]
(str "Welcome to stewie, you're visitor " (or (:value counter) 0))))

(defn -main [& m]
(let [mode (keyword (or (first m) :dev))
port (Integer. (get (System/getenv) "PORT" "8080"))]
Expand Down
11 changes: 0 additions & 11 deletions src/stewie/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,3 @@
(authenticate (:user config) (:pass config)) ;; Setup u/p.
(or (collection-exists? collection) ;; Create collection named 'firstcollection' if it doesn't exist.
(create-collection! collection)))))

; (defpage "/welcome" []
; (maybe-init)
; (let [counter
; (fetch-and-modify
; :firstcollection ;; In the collection named 'firstcollection',
; {:_id "counter"} ;; find the counter record.
; {:$inc {:value 1} } ;; Increment it.
; :return-new true :upsert? true)] ;; Insert if not there.
; (common/layout
; [:p (str "Welcome to noir-heroku, you're visitor " (or (:value counter) 0))])))

0 comments on commit 202d7c1

Please sign in to comment.