   [#^DBCollection collection fields & options]
   (let [o? #(has-option? options %)]
     (.ensureIndex collection #^DBObject
-                  (db-object fields)
+                  (to-dbo fields)
                   (boolean (o? :force))
                   (boolean (o? :unique)))))
 
 (defn drop-index [#^DBCollection collection o]
-  (.dropIndex collection #^DBObject (db-object o)))
+  (.dropIndex collection #^DBObject (to-dbo o)))
 
-(defn drop-index-named [#^DBCollection collection #^String s]
-  (.dropIndex collection s))
+(defn drop-index-named [#^DBCollection collection kw]
+  (.dropIndex collection (name kw)))
 

(defn search* [#^DBCollection collection query keys limit skip order-by count?]
  (let [cursor (if query
                 (if keys
                   (.find collection #^DBObject (db-object query) #^DBObject (db-object keys))
                   (.find collection #^DBObject (db-object query)))
                 (.find collection ))
        cursor (if limit (.limit cursor limit) cursor)
        cursor (if skip (.skip cursor skip) cursor)
        cursor (if order-by (.sort cursor (db-object (apply merge order-by))) cursor)
        cursor (if count? (.count cursor) cursor)]
    (map clojure-object cursor)))

(defnk fetch [collection query :limit nil :skip nil :include nil :exclude nil :order-by nil :count false]
  (search* collection


(defn insert [#^DBCollection collection & objs]
  (if (= 1 (count objs))
    (to-clj
     (.insert collection #^DBObject (to-dbo (first objs))))
    (map to-clj
         (.insert collection #^java.util.List (map to-dbo objs)))))

(defn save [#^DBCollection collection & objs]
  (doseq [o objs]
    (.save collection (to-dbo o))))

(defn update [#^DBCollection collection query obj & options]
  (let [o? #(has-option? options %)]
    (to-clj (.update collection
                             (to-dbo query)
                             (to-dbo obj)
                             (o? :upsert)
                             (o? :multi)))))

