      [cljs.reader]
      [cljs-promises.core :refer [promise]]
      [datomish.cljify :refer [cljify]]
+     [datomish.api :as d]
      [datomish.db :as db]
      [datomish.db-factory :as db-factory]
      [datomish.pair-chan]


;; Public API.

(defn ^:export db [conn]
  (transact/db conn))

(defn ^:export q [db find options]
  (let [find (cljs.reader/read-string find)
        opts (cljify options)]
    (take-pair-as-promise!
      (db/<?q db find opts)
      clj->js)))

(defn ^:export ensure-schema [conn simple-schema]

        datoms (simple-schema/simple-schema->schema simple-schema)]
    (println "Transacting schema datoms" (pr-str datoms))
    (take-pair-as-promise!
      (d/<transact!
        conn
        datoms)
      clj->js)))
