Introduce js-sqlite as an abstraction wrapper around Sqlite.jsm and promise-sqlite.
This commit is contained in:
parent
cc25ce33e2
commit
1cfbf8498c
7 changed files with 26 additions and 6 deletions
20
src-node/datomish/js_sqlite.cljs
Normal file
20
src-node/datomish/js_sqlite.cljs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
(ns datomish.js-sqlite
|
||||||
|
(:require
|
||||||
|
[datomish.sqlite :as s]
|
||||||
|
[datomish.js-util :refer [is-node?]]
|
||||||
|
[datomish.promise-sqlite :as promise-sqlite]))
|
||||||
|
|
||||||
|
(def open promise-sqlite/open)
|
||||||
|
|
||||||
|
(extend-protocol s/ISQLiteConnectionFactory
|
||||||
|
string
|
||||||
|
(<sqlite-connection [path]
|
||||||
|
(open path))
|
||||||
|
|
||||||
|
object ;; TODO: narrow this to the result of node-tempfile/tempfile.
|
||||||
|
(<sqlite-connection [tempfile]
|
||||||
|
(open (.-name tempfile))))
|
|
@ -22,7 +22,7 @@
|
||||||
[datomish.test-macros :refer [deftest-async deftest-db]]
|
[datomish.test-macros :refer [deftest-async deftest-db]]
|
||||||
[clojure.test :as t :refer [is are deftest testing]]
|
[clojure.test :as t :refer [is are deftest testing]]
|
||||||
[clojure.core.async :refer [go <! >!]]])
|
[clojure.core.async :refer [go <! >!]]])
|
||||||
#?@(:cljs [[datomish.promise-sqlite]
|
#?@(:cljs [[datomish.js-sqlite]
|
||||||
[datomish.pair-chan]
|
[datomish.pair-chan]
|
||||||
[datomish.test-macros :refer-macros [deftest-async deftest-db]]
|
[datomish.test-macros :refer-macros [deftest-async deftest-db]]
|
||||||
[datomish.node-tempfile :refer [tempfile]]
|
[datomish.node-tempfile :refer [tempfile]]
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
[datomish.test-macros :refer [deftest-async]]
|
[datomish.test-macros :refer [deftest-async]]
|
||||||
[clojure.test :as t :refer [is are deftest testing]]
|
[clojure.test :as t :refer [is are deftest testing]]
|
||||||
[clojure.core.async :refer [go <! >!]]])
|
[clojure.core.async :refer [go <! >!]]])
|
||||||
#?@(:cljs [[datomish.promise-sqlite]
|
#?@(:cljs [[datomish.js-sqlite]
|
||||||
[datomish.pair-chan]
|
[datomish.pair-chan]
|
||||||
[datomish.test-macros :refer-macros [deftest-async]]
|
[datomish.test-macros :refer-macros [deftest-async]]
|
||||||
[datomish.node-tempfile :refer [tempfile]]
|
[datomish.node-tempfile :refer [tempfile]]
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
[cljs.test :refer-macros [is are deftest testing async]]
|
[cljs.test :refer-macros [is are deftest testing async]]
|
||||||
[datomish.pair-chan]
|
[datomish.pair-chan]
|
||||||
[datomish.sqlite :as s]
|
[datomish.sqlite :as s]
|
||||||
[datomish.promise-sqlite :as ps]))
|
[datomish.js-sqlite :as ps]))
|
||||||
|
|
||||||
(deftest-async test-all-rows
|
(deftest-async test-all-rows
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
[datomish.test-macros :refer [deftest-async]]
|
[datomish.test-macros :refer [deftest-async]]
|
||||||
[clojure.test :as t :refer [is are deftest testing]]
|
[clojure.test :as t :refer [is are deftest testing]]
|
||||||
[clojure.core.async :refer [go <! >!]]])
|
[clojure.core.async :refer [go <! >!]]])
|
||||||
#?@(:cljs [[datomish.promise-sqlite]
|
#?@(:cljs [[datomish.js-sqlite]
|
||||||
[datomish.pair-chan]
|
[datomish.pair-chan]
|
||||||
[datomish.test-macros :refer-macros [deftest-async]]
|
[datomish.test-macros :refer-macros [deftest-async]]
|
||||||
[datomish.node-tempfile :refer [tempfile]]
|
[datomish.node-tempfile :refer [tempfile]]
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
[tempfile.core :refer [tempfile with-tempfile]]
|
[tempfile.core :refer [tempfile with-tempfile]]
|
||||||
[clojure.test :as t :refer [is are deftest testing]]])
|
[clojure.test :as t :refer [is are deftest testing]]])
|
||||||
#?@(:cljs
|
#?@(:cljs
|
||||||
[[datomish.promise-sqlite]
|
[[datomish.js-sqlite]
|
||||||
[datomish.test-macros :refer-macros [deftest-db]]
|
[datomish.test-macros :refer-macros [deftest-db]]
|
||||||
[honeysql.core :as sql :refer-macros [param]]
|
[honeysql.core :as sql :refer-macros [param]]
|
||||||
[datomish.node-tempfile :refer [tempfile]]
|
[datomish.node-tempfile :refer [tempfile]]
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
[datomish.test-macros :refer [deftest-async deftest-db]]
|
[datomish.test-macros :refer [deftest-async deftest-db]]
|
||||||
[clojure.test :as t :refer [is are deftest testing]]
|
[clojure.test :as t :refer [is are deftest testing]]
|
||||||
[clojure.core.async :refer [go <! >!]]])
|
[clojure.core.async :refer [go <! >!]]])
|
||||||
#?@(:cljs [[datomish.promise-sqlite]
|
#?@(:cljs [[datomish.js-sqlite]
|
||||||
[datomish.pair-chan]
|
[datomish.pair-chan]
|
||||||
[datomish.test-macros :refer-macros [deftest-async deftest-db]]
|
[datomish.test-macros :refer-macros [deftest-async deftest-db]]
|
||||||
[datomish.node-tempfile :refer [tempfile]]
|
[datomish.node-tempfile :refer [tempfile]]
|
||||||
|
|
Loading…
Reference in a new issue