This commit is contained in:
Nick Alexander 2016-07-28 14:47:43 -07:00
parent 7a90c43a5a
commit 80742242e2
4 changed files with 8 additions and 4 deletions

View file

@ -122,7 +122,8 @@
:v (Datom. (.-e d) (.-a d) v (.-tx d) (.-added d))
:tx (Datom. (.-e d) (.-a d) (.-v d) v (.-added d))
: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

View file

@ -85,9 +85,9 @@
{:db.type/ref { :valid? #(and (integer? %) (pos? %)) :->SQLite identity :<-SQLite identity }
:db.type/keyword { :valid? keyword? :->SQLite str :<-SQLite #(keyword (subs % 1)) }
: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/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]

View file

@ -36,7 +36,7 @@
(if (and (symbol? x)
(str/starts-with? (name x) "?"))
(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
"Associates a value into a sequence in a nested associative structure, where

View file

@ -32,6 +32,9 @@
#?(:clj
(:import [datascript.db DB])))
#?(:cljs
(def Throwable js/Error))
(defn- <datoms [db]
(let [entids (zipmap (vals (dm/idents db)) (keys (dm/idents db)))]
(go-pair