1

I implemented a query for chat messages in PARSE using their REST API. My problem is, I am getting messages where somehow sender and receiver was the same.

Clearly a bug or a test in the debug version. Anyway, those messages should not get displayed.

Obviously I want to fix that by changing my PARSE Query and not go through all the messages and delete the wrong ones. Is that even possible? I am not very good with the PARSE REST API.

This is what I am passing to PARSE API:

         $aWhere = array(
                        self::FIELD_SENDER =>   array('$in' => array($sUsername1, $sUsername2)),
                        self::FIELD_RECEIVER => array('$in' => array($sUsername1, $sUsername2)),                    
                    );  

$url = 'https://api.parse.com/1/classes/test?where='.json_encode($aWhere);

url then gets passed into CURL

I want to avoid messages where self::FIELD_SENDER is $sUsername1 AND self::FIELD_RECEIVER is $sUsername1 and the same goes in respect to $sUsername2.

1 Answer 1

1

I strongly recommend you instead fix your data using a Job.

As for what you are asking for, you can't quite get what you want. Let's explore the logic:

  • You could try building an OR query
    • Query1: sender != user1 AND receiver != user1
    • Query2: sender != user2 AND receiver != user2

This may seem like it will give the results you want, except the situation excluded by Query1 is satisfied by Query2 and vice versa.

What about using $nin (not in):

  • sender not in (user1, user2)
  • receiver not in (user1, user2)

Unfortunately this will also exclude the following messages:

  • sender=user1, receiver=(anyone)
  • sender=user2, receiver=(anyone)
  • sender=(anyone), receiver=user1
  • sender=(anyone), receiver=user2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.