Introduce js-sqlite as an abstraction wrapper around Sqlite.jsm and promise-sqlite.

This commit is contained in:
Richard Newman 2016-09-07 17:16:03 -07:00
parent cc25ce33e2
commit 1cfbf8498c
7 changed files with 26 additions and 6 deletions

View 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))))

View file

@ -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]]

View file

@ -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]]

View file

@ -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)]

View file

@ -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]]

View file

@ -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]]

View file

@ -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]]