Hacking on exec-repl.
This commit is contained in:
parent
42361c1e5e
commit
d9cff5fa3c
1 changed files with 32 additions and 3 deletions
|
@ -10,10 +10,10 @@
|
||||||
[cljs.core.async.macros :refer [go]]))
|
[cljs.core.async.macros :refer [go]]))
|
||||||
(:require
|
(:require
|
||||||
[datomish.db :as db]
|
[datomish.db :as db]
|
||||||
[datomish.exec :as exec]
|
|
||||||
[datomish.sqlite :as s]
|
[datomish.sqlite :as s]
|
||||||
[datomish.sqlite-schema :as ss]
|
[datomish.sqlite-schema :as ss]
|
||||||
[datomish.query :as dq]
|
[datomish.query :as dq]
|
||||||
|
[datomish.transact :as transact]
|
||||||
#?@(:clj
|
#?@(:clj
|
||||||
[[datomish.jdbc-sqlite]
|
[[datomish.jdbc-sqlite]
|
||||||
[datomish.pair-chan :refer [go-pair <?]]
|
[datomish.pair-chan :refer [go-pair <?]]
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
"Given an open database, returns a lazy sequence of results.
|
"Given an open database, returns a lazy sequence of results.
|
||||||
When fully consumed, underlying resources will be released."
|
When fully consumed, underlying resources will be released."
|
||||||
[db find]
|
[db find]
|
||||||
(pair-channel->lazy-seq (exec/<?run db find))))
|
(pair-channel->lazy-seq (db/<?run db find))))
|
||||||
|
|
||||||
(defn xxopen []
|
(defn xxopen []
|
||||||
(datomish.pair-chan/go-pair
|
(datomish.pair-chan/go-pair
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
(def db d))))
|
(def db d))))
|
||||||
|
|
||||||
;; With an open DB…
|
;; With an open DB…
|
||||||
#_(datomish.exec/run-to-pair-seq
|
#_(run-to-pair-seq
|
||||||
db
|
db
|
||||||
'[:find ?page :in $ :where [?page :page/starred true ?t]])
|
'[:find ?page :in $ :where [?page :page/starred true ?t]])
|
||||||
|
|
||||||
|
@ -66,3 +66,32 @@
|
||||||
(println
|
(println
|
||||||
"Result: "
|
"Result: "
|
||||||
(<! (db/<?q d '[:find ?page :in $ :where [?page :page/starred true ?t]] {})))))
|
(<! (db/<?q d '[:find ?page :in $ :where [?page :page/starred true ?t]] {})))))
|
||||||
|
|
||||||
|
|
||||||
|
#_
|
||||||
|
(go-pair
|
||||||
|
(let [connection (<? (s/<sqlite-connection "/tmp/foo.sqlite"))
|
||||||
|
dd (<? (db/<with-sqlite-connection connection))]
|
||||||
|
(def *db* dd)))
|
||||||
|
#_
|
||||||
|
(clojure.core.async/<!!
|
||||||
|
(go-pair
|
||||||
|
(let [now -1
|
||||||
|
forms (mapcat (fn [i]
|
||||||
|
(map (fn [j]
|
||||||
|
[:db/add i :x j true])
|
||||||
|
(range 1000 (* i 2000) i)))
|
||||||
|
(range 1 10))]
|
||||||
|
(println "Adding" (count forms) "forms")
|
||||||
|
(<? (transact/<transact! *db* forms nil now)))))
|
||||||
|
|
||||||
|
#_
|
||||||
|
(go-pair
|
||||||
|
(let [connection (<? (s/<sqlite-connection "/tmp/foo.sqlite"))
|
||||||
|
dd (<? (db/<with-sqlite-connection connection))]
|
||||||
|
(println
|
||||||
|
(count
|
||||||
|
(<? (db/<?q dd
|
||||||
|
'[:find ?e ?v :in $ :where
|
||||||
|
[?e :x ?v]
|
||||||
|
#_[(> ?v 1000)]] {}))))))
|
||||||
|
|
Loading…
Reference in a new issue