Fix cljs
This commit is contained in:
parent
7a90c43a5a
commit
80742242e2
4 changed files with 8 additions and 4 deletions
|
@ -122,7 +122,8 @@
|
||||||
:v (Datom. (.-e d) (.-a d) v (.-tx d) (.-added d))
|
:v (Datom. (.-e d) (.-a d) v (.-tx d) (.-added d))
|
||||||
:tx (Datom. (.-e d) (.-a d) (.-v d) v (.-added d))
|
:tx (Datom. (.-e d) (.-a d) (.-v d) v (.-added d))
|
||||||
:added (Datom. (.-e d) (.-a d) (.-v d) (.-tx d) v)
|
:added (Datom. (.-e d) (.-a d) (.-v d) (.-tx d) v)
|
||||||
(throw (IllegalArgumentException. (str "invalid key for #datascript/Datom: " k)))))
|
#?(:clj (throw (IllegalArgumentException. (str "invalid key for #datascript/Datom: " k)))
|
||||||
|
:cljs (throw (js/Error. (str "invalid key for #datascript/Datom: " k))))))
|
||||||
|
|
||||||
;; printing and reading
|
;; printing and reading
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@
|
||||||
{:db.type/ref { :valid? #(and (integer? %) (pos? %)) :->SQLite identity :<-SQLite identity }
|
{:db.type/ref { :valid? #(and (integer? %) (pos? %)) :->SQLite identity :<-SQLite identity }
|
||||||
:db.type/keyword { :valid? keyword? :->SQLite str :<-SQLite #(keyword (subs % 1)) }
|
:db.type/keyword { :valid? keyword? :->SQLite str :<-SQLite #(keyword (subs % 1)) }
|
||||||
:db.type/string { :valid? string? :->SQLite identity :<-SQLite identity }
|
:db.type/string { :valid? string? :->SQLite identity :<-SQLite identity }
|
||||||
:db.type/boolean { :valid? #(instance? Boolean %) :->SQLite #(if % 1 0) :<-SQLite #(if (= % 1) true false) }
|
:db.type/boolean { :valid? #?(:clj #(instance? Boolean %) :cljs #(= js/Boolean (type %))) :->SQLite #(if % 1 0) :<-SQLite #(if (= % 1) true false) }
|
||||||
:db.type/integer { :valid? integer? :->SQLite identity :<-SQLite identity }
|
:db.type/integer { :valid? integer? :->SQLite identity :<-SQLite identity }
|
||||||
:db.type/real { :valid? float? :->SQLite identity :<-SQLite identity }
|
:db.type/real { :valid? #?(:clj float? :cljs number?) :->SQLite identity :<-SQLite identity }
|
||||||
})
|
})
|
||||||
|
|
||||||
(defn #?@(:clj [^Boolean ensure-valid-value]
|
(defn #?@(:clj [^Boolean ensure-valid-value]
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
(if (and (symbol? x)
|
(if (and (symbol? x)
|
||||||
(str/starts-with? (name x) "?"))
|
(str/starts-with? (name x) "?"))
|
||||||
(keyword (subs (name x) 1))
|
(keyword (subs (name x) 1))
|
||||||
(raise-str x " is not a Datalog var.")))
|
(throw (ex-info (str x " is not a Datalog var.") {}))))
|
||||||
|
|
||||||
(defn conj-in
|
(defn conj-in
|
||||||
"Associates a value into a sequence in a nested associative structure, where
|
"Associates a value into a sequence in a nested associative structure, where
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(:import [datascript.db DB])))
|
(:import [datascript.db DB])))
|
||||||
|
|
||||||
|
#?(:cljs
|
||||||
|
(def Throwable js/Error))
|
||||||
|
|
||||||
(defn- <datoms [db]
|
(defn- <datoms [db]
|
||||||
(let [entids (zipmap (vals (dm/idents db)) (keys (dm/idents db)))]
|
(let [entids (zipmap (vals (dm/idents db)) (keys (dm/idents db)))]
|
||||||
(go-pair
|
(go-pair
|
||||||
|
|
Loading…
Reference in a new issue