   :allowed-methods       #{:get :post}
   :available-media-types #{"application/edn" "text/html"}
   :authorized?           (authorized? querier :datasets)
-  :post!                 (partial index-post! querier)
+  :post!                 (partial index-post! commander)
   :handle-ok             (partial index-handle-ok querier)
   :handle-created        (partial index-handle-created handlers))
 
-(defn resource-exists? [querier req]
-  (let [{route-params :route-params} req
+(defn resource-exists? [querier ctx]
+  (let [request      (:request ctx)
+        route-params (:route-params request)
         {:keys [entity-id name]} route-params]
-    (when-let [item (first (hecuba/items querier :dataset {:entity-id entity-id
-                                                           :name name}))]
+    (log/infof "resource-exists? :%s:%s" entity-id name)
+
+    (when-let [item (first (hecuba/items querier :dataset [[= :entity-id entity-id]
+                                                           [= :name name]]))]
         {::item item}
         #_(throw (ex-info (format "Cannot find item of id %s"))))))
 

        ds {:entity_id (entity-id-from ctx)
            :name      (name-from ctx)
            :members   (string/join \, members)}]
    (hecuba/upsert! commander :dataset ds)))

(defn resource-handle-ok [req]
  (let [item (::item req)]
    (util/render-item req item)))

(defresource resource [{:keys [commander querier]} handlers]
  :allowed-methods       #{:get :post}

  (:require
   [bidi.bidi :as bidi]
   [clojure.string :as string]
   [clojure.tools.logging :as log]
   [kixi.hecuba.protocols :as hecuba]
   [kixi.hecuba.queue :as q]
   [kixi.hecuba.security :as sec]
