Skip to content

Instantly share code, notes, and snippets.

@adelevie
Last active December 11, 2015 13:59
Show Gist options
  • Save adelevie/4611516 to your computer and use it in GitHub Desktop.
Save adelevie/4611516 to your computer and use it in GitHub Desktop.
{
"hometown": {
"$select": {
"query": {
"className": "Team",
"where": {
"winPct": {
"$gt": 0.5
}
}
},
"key": "city"
}
}
}
# 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
# 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