Last active
December 11, 2015 13:59
-
-
Save adelevie/4611516 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
{ | |
"hometown": { | |
"$select": { | |
"query": { | |
"className": "Team", | |
"where": { | |
"winPct": { | |
"$gt": 0.5 | |
} | |
} | |
}, | |
"key": "city" | |
} | |
} | |
} |
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
# experimental | |
# current api | |
users = Parse::Query.new("_User").tap do |user_query| | |
user_query.eq("hometown", { | |
"$select" => { | |
"query" => Parse::Query.new("Team").tap do |team_query| | |
team_query.greater_than("winPct", 0.5) | |
end, | |
"key" => "city" | |
} | |
}) | |
end.get | |
# proposed api | |
users = Parse::Query.new("_User").tap do |user_query| | |
user_query.select_query("hometown", "Team").tap do |team_query| | |
team_query.greater_than("winPct", 0.5) | |
team_query.key = "city" | |
end | |
end.get |
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
# If you have a class containing sports teams and you store a user's hometown in the user class, | |
# you can issue one query to find the list of users whose hometown teams have winning records. The query would look like: | |
curl -X GET \ | |
-H "X-Parse-Application-Id: FOO" \ | |
-H "X-Parse-REST-API-Key: BAR" \ | |
-G \ | |
--data-urlencode 'where={"hometown":{"$select":{"query":{"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}' \ | |
https://api.parse.com/1/classes/_User |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment