Wednesday, February 25, 2009

Fancy Queries for clj-record

Thanks to another contribution from Tunde Ashafa, clj-record now has support for more advanced queries using functions in the new clj-record.query namespace.

Previously you could do this:

(manufacturer/find-records {:grade 98})
; or
(manufacturer/find-records {:name "Humedai Motors"})

Now you can do this:

; having required [clj-record.query :as q]
(manufacturer/find-records {:grade (q/greater-than 90)})
; or
(manufacturer/find-records {:name (q/like "Hume%")})

See the tests for more examples of what it does. See the source for how it's implemented. And please: recommend improvements.

No comments: