Resolve lookup-refs.

This commit is contained in:
Nick Alexander 2016-07-27 14:29:51 -07:00
parent baec3815b0
commit fbd5863921

View file

@ -315,6 +315,10 @@
(transduce conj [] initial-es))
(assoc-in report [:entities]))))
(defn- lookup-ref? [x]
(and (sequential? x)
(= (count x) 2)))
(defn <?run
"Execute the provided query on the provided DB.
Returns a transduced channel of [result err] pairs.
@ -345,6 +349,17 @@
(a/reduce (partial reduce-error-pair conj) [[] nil]
(<?run db find args)))
(defn <resolve-lookup-refs [db report]
(go-pair
(->>
(vec (for [[op & entity] (:entities report)]
(into [op] (for [field entity]
(if (lookup-ref? field)
(first (<? (<eavt db field))) ;; TODO improve this
field)))))
(assoc-in report [:entities])))) ;; TODO: meta.
(defonce -eid (atom (- 0x200 1)))
;; TODO: better here.
@ -497,6 +512,9 @@
(->> initial-report
(preprocess db)
(<resolve-lookup-refs db)
(<?)
(<resolve-id-literals db)
(<?)