Skip to content

IncludeObject not working with liveQuery #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MungaraJay opened this issue Aug 27, 2020 · 4 comments
Closed

IncludeObject not working with liveQuery #424

MungaraJay opened this issue Aug 27, 2020 · 4 comments

Comments

@MungaraJay
Copy link

MungaraJay commented Aug 27, 2020

Hello,

I was trying out includeObject method with my livequery in one of my project. Also, I am using flutter parse_server_sdk latest version 1.0.26.

What i want is i have a list of events. So whenever a new event is added in my database then it should trigger the subscription method. I have used following code and it works as well. But, only thing i have issue with is i don't get the includedobject i have added in QueryBuilder.

QueryBuilder<ParseObject> parseQuery =
        QueryBuilder<ParseObject>(ParseObject(tblEvents))
          ..whereEqualTo(tblEventUserId, currentUser);
    parseQuery.includeObject([tblOrganizerId]);

    Subscription subscription = await liveQuery.client.subscribe(parseQuery);
    subscription.on(LiveQueryEvent.create, (value) {
      print("val : ${value}");
      print("val : ${value.runtimeType}");
    });

Output :

val : {"className":"Group_Events","objectId":"uotQ6BpT4C","createdAt":"2020-08-27T07:18:26.581Z","updatedAt":"2020-08-27T07:18:26.581Z","organizer_id":{"__type":"Pointer","className":"Organizer","objectId":"t9M1oyZHh4"},"user_id":{"__type":"Pointer","className":"_User","objectId":"Hx5xJ5ABxG"},"weight":1}
I/flutter (30335): val : ParseObject

I have also evaluated the expression. But, there is only limited pointer data to "tblOrganizerId". I am not getting whole data of that table.

So how can i achieve that?

Thanks.

@fischerscode
Copy link
Contributor

fischerscode commented Aug 27, 2020

Due to server limitations, LiveQuery does not support includes.

As you want to show the user a list, you might want to have a look at the ParseLiveListWidget.
(Use 1.0.27 (currently only on github) for a ParseLiveList related bugfix)

In case you want to use LiveQuery, you have to fetch the extra data manually.

Edit: The "due to server limitations" comment is based on this issue.

@prakash-indorkar
Copy link

Any update on IncludeObject with liveQuery please?

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Jan 11, 2021

@prakash-indorkar
use LiveQuery Triggers em Cloud Code https://docs.parseplatform.org/cloudcode/guide/#livequery-triggers

By default, ParseLiveQuery does not perform queries that require additional database operations. 
This is to keep your Parse Server as fast and effient as possible. If you require this functionality, 
you can perform these in afterLiveQueryEvent

Example:

Parse.Cloud.afterLiveQueryEvent('Order', async (request) => {
  const object = request.object;
  const user = object.get("user"); //pointer to _User
  await user.fetch();
});

@RodrigoSMarques
Copy link
Contributor

Use LiveQuery Triggers em Cloud Code https://docs.parseplatform.org/cloudcode/guide/#livequery-triggers

Closed. No activity in the last 15 days.
If necessary open again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants