parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Live query with include won't work

Open avielfedida opened this issue 9 years ago • 13 comments

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.

avielfedida avatar May 01 '16 22:05 avielfedida

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.

chadpav avatar May 03 '16 19:05 chadpav

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)?

avielfedida avatar May 03 '16 20:05 avielfedida

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.

chadpav avatar May 05 '16 16:05 chadpav

Hi to all! Any update or support about include in LiveQuery?

ronaldgalangy avatar May 26 '17 12:05 ronaldgalangy

Any news about that?

johncodeos avatar Jan 22 '19 22:01 johncodeos

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 avatar Jan 23 '19 00:01 dplewis

@dplewis I chose to go with @chadpav's method. Thanks.

johncodeos avatar Jan 23 '19 00:01 johncodeos

I clearly see that there is interest in this topic. Is there a particular reason this won't work? Is it possible to fix this?

vdkdamian avatar Jan 06 '23 05:01 vdkdamian

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

This seems like a bit of random limitation that should not be there. Are there any plans to address this issue?

DarekDev avatar Jul 06 '23 06:07 DarekDev

Does anyone want to open a PR?

mtrezza avatar Jul 06 '23 15:07 mtrezza

Do we know what the status on this issue is or what the root cause entails?

ssmagsk avatar Jul 10 '25 21:07 ssmagsk

Looks like you can use CloudCode, see here: https://community.parseplatform.org/t/parse-live-query-include/3175/3?u=cbaker6

dplewis avatar Jul 10 '25 21:07 dplewis