简体   繁体   中英

parse server: include pointer in live query in javascript sdk

I am using parse server to live query a class containing rows with pointers. When I use include() in the normal query it get all the data of the pointer but in the live query I only get the objectId

Code:

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')))
})

When I do JSON.stringify(this.conversations[index].get('lastMessage')) it only gives the objectId . I need a way to access the content of the pointer lastMessage

Regards

includeKey() / include() isn't supported in Live Queries:

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.

See related issues to keep track:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM