Skip to content

Commit

Permalink
Update mongo java driver to 2.0, and make corresponding fixes.
Browse files Browse the repository at this point in the history
Note that metadata on gridfs files is now stored directly on the file object,
not inside a :metadata sub-map.
  • Loading branch information
purcell committed Jul 15, 2010
1 parent 6e97357 commit 489d41e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -3,7 +3,7 @@
:description "clojure-friendly api for MongoDB" :description "clojure-friendly api for MongoDB"
:dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"] :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"] [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]
[org.clojars.somnium/mongo-java-driver "1.1.0-SNAPSHOT"] [org.mongodb/mongo-java-driver "2.0"]
[org.clojars.somnium/clojure-db-object "0.1.1-SNAPSHOT"]] [org.clojars.somnium/clojure-db-object "0.1.1-SNAPSHOT"]]
:dev-dependencies [[swank-clojure "1.1.0-SNAPSHOT"] :dev-dependencies [[swank-clojure "1.1.0-SNAPSHOT"]
[org.clojars.somnium/user "0.1.0-SNAPSHOT"]]) [org.clojars.somnium/user "0.1.0-SNAPSHOT"]])
7 changes: 4 additions & 3 deletions src/somnium/congomongo.clj
Expand Up @@ -26,10 +26,11 @@
[somnium.congomongo.util :only [named defunk]] [somnium.congomongo.util :only [named defunk]]
[somnium.congomongo.coerce :only [coerce coerce-fields]] [somnium.congomongo.coerce :only [coerce coerce-fields]]
[clojure.contrib.json read write]) [clojure.contrib.json read write])
(:import [com.mongodb Mongo DB DBCollection DBObject ObjectId] (:import [com.mongodb Mongo DB DBCollection DBObject]
[com.mongodb.gridfs GridFS] [com.mongodb.gridfs GridFS]
[com.mongodb.util JSON] [com.mongodb.util JSON]
[somnium.congomongo ClojureDBObject])) [somnium.congomongo ClojureDBObject]
[org.bson.types ObjectId]))


(defunk mongo! (defunk mongo!
"Creates a Mongo object and sets the default database. "Creates a Mongo object and sets the default database.
Expand Down Expand Up @@ -161,7 +162,7 @@
{:arglists '(collection fields {:unique false :force true})} {:arglists '(collection fields {:unique false :force true})}
[c f :unique false :force true] [c f :unique false :force true]
(-> (get-coll c) (-> (get-coll c)
(.ensureIndex (coerce-fields f) force unique))) (.ensureIndex (coerce-fields f) (coerce {:force force :unique unique} [:clojure :mongo]))))


(defn drop-index! (defn drop-index!
"Drops an index on the collection for the specified fields" "Drops an index on the collection for the specified fields"
Expand Down
4 changes: 2 additions & 2 deletions test/congomongo_test.clj
Expand Up @@ -130,8 +130,8 @@
(with-mongo (with-mongo
(let [f (insert-file! :testfs (.getBytes "nuts") (let [f (insert-file! :testfs (.getBytes "nuts")
:metadata { :calories 50, :opinion "tasty"})] :metadata { :calories 50, :opinion "tasty"})]
(is (= "tasty" (-> f :metadata :opinion))) (is (= "tasty" (f :opinion)))
(is (= f (fetch-one-file :testfs :where { :metadata.opinion "tasty" })))))) (is (= f (fetch-one-file :testfs :where { :opinion "tasty" }))))))


(deftest gridfs-write-file-to (deftest gridfs-write-file-to
(with-mongo (with-mongo
Expand Down

0 comments on commit 489d41e

Please sign in to comment.