Parse.com - 在一个对象数组中查询

Ram*_*sel 3 parse-platform

我有一个Photo Class和一个Comments Class.我正在尝试实现一种搜索,用户可以在其中检索包含带有某些单词的评论的照片.我想到了几种方法,最简单的似乎是在Photo Class中包含一个Comments对象数组.

但是,我无法弄清楚如何查询此注释对象数组以查询其关键的"内容".


做类似于创建注释字符串数组本身的方法可行,但出于一致性的原因,我宁愿保存指向注释的指针.

Por*_*nny 8

Timothy is correct, so feel free to vote for whatever (never bad to share the love), I'm just paraphrasing.

您针对评论表构建查询,然后将其与照片进行匹配.

PFQuery *commentsQuery = [PFQuery queryWithClassName:@"Comments"];

//you can keep entering more or queries to get more terms
[commentsQuery whereKey:@"content containsString:"searchterm"]

PFQuery *photosQuery = [PFQuery queryWithClassName:@"Photos"];
[photosQuery whereKey:@"_id" matchesKey:@"photo" inQuery:commentsQuery]
[photosQuery fetch];
Run Code Online (Sandbox Code Playgroud)