我正在使用Parse.Relation
在主題下對用戶進行分組。如何檢索指向給定用戶的所有主題(topic.relation
)?獲取指向給定對象的所有Parse.Relations
問題是關於在單個調用/回調中執行此操作。
// first add() a User object to the Topic's Parse.Relation
this.friendRelation = this.topic.relation("friend");
this.friendRelation.add(user);
// save the Topic to save its newly added .relation to Parse/Mongo
this.topic.save();
// iterate by adding the same User to several Topics
// (...)
// then you want to retrieve all Parse.Relations of all Topics where that
// specific user is pointed to
// the non-optimized way is to traverse every row in the Topics index
// and query each topic for its relations to find matching pointers to our user,
// which means that the number of calls is bound to the number of rows – fine for
// 10 topics in Mongo but passed 100 it won't be tolerable.
請發佈一些代碼,這將有助於我們更清楚地理解您的問題。 – 2012-07-27 02:34:58
嗨謝赫,這是一些初始代碼來設置多對多的關係。現在製作迭代器給你一個效率低下的想法。 – 2012-07-27 18:04:23