Created
February 28, 2012 19:12
-
-
Save nilswloka/1934452 to your computer and use it in GitHub Desktop.
Use mongeez with congomongo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example | |
(:use somnium.congomongo) | |
(:use [somnium.congomongo.config :only [*mongo-config*]]) | |
(:import [org.mongeez Mongeez]) | |
(:import [org.springframework.core.io ClassPathResource])) | |
(defn migrate-mongo [db] | |
"Migrates mongodb by using mongeez" | |
(let [mongo (:mongo *mongo-config*) | |
mongeez (Mongeez.)] | |
(doto mongeez | |
(.setFile (ClassPathResource. "/mongeez.xml")) | |
(.setMongo mongo) | |
(.setDbName db) | |
(.process)))) | |
(defn init-mongo [] | |
(when (not (connection? *mongo-config*)) | |
(let [host "localhost" | |
port 27017 | |
db "example" | |
(mongo! :db db :host host :port port) | |
(migrate-mongo db)))) | |
(init-mongo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<changeFiles> | |
<file path="mongo-change-1.xml"/> | |
</changeFiles> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mongoChangeLog> | |
<changeSet changeId="ChangeSet-1" author="example-author"> | |
<script> | |
example = { greeting : 'Hello World!' }; | |
db.greetings.insert(example); | |
</script> | |
</changeSet> | |
</mongoChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject example "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.3.0"] | |
[congomongo "0.1.7"] | |
[org.mongeez/mongeez "0.9.1"] | |
[log4j "1.2.16"] | |
[org.springframework/spring-core "3.0.5.RELEASE"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment