Parse - setting multiple conditions in xcode (objective-c)

I'm using a parsing backend for my apps database in Xcode (objective-c), but I don't know how to write a multiple parsing format query. I want to convert the following request to a parsing format request in Xcode.

$msg_record = $this->db->query('SELECT msg, send_id, send_time FROM msg_record
                     WHERE (send_id=123456789 AND to_id=987654321) OR (send_id=987654321 AND to_id=123456789)
                     ORDER BY send_time ASC')->result();

      

Can anyone help me transform the request? Thank.

+3


source to share


1 answer


To create or condition in a Parse query, you will need to make two (or more) subqueries, which you concatenate with orQueryWithSubqueries

. Be aware that you cannot translate SELECT

directly from SQL to Parse.

This is what you are looking for:



PFQuery *query1 = [PFQuery queryWithClassName:@"msg_record"];
[query1 whereKey:@"send_id" equalTo:@"123456789"];
[query1 whereKey:@"to_id" equalTo:@"987654321"];

PFQuery *query2 = [PFQuery queryWithClassName:@"msg_record"];
[query2 whereKey:@"send_id" equalTo:@"987654321"];
[query2 whereKey:@"to_id" equalTo:@"123456789"];

PFQuery *mainQuery = [PFQuery orQueryWithSubqueries:@[query1,query2]];
[mainQuery orderByAscending:@"send_time"];

      

+5


source







All Articles