解析服务器:在javascript中的活动查询中包含指针sdk

问题描述:

我正在使用解析服务器来查询包含具有指针的行的类。 当我在正常查询中使用include()它得到的指针的所有数据,但在实况查询我只得到objectId解析服务器:在javascript中的活动查询中包含指针sdk

代码:当我做JSON.stringify(this.conversations[index].get('lastMessage'))它不仅赋予了objectId

var currentUser = Parse.User.current(); 
const Conversation = Parse.Object.extend("conversations"); 

var fromQuery = new Parse.Query(Conversation); 
fromQuery.equalTo("from", currentUser); 

var toQuery = new Parse.Query(Conversation); 
toQuery.equalTo("to", currentUser); 

var mainQuery = Parse.Query.or(fromQuery, toQuery); 
mainQuery.include("to") 
mainQuery.include("from") 
mainQuery.include("lastMessage") 
// FIXME: DEBUG: 
this.convsubscription = mainQuery.subscribe(); 

mainQuery.find().then((conversations) => { 
    for (var i = 0; i < conversations.length; i++){ 
    var object = conversations[i] 
    this.conversations.unshift(object); 
    } 
}) 


this.convsubscription.on('update', (object) => { 
    // we will get the index of updated object  
    var index = this.conversations.findIndex(x => x.id == object.id); 
    console.log(index); 
    // then we will remove the old object and insert the updated one 
    this.conversations.splice(index, 1 ,object) 

    console.log(JSON.stringify(this.conversations[index].get('lastMessage'))) 
}) 

。我需要一种方法来访问指针lastMessage

问候的内容

includeKey()/include()不支持在现场查询:

这是一个服务器端的问题,includeKey被忽略当订阅查询。将对象保存在parse-server上后,决策树会同步处理,因此我们没有机会注入包含。我们需要重构整个服务器端逻辑以支持这些逻辑。

请参阅相关的问题追踪:

+0

所以是有,我可以用它来达到同样的效果的任何方法? –

+0

是的,你需要在访问数据之前获取数据。 – nathan