简体   繁体   English

复合查询JS SDK paRse.com

[英]Compound Query JS SDK paRse.com

I have one class Messages with 3 principal fields: 我有一类消息,具有3个主要字段:

id FromUser ToUser id FromUser ToUser

I do have a query where the To = Value field and the From field is not repeated. 我确实有一个查询,其中“ To = Value”字段和“ From”字段不重复。 I mean, get all FROMUSER who sent me a message. 我的意思是,得到所有给我发送消息的FROMUSER。

Any Idea? 任何想法?

Thanks! 谢谢!

As @Fosco says, "group by" or "select distinct" are not supported yet in Parse.com. 正如@Fosco所说,Parse.com尚不支持“分组依据”或“选择不同”。

Moreover keep in mind the restriction on the selection limit (max 1000 results for query) and timeout request call ( 3 seconds in the before save events, 7/10 seconds in the custom functions ). 此外,请记住选择限制(最多1000个查询结果)和超时请求调用的限制(保存事件之前3秒,自定义函数7/10秒)。 For the "count" selection, the restriction is the timeout request call. 对于“计数”选择,限制是超时请求调用。

I'm working on Parse.com too, and i've changed a lot the structure of my db model, often adding some inconsistent columns in several classes, keeping them carefully updated for each necessary query. 我也在Parse.com上工作,并且更改了数据库模型的结构,经常在几个类中添加一些不一致的列,以针对每个必要的查询对其进行仔细更新。

For cases like yours, i suggest to make a custom function, that keep in input two parameter ( we can say, "myLimit" and "myOffset" ) for the lazy loading, then select the slices, and programmatically try to filter the resulting array item list (with a simple search using for..loop, or using some utility of UnderscoreJS). 对于像您这样的情况,我建议创建一个自定义函数,将输入两个参数(我们可以说为“ myLimit”和“ myOffset”)用于延迟加载,然后选择切片,并以编程方式尝试过滤结果数组项目列表(使用for..loop或使用UnderscoreJS的一些实用工具进行简单搜索)。 Start with small slices ( eg: 200-300 records maximum for selection ) until the last selection returns zero results ( end reached). 从小片开始(例如:200-300条记录供选择最多),直到最后一次选择返回零结果(到达终点)。 You could count all items before start all of this, but the timeout limitation could cause you problems. 您可以在开始所有操作之前计算所有项目,但是超时限制可能会给您带来麻烦。 If this not works as expected try to make the same, client side. 如果这不能按预期工作,请尝试使客户端相同。

You could also make a different approach, so creating another table/class, and for each new message, adding the FromUser in that table ONLY if it doesn't already exist, for that specified ToUser. 您还可以采用其他方法,因此创建另一个表/类,并为每个新消息,仅对于该指定的ToUser,将FromUser添加到该表中(如果尚不存在)。

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM