Clean up database calls
This commit is contained in:
parent
54067c2103
commit
a02c33c620
2 changed files with 40 additions and 28 deletions
|
|
@ -161,8 +161,15 @@
|
|||
(.continue cursor))))
|
||||
(resolve @result)))))))))
|
||||
|
||||
(defn first-result [xform cursor-req]
|
||||
(transduce-cursor (comp xform (take 1)) (fn [_ x] x) nil cursor-req))
|
||||
(defn first-result
|
||||
"Given a cursor, will return a promise that resolves to the first result.
|
||||
|
||||
Optionally takes an `xform` that can be used to filter or transform values
|
||||
returned by the cursor."
|
||||
([cursor-req]
|
||||
(first-result (map identity) cursor-req))
|
||||
([xform cursor-req]
|
||||
(transduce-cursor (comp xform (take 1)) (fn [_ x] x) nil cursor-req)))
|
||||
|
||||
(comment
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue