   ([type]
      (count-instances type nil))
   ([type criteria]
-     (c/fetch (collection-for type) criteria :count true)))
+     (c/count-docs (collection-for type) criteria)))
 
 (defn distinct-values
   "Return the distinct values of a given type for a given key."

  ([type obj]
     (update-all type {} obj))
  ([type criteria obj]
     (c/update-all (collection-for type) criteria obj)))

(defn delete
  "Deletes one or more entities."
  ([entity]
     (c/delete (collection-for entity) (where (eq :_id (:_id entity)))))
  ([entity & entities]
     (doall (map delete (cons entity entities)))))

(defn delete-all
  "Deletes all entitys given an optional where clause."

(defn fetch-all
  "Fetch all of the entities for the given type."
  [type & options]
  (apply fetch type nil options))

(defn fetch-one
  "Fetch the first entity for the given type matching the supplied criteria and options."
  [type criteria & options]
  (first (apply fetch type criteria options)))

(defn fetch-by-id
  "Fetch an enity by :_id"
