Created
October 27, 2012 12:56
-
-
Save toff63/3964545 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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