I have a table, one of the table fields points to the users table, here is my code:
var subscription = (new Parse.Query('Queue')).include('requestingUser').subscribe();
subscription.on('create', function(queueObject) {
queueObject.get('requestingUser') // user object
queueObject.get('requestingUser').get('name') // undefined
})
Within the parse server index.js I set:
liveQuery: {
classNames: ["_User", "User", "Queue"] // Just in case I did try "_User" and "User"
}
I also tried another table, other than users table, doesn't work either.
This is the response(if it helps):
HTTP/1.1 201 Created
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type
Location: http://localhost:1337/parse/classes/Queue/cFwSWuzUXx
Content-Type: application/json; charset=utf-8
Content-Length: 64
Date: Sun, 01 May 2016 22:04:16 GMT
Connection: keep-alive
Honestly, I'm not sure if it's a bug but I was trying to find out if it's even possibly to use include with live query and didn't find anything like that in the docs, but the docs suggest that subscribe is just instead of find for example so I don't think include should be a problem and it is.
My understanding is that 'include' is not supported in LiveQuery yet. You will get back to the pointer information and can perform a fetch there or implement some local caching so you don't have to call the server to resolve those related records.
Currently I just use the pointer id the get the user I'm looking for via another query, so I didn't understand you perfectly, should I be able to use include or its not implemented yet(with LiveQuery)?
It's not implemented using Live Query. The way you are doing it is correct.
My last comment was just a suggestion that you keep user records in a local cache so you don't always have to immediately fetch from the server every time.
Hi to all! Any update or support about include in LiveQuery?
Any news about that?
As @chadpav mentioned fetch the pointers or store them in local cache.
Since LDS (LocalDataStore) has been added you could use that for include.
@JEKos feel free to do a PR.
@dplewis I chose to go with @chadpav's method. Thanks.
Most helpful comment
Hi to all! Any update or support about
includein LiveQuery?