获取指向给定对象的所有解析关系
Fetch all Parse.Relations pointing to a given object
我使用Parse.Relation
在Topic下对用户进行分组。如何检索topic.relation
指向给定用户的所有主题?
问题是如何在单个调用/回调中执行此操作。
// 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.
为Topic类构造一个查询,并添加一个equalTo约束。
var query = new Parse.Query(Topic);
query.equalTo("friend", user);
query.find({success: function (returnedTopics) {
...
},
error: function (...) {
}
});
这将返回在其好友关系中包含用户的所有Topic对象。
相关文章:
- 如何从类关系中检索对象列表
- 在Aurelia computeds中,当设置依赖关系时,如何声明对对象属性的依赖关系
- Angular 2,在没有直接关系的两个组件之间共享一个对象
- 经典方法的目的|与对象状态的关系
- 获取指向给定对象的所有解析关系
- 如何管理原始对象之间的数据依赖关系
- 嵌入多对多关系-如果一个新对象还不存在,则添加一个新的对象
- Javascript单元测试依赖关系-当依赖对象发生变化时,如何使测试失败
- 为什么没有将关系添加到模型中的 loopback.io 对象中
- 同一数组(AngularJS)中的javascript对象之间的一对一关系
- 在子对象中创建对父对象的引用是否会导致循环关系
- Parse.com 创建具有关系的对象
- Ember数据-类型错误:对象没有方法'每个关系'
- Parsejs angular/ionic在视图中检索关系对象(第二次打开页面时显示值)
- 将两个对象与第三个对象的关系进行比较
- 解析Javascript-如何通过关系对象进行查询's属性
- 在parse.com上的关系字段中重新查看对象
- Javascript对象关系
- Ember数据-过滤hasMany关系的对象
- Bookshelf js fetch withRelated选项返回空关系对象