add touch-databases to ensure db structure is present
This commit is contained in:
parent
88ce5616e0
commit
78170ceb10
|
@ -1,4 +1,5 @@
|
||||||
(ns blarg.models.db
|
(ns blarg.models.db
|
||||||
|
(:use [blarg.util])
|
||||||
(:require [blarg.config :as config]
|
(:require [blarg.config :as config]
|
||||||
[com.ashafa.clutch :as couch]))
|
[com.ashafa.clutch :as couch]))
|
||||||
|
|
||||||
|
@ -27,3 +28,15 @@
|
||||||
"returns only the first value from the sequence returned by running a view"
|
"returns only the first value from the sequence returned by running a view"
|
||||||
[& body]
|
[& body]
|
||||||
`(first (->view-values ~@body)))
|
`(first (->view-values ~@body)))
|
||||||
|
|
||||||
|
(defn touch-databases
|
||||||
|
"verifies that the required databases are present, creating them if they
|
||||||
|
are not there (including the views)."
|
||||||
|
[]
|
||||||
|
(couch/get-database users)
|
||||||
|
(couch/get-database files)
|
||||||
|
(when (couch/get-database posts)
|
||||||
|
(couch/with-db posts
|
||||||
|
(let [doc (couch/get-document "_design/posts")]
|
||||||
|
(if (nil? doc)
|
||||||
|
(couch/put-document (load-json "couchdb/design_docs/posts.js")))))))
|
||||||
|
|
Reference in a new issue