应该知道我的意思吧,比如
User
{
id: 'userId',
name: 'name',
age: 'age'
}
Post
{
userId: 'userId',
title: 'title',
content: 'content'
}
之前用 MongoDB 的时候,查询 Post 直接指定 .populate('userId') 就最终就可以得到
{
userId: {
id: 'userId',
name: 'name',
age: 'age'
},
title: 'title',
content: 'content'
}
但是用了你们的产品后,发现不是很方便了,你们提供了关系相关 API 但是看文档例子我感觉好像不是我理解的样子
一对一关系里,你们把 post 关联到 commend 里,然后并没有说明如何在获取 commend 的时候同时获取到完整的 post 对象内容,只给了个不明不白的例子:
var post = fetchedComment.get('post');
post.fetch({
// 用法可参考 API 文档 > AV.Object > fetch
include: 'author'
}).then(function(post) {
// 成功
var content = post.get('content');
}, function(error) {
// 失败
});
这个例子里,我可以理解为 fetchedComment 是通过某种 query 查到了,然后通过 fetchedComment.get 来获取 post 里的 author 属性?
可否做到获取 fetchedComment 的同时 post 所有需要的属性?就跟 population 机制差不多
谢谢
-
创建时间
16年2月28日
-
最后回复
16年2月29日
-
1
回复
-
968
浏览
-
2
用户