Permalink
Browse files

Update mongo java driver to 2.0, and make corresponding fixes.

Note that metadata on gridfs files is now stored directly on the file object,
not inside a :metadata sub-map.
  • Loading branch information...
1 parent 6e97357 commit 489d41ea9c4a7e0b34fed3393ae482afeac6d454 @purcell committed Jul 15, 2010
Showing with 7 additions and 6 deletions.
  1. +1 −1 project.clj
  2. +4 −3 src/somnium/congomongo.clj
  3. +2 −2 test/congomongo_test.clj
View
@@ -3,7 +3,7 @@
:description "clojure-friendly api for MongoDB"
:dependencies [[org.clojure/clojure "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"]]
:dev-dependencies [[swank-clojure "1.1.0-SNAPSHOT"]
[org.clojars.somnium/user "0.1.0-SNAPSHOT"]])
@@ -26,10 +26,11 @@
[somnium.congomongo.util :only [named defunk]]
[somnium.congomongo.coerce :only [coerce coerce-fields]]
[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.util JSON]
- [somnium.congomongo ClojureDBObject]))
+ [somnium.congomongo ClojureDBObject]
+ [org.bson.types ObjectId]))
(defunk mongo!
"Creates a Mongo object and sets the default database.
@@ -161,7 +162,7 @@
{:arglists '(collection fields {:unique false :force true})}
[c f :unique false :force true]
(-> (get-coll c)
- (.ensureIndex (coerce-fields f) force unique)))
+ (.ensureIndex (coerce-fields f) (coerce {:force force :unique unique} [:clojure :mongo]))))
(defn drop-index!
"Drops an index on the collection for the specified fields"
View
@@ -130,8 +130,8 @@
(with-mongo
(let [f (insert-file! :testfs (.getBytes "nuts")
:metadata { :calories 50, :opinion "tasty"})]
- (is (= "tasty" (-> f :metadata :opinion)))
- (is (= f (fetch-one-file :testfs :where { :metadata.opinion "tasty" }))))))
+ (is (= "tasty" (f :opinion)))
+ (is (= f (fetch-one-file :testfs :where { :opinion "tasty" }))))))
(deftest gridfs-write-file-to
(with-mongo

0 comments on commit 489d41e

Please sign in to comment.