Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
clj-util-datomic-peer/src/main/clojure/de/mpg/shh/util_datomic_peer/transaction_data.clj
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (17 sloc)
1.21 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns de.mpg.shh.util-datomic-peer.transaction-data | |
(:require [datascript.core :as ds] | |
[de.mpg.shh.util-datomic-peer.impl.push :as peer-push])) | |
(defn push->tx-data | |
([dt-partition dt-value-type-lookup schema-map push-pattern rows] | |
(let [attr-set (peer-push/push->attr-set #{} push-pattern) | |
component-attrs (filter (partial peer-push/component-attr? schema-map) attr-set) | |
component-attr-id-attr-map (into {} (map #(vector % (peer-push/component-attr->id-attr %)) component-attrs))] | |
(push->tx-data dt-partition dt-value-type-lookup schema-map push-pattern rows component-attr-id-attr-map))) | |
([dt-partition dt-value-type-lookup schema-map push-pattern rows component-attr-id-attr-map] | |
(let [schema (assoc schema-map :db/ident {:db/unique :db.unique/identity}) | |
datoms [] | |
ds-conn (ds/conn-from-db (ds/init-db datoms schema)) | |
attr-paths (peer-push/push->path [] [] push-pattern) | |
attr-paths-lookup (into {} (map #(vector (last %) (vec (butlast %))) attr-paths)) | |
_ (dorun (map (partial peer-push/cache-row ds-conn attr-paths-lookup component-attr-id-attr-map) rows))] | |
(peer-push/datascript->datomic-tx-data ds-conn dt-partition dt-value-type-lookup)))) |