   (:import [com.mongodb Mongo DB DBCollection BasicDBObject
             DBObject DBCursor DBAddress MongoOptions
             ObjectId]))
+
 (defn has-option? [options k]
   (boolean (some #{k} options)))
 
-(defn db-object [#^clojure.lang.IPersistentMap m]
+(defn db-object [m]
   (let [to-s #(if (keyword? %) (name %) (str %))
         to-v #(if (map? %) (db-object %) %)
-        r (BasicDBObject.)]
+        dbo  (BasicDBObject.)]
     (doseq [[k v] m]
-      (.put r #^String (to-s k) #^Object (to-v v)))
-    r))
+      (.put dbo (to-s k) (to-v v)))
+    dbo))
 
-(defn clojure-object [#^DBObject dbo]
+(defn clojure-object [dbo]
   (apply merge (map (fn [#^java.util.Map$Entry e]
                        (let [k (.getKey e)
                              v (.getValue e)]

  (.findOne collection (ObjectId. s)))

(defn distinct-values [#^DBCollection collection s]
  (seq (.distinct collection #^String (name s))))

(defn delete [#^DBCollection collection obj]
  (.remove collection (db-object obj)))

(defn ensure-index
  [#^DBCollection collection fields & options]
  (let [o? #(has-option? options %)]
    (.ensureIndex collection #^DBObject
                  (db-object fields)
                  (boolean (o? :force))
                  (boolean (o? :unique)))))

(defn drop-index [#^DBCollection collection o]
  (.dropIndex collection #^DBObject (db-object o)))
