Reputation: 145
I am having difficulties working out how to perform an OR type query using the parse rest API.
I have two classes set up as below. There is a one - many relationship between A and B
ClassA
-> objectId
-> player1
-> player2
ClassB
-> objectId
-> ClassAId (pointer)
-> someData1
-> someData2
What I am trying to do is get all ClassB records where the current user ID is either in player1 OR player2 field if ClassA.
I can get the query working when just looking to see if player1 field is the current user i.e. my lua table looks like this (then it is encoded to JSON and sent to parse). I then send that query to the ClassB rest url.
local queryTable = {
["where"] = {
["ClassAId"] = {
["$inQuery"] = {["where"] = { ["player1"] = settings.userID}
, ["className"] = "ClassA" }
}
}
}
Could somebody point to how I can also include the player2 field.
If this was SQL I'd be on it like sonic but parse is a slightly different beast!
Upvotes: 1
Views: 1410
Reputation: 16874
Check out the documentation on compound queries:
https://parse.com/docs/rest#queries-compound
As shown the pattern is "where={"$or":[{..expression1..},{..expression2..}]}".
So your existing expression would be in place of "..expression1..", and you would use a copy of that for player2
in place of "..expression2..".
Upvotes: 2