Skip to content

Instantly share code, notes, and snippets.



Created Feb 21, 2011
What would you like to do?
(defn pluralize
"Turn a string to plural"
(if (= (last (name x)) \y)
(apply str (concat (drop-last (name x)) [\i \e \s]))
(str (name x) "s")))
(defn table [t]
(cql/table db (pluralize t)))
(defn col [t c]
(keyword (str (pluralize (name t)) "." (name c))))
(defn fk [t]
(str (name t) "_id"))
(defn pk [t]
(defn refer-fk [t1 t2]
(col t1 (fk t2)))
(defn only-of
"Pass singular keywords for now."
[t1 t2]
(cql/join (table t1)
(table t2)
(cql/where (= (refer-fk t2 t1)
(col t1 (pk t1))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment