【发布时间】:2015-04-19 05:57:56
【问题描述】:
我的 Parse 架构中有以下关系: 带有“评论”子项目的“发布”项目。我正在将数组用于一对多关系,如下所述:relations_guide
如何获取所有帖子(即使是没有 cmets 的帖子)以及每个帖子的所有 cmets?
我正在尝试这样的事情:
var post = Parse.Object.extend("post");
var comment = Parse.Object.extend("comment");
var queryPosts = new Parse.Query(post);
var queryComments = new Parse.Query(comment);
queryPosts.matchesQuery("commentsList", queryComments);
return queryPosts.find().then(function (postsResult) {
console.log('prepareResponses: number of posts found: ' + postsResult.length);
然后,当然,我想让 cmets 退出帖子 大概是这样?
p = postsResult[0].get("commentsList");
console.log("Number of comments in the first post is: " + p.length);
【问题讨论】:
-
您是要查找所有帖子、所有带有特定 cmets 的帖子,还是所有 cmets?不清楚你想要什么
-
尝试查找所有帖子,即使是那些 cmets 为零的帖子)以及每个帖子的所有 cmets。
标签: javascript parse-platform one-to-many relation