These tools in reality would probably live behind a protocol for a polymorphic runtime dispatch (i.e. so they can be added to varous store types)
(defn select [conn query]
(println "reading from" conn "query:" query)
[1 2 3])
(defn insert [conn query]
(println "writing to" conn "data:" query))(defn inc-all [xs]
(map inc xs))
(defn sum [xs]
(reduce + xs))- read from a datastore
- calculate something
- calculate more
(-> :data-store ;; in reality this would be a real connection object
(select {:where {:status "ready"}})
inc-all
sum)results:
reading from :data-store query: {:where {:status ready}}
9- read from a datastore
- calculate something
- calculate more
- write it to a data store
(let [db :data-store] ;; in reality this would be a real connection object
(->> (select db {:where {:status "ready"}})
inc-all
sum
(insert db)))results:
reading from :data-store query: {:where {:status ready}}
writing to :data-store data: 9