Resolve lookup-refs.
This commit is contained in:
parent
baec3815b0
commit
fbd5863921
1 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
(<?)
|
||||
|
||||
|
|
Loading…
Reference in a new issue