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

parse server: include pointer in live query in javascript sdk

我正在使用解析服务器实时查询 class 包含带指针的行。 当我在正常查询中使用 include() 时,它会获取指针的所有数据,但在实时查询中我只获取 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')))
})

当我执行 JSON.stringify(this.conversations[index].get('lastMessage')) 时,它只给出 objectId。我需要一种方法来访问指针 lastMessage

的内容

此致

includeKey()/include() 在实时查询中不受支持:

this is a server side issue, the includeKey is ignored when subscribing to the query. The decision tree is processed synchronously after an object is saved on parse-server, therefore we don't have the opportunity to inject inclusions. We'd need to refactor the whole serverside logic in order to support those.

查看相关问题以进行跟踪: