Follow-up: lift helpers to IDB.
This commit is contained in:
parent
65d71a2598
commit
f408cfd314
1 changed files with 29 additions and 23 deletions
|
@ -79,6 +79,14 @@
|
||||||
[db datoms]
|
[db datoms]
|
||||||
"Apply datoms to the store.")
|
"Apply datoms to the store.")
|
||||||
|
|
||||||
|
(<apply-db-ident-assertions
|
||||||
|
[db added-idents]
|
||||||
|
"Apply added idents to the store.")
|
||||||
|
|
||||||
|
(<apply-db-install-assertions
|
||||||
|
[db fragment]
|
||||||
|
"Apply added schema fragment to the store.")
|
||||||
|
|
||||||
(<advance-tx
|
(<advance-tx
|
||||||
[db]
|
[db]
|
||||||
"TODO: document this interface."))
|
"TODO: document this interface."))
|
||||||
|
@ -197,7 +205,27 @@
|
||||||
|
|
||||||
;; TODO: handle exclusion across transactions here.
|
;; TODO: handle exclusion across transactions here.
|
||||||
(update db :current-tx inc))))
|
(update db :current-tx inc))))
|
||||||
;; )
|
|
||||||
|
(<apply-db-ident-assertions [db added-idents]
|
||||||
|
(go-pair
|
||||||
|
(let [->SQLite (get-in ds/value-type-map [:db.type/keyword :->SQLite]) ;; TODO: make this a protocol.
|
||||||
|
exec (partial s/execute! (:sqlite-connection db))]
|
||||||
|
;; TODO: batch insert.
|
||||||
|
(doseq [[ident entid] added-idents]
|
||||||
|
(<? (exec
|
||||||
|
["INSERT INTO idents VALUES (?, ?)" (->SQLite ident) entid]))))
|
||||||
|
db))
|
||||||
|
|
||||||
|
(<apply-db-install-assertions [db fragment]
|
||||||
|
(go-pair
|
||||||
|
(let [->SQLite (get-in ds/value-type-map [:db.type/keyword :->SQLite]) ;; TODO: make this a protocol.
|
||||||
|
exec (partial s/execute! (:sqlite-connection db))]
|
||||||
|
;; TODO: batch insert.
|
||||||
|
(doseq [[ident attr-map] fragment]
|
||||||
|
(doseq [[attr value] attr-map]
|
||||||
|
(<? (exec
|
||||||
|
["INSERT INTO schema VALUES (?, ?, ?)" (->SQLite ident) (->SQLite attr) (->SQLite value)])))))
|
||||||
|
db))
|
||||||
|
|
||||||
(close-db [db] (s/close (.-sqlite-connection db)))
|
(close-db [db] (s/close (.-sqlite-connection db)))
|
||||||
|
|
||||||
|
@ -984,28 +1012,6 @@
|
||||||
schema-fragment (datomish.schema-changes/datoms->schema-fragment datoms)]
|
schema-fragment (datomish.schema-changes/datoms->schema-fragment datoms)]
|
||||||
(assoc-in report [:added-attributes] schema-fragment)))
|
(assoc-in report [:added-attributes] schema-fragment)))
|
||||||
|
|
||||||
;; TODO: lift to IDB.
|
|
||||||
(defn <apply-db-ident-assertions [db added-idents]
|
|
||||||
(go-pair
|
|
||||||
(let [->SQLite (get-in ds/value-type-map [:db.type/keyword :->SQLite]) ;; TODO: make this a protocol.
|
|
||||||
exec (partial s/execute! (:sqlite-connection db))]
|
|
||||||
;; TODO: batch insert.
|
|
||||||
(doseq [[ident entid] added-idents]
|
|
||||||
(<? (exec
|
|
||||||
["INSERT INTO idents VALUES (?, ?)" (->SQLite ident) entid]))))
|
|
||||||
db))
|
|
||||||
|
|
||||||
(defn <apply-db-install-assertions [db fragment]
|
|
||||||
(go-pair
|
|
||||||
(let [->SQLite (get-in ds/value-type-map [:db.type/keyword :->SQLite]) ;; TODO: make this a protocol.
|
|
||||||
exec (partial s/execute! (:sqlite-connection db))]
|
|
||||||
;; TODO: batch insert.
|
|
||||||
(doseq [[ident attr-map] fragment]
|
|
||||||
(doseq [[attr value] attr-map]
|
|
||||||
(<? (exec
|
|
||||||
["INSERT INTO schema VALUES (?, ?, ?)" (->SQLite ident) (->SQLite attr) (->SQLite value)])))))
|
|
||||||
db))
|
|
||||||
|
|
||||||
(defn- <with-internal [db tx-data merge-ident merge-attr]
|
(defn- <with-internal [db tx-data merge-ident merge-attr]
|
||||||
(go-pair
|
(go-pair
|
||||||
(let [report (->>
|
(let [report (->>
|
||||||
|
|
Loading…
Reference in a new issue