;; 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.db-factory #?(:cljs (:require-macros [datomish.pair-chan :refer [go-pair !]]]) #?@(:cljs [[datomish.pair-chan] [cljs.core.async :as a :refer [chan !]]])) #?(:clj (:import [datomish.datom Datom]))) (defn (integer entid), like {:db/ident 0}." (go-pair (let [rows ( {:start integer :idx integer}, like {:db.part/user {start: 0x100 idx: 0x101}}." (go-pair (let [rows ( (map (keyword attribute -> keyword value)), like {:db/ident {:db/cardinality :db.cardinality/one}}." (go-pair (let [ident-map (clojure.set/map-invert idents) ref-tag (sqlite-schema/->tag :db.type/ref) kw<-SQLite (partial sqlite-schema/<-SQLite :db.type/keyword)] (->> (s/all-rows sqlite-connection ["SELECT ident, attr, value, value_type_tag FROM schema"]) (vector (fn [[part {:keys [start idx]}]] [(sqlite-schema/->SQLite part) start idx])] ;; TODO: allow inserting new parts. ;; TODO: think more carefully about allocating new parts and bitmasking part ranges. ;; TODO: install these using bootstrap assertions. It's tricky because the part ranges are implicit. ;; TODO: chunk into 999/3 sections, for safety. (vector bootstrap/parts))))) (-> db ;; We use