Review comment: use datomish.api where possible.
This commit is contained in:
parent
ce67644fd5
commit
61757e271c
1 changed files with 7 additions and 8 deletions
|
@ -12,6 +12,7 @@
|
||||||
[cljs.reader]
|
[cljs.reader]
|
||||||
[cljs-promises.core :refer [promise]]
|
[cljs-promises.core :refer [promise]]
|
||||||
[datomish.cljify :refer [cljify]]
|
[datomish.cljify :refer [cljify]]
|
||||||
|
[datomish.api :as d]
|
||||||
[datomish.db :as db]
|
[datomish.db :as db]
|
||||||
[datomish.db-factory :as db-factory]
|
[datomish.db-factory :as db-factory]
|
||||||
[datomish.pair-chan]
|
[datomish.pair-chan]
|
||||||
|
@ -24,14 +25,13 @@
|
||||||
|
|
||||||
;; Public API.
|
;; Public API.
|
||||||
|
|
||||||
(defn ^:export db [conn]
|
(def ^:export db d/db)
|
||||||
(transact/db conn))
|
|
||||||
|
|
||||||
(defn ^:export q [db find options]
|
(defn ^:export q [db find options]
|
||||||
(let [find (cljs.reader/read-string find)
|
(let [find (cljs.reader/read-string find)
|
||||||
opts (cljify options)]
|
opts (cljify options)]
|
||||||
(take-pair-as-promise!
|
(take-pair-as-promise!
|
||||||
(db/<?q db find opts)
|
(d/<q db find opts)
|
||||||
clj->js)))
|
clj->js)))
|
||||||
|
|
||||||
(defn ^:export ensure-schema [conn simple-schema]
|
(defn ^:export ensure-schema [conn simple-schema]
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
datoms (simple-schema/simple-schema->schema simple-schema)]
|
datoms (simple-schema/simple-schema->schema simple-schema)]
|
||||||
(println "Transacting schema datoms" (pr-str datoms))
|
(println "Transacting schema datoms" (pr-str datoms))
|
||||||
(take-pair-as-promise!
|
(take-pair-as-promise!
|
||||||
(transact/<transact!
|
(d/<transact!
|
||||||
conn
|
conn
|
||||||
datoms)
|
datoms)
|
||||||
clj->js)))
|
clj->js)))
|
||||||
|
@ -52,9 +52,8 @@
|
||||||
;; Expects a JS array as input.
|
;; Expects a JS array as input.
|
||||||
(try
|
(try
|
||||||
(let [tx-data (js->tx-data tx-data)]
|
(let [tx-data (js->tx-data tx-data)]
|
||||||
(println "Transacting:" (pr-str tx-data))
|
|
||||||
(go-promise clj->js
|
(go-promise clj->js
|
||||||
(let [tx-result (<? (transact/<transact! conn tx-data))]
|
(let [tx-result (<? (d/<transact! conn tx-data))]
|
||||||
(select-keys tx-result
|
(select-keys tx-result
|
||||||
[:tempids
|
[:tempids
|
||||||
:added-idents
|
:added-idents
|
||||||
|
@ -73,13 +72,13 @@
|
||||||
;; We pickle the connection as a thunk here so it roundtrips through JS
|
;; We pickle the connection as a thunk here so it roundtrips through JS
|
||||||
;; without incident.
|
;; without incident.
|
||||||
{:conn (fn [] c)
|
{:conn (fn [] c)
|
||||||
:db (fn [] (transact/db c))
|
:db (fn [] (d/db c))
|
||||||
:path path
|
:path path
|
||||||
|
|
||||||
;; Primary API.
|
;; Primary API.
|
||||||
:ensureSchema (fn [simple-schema] (ensure-schema c simple-schema))
|
:ensureSchema (fn [simple-schema] (ensure-schema c simple-schema))
|
||||||
:transact (fn [tx-data] (transact c tx-data))
|
:transact (fn [tx-data] (transact c tx-data))
|
||||||
:q (fn [find opts] (q (transact/db c) find opts))
|
:q (fn [find opts] (q (d/db c) find opts))
|
||||||
:close (fn [] (db/close-db db))
|
:close (fn [] (db/close-db db))
|
||||||
|
|
||||||
;; Some helpers for testing the bridge.
|
;; Some helpers for testing the bridge.
|
||||||
|
|
Loading…
Reference in a new issue