Skip to content

Instantly share code, notes, and snippets.

@angerman
Created July 25, 2009 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angerman/154862 to your computer and use it in GitHub Desktop.
Save angerman/154862 to your computer and use it in GitHub Desktop.
(def *filters* {'= Query$FilterOperator/EQUAL
'> Query$FilterOperator/GREATER_THAN
'>= Query$FilterOperator/GREATER_THAN_OR_EQUAL
'< Query$FilterOperator/LESS_THAN
'<= Query$FilterOperator/LESS_THAN_OR_EQUAL})
;; query kind where (= :name x)
;; -> (.addFilter (Query. "Item") :name ('= *filters*) x)
(defmacro query [kind _ filters] `(.addFilter (Query. ~kind)
~(name (nth filters 1))
((first '~filters) *filters*)
~(last filters)))
;; additionally if something like would be supported would be great
;; query kind where [(= :name x) (= :key y)]
;; but if there is a more lispy way to do the query I'm very eager to learn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment