transform and changing pick! to pick #71

wants to merge 1 commit into


None yet
2 participants

ninjudd commented Mar 1, 2011

Hey Lau,

I'm submitting this as a pull request even though I could commit it directly because I want you to take a look and sign off first.

I added a transform method to RTable that lets you specify a transform function to be executed after deref. I also implmented pick using it based on the conversation we had in #clojureql. The transform function will also be really useful for other data transformations that have to be done in Clojure. i.e:

;; i just want a list of emails for all users
@(transform users #(map :email %))

;; several fields are json, and i need to parse them when records are loaded
@(transform records #(map parse-json %))

Transforms are also composable:

;; only parse and return the first record
@(-> records (transform #(map parse-json %)) (transform first))

I'm pretty excited about this feature as it is going to clean up a lot of our code and make ClojureQL even easier for our engineers to use.

Let me know if you have any questions.



bendlas commented Jul 28, 2011

Committed as 7584a38

@bendlas bendlas closed this Jul 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment