[英]Get a Query right in Parse REST API
I implemented a query for chat messages in PARSE using their REST API. 我使用REST API在PARSE中实现了对聊天消息的查询。 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. 显然,我想通过更改PARSE查询来解决此问题,而不要遍历所有消息并删除错误的消息。 Is that even possible? 那有可能吗? I am not very good with the PARSE REST API. 我对PARSE REST API不太满意。
This is what I am passing to PARSE API: 这就是我要传递给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 网址然后传递到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
. 我想避免以下消息: self::FIELD_SENDER
是$sUsername1
,而self::FIELD_RECEIVER
是$sUsername1
,对于$sUsername2
。
I strongly recommend you instead fix your data using a Job. 我强烈建议您改用Job修复数据。
As for what you are asking for, you can't quite get what you want. 至于您要的东西,您根本无法获得想要的东西。 Let's explore the logic: 让我们探讨一下逻辑:
This may seem like it will give the results you want, except the situation excluded by Query1 is satisfied by Query2 and vice versa. 看起来这将提供所需的结果,但Query2可以满足Query1排除的情况,反之亦然。
What about using $nin (not in): 如何使用$ nin(不在):
Unfortunately this will also exclude the following messages: 不幸的是,这还将排除以下消息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.