Skip to content

Instantly share code, notes, and snippets.

@toff63
Created October 27, 2012 12:56
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 toff63/3964545 to your computer and use it in GitHub Desktop.
Save toff63/3964545 to your computer and use it in GitHub Desktop.
;; find all community names and urls -- implicit join
(pprint (seq (q '[:find ?n ?u
:where
[?c :community/name ?n]
[?c :community/url ?u]]
(db conn))))
;; return
;; (["Chinatown/International District" "http://www.cidbia.org/"]
;; ["All About Belltown" "http://www.belltown.org/"]
;; ["Friends of Discovery Park" "http://www.friendsdiscoverypark.org/"])
;; add variables
(pprint (seq (q '[:find ?e ?c
:in $ ?communityName
:where
[?e :community/name ?communityName]
[?e :community/category ?c]]
(db conn) "belltown")))
;; return
;; ([17592186045494 "events"] [17592186045494 "news"])
;; rules
;; find all names of all communities that are twitter feeds, using rules
(let [rules '[[[twitter ?c]
[?c :community/type :community.type/twitter]]]]
(pprint (seq (q '[:find ?n
:in $ %
:where
[?c :community/name ?n]
(twitter ?c)]
(db conn)
rules))))
;; return (["Discover SLU"] ["Columbia Citizens"] ["Fremont Universe"] ["Magnolia Voice"] ["Maple Leaf Life"]
;; ["MyWallingford"])
;; fulltext search
(pprint (seq (q '[:find ?n
:where [(fulltext $ :community/name "Wallingford") [[?e ?n]]]]
(db conn))))
;; (["KOMO Communities - Wallingford"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment