Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn- ipred [[k v]]
(pred/like k v))
(defn- partial-pred [m]
"Turn a map into a predicate format understood by cql. IE {:a 1 :b 2} --> (pred/and* (pred/=* :a 1) (pred/=* :b 2))"
(apply pred/and* (map ipred m)))
(defprotocol MapFindable
"A protocol for clojureQL searchable things that can be found using a map interface"
(find [this search-map]))
(extend-protocol MapFindable
clojure.lang.PersistentArrayMap
(find [{table :table :as schema} m]
(cql/select (cql/table db/db table) (partial-pred m)))
clojureql.core.RTable
(find [rt m]
(cql/select rt (partial-pred m))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.