Skip to content

Parse SDK - Includeobject is not working while trying to fetch data from respective class #420

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
aniket453 opened this issue Aug 16, 2020 · 9 comments

Comments

@aniket453
Copy link

Hello,

I am trying to fetch the values from my "Office" class and in my office class "user_id" column is the Pointer to my User class. So i also want to include user object. I am trying following code

QueryBuilder<ParseObject> parseQuery =
QueryBuilder<ParseObject>(ParseObject("Language"));
parseQuery.includeObject(['user_id']);

ParseResponse parseResponse = await parseQuery.query();

Output i am getting is :

[{"className":" Language ","objectId":"w3U0iHfhkh","createdAt":"2020-08-16T10:23:15.961Z","updatedAt":"2020-08-16T10:23:15.961Z","name":"Lang2199","address":"Address1521","user_id":{"__type":"Pointer","className":"_User","objectId":"zbhsxhpr9x"}}]

Update this thread if anyone finds a solution.

Thanks.

@RodrigoSMarques
Copy link
Contributor

@aniket453
Which version of the plugin are you using?

This works correctly in version 1.0.26

@aniket453
Copy link
Author

@RodrigoSMarques i am using "parse_server_sdk: ^1.0.26" latest version of parse sdk.

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Aug 17, 2020

@aniket453
I am using version 1.0.26. my log.

    final QueryBuilder queryBuilder =
        QueryBuilder<ParseObject>(ParseObject(keyFavoritesTable));
    //Two Pointers: Favorites to Ad (column ad) e Ad to _User (column onwer)
    queryBuilder.includeObject(['ad', 'ad.owner']);

Query generated by Parse:

https://xxx.herokuapp.com/parse/classes/Favorites?where={"owner": "pYXeOSGNlF"}&include=ad,ad.owner&limit=1000

Result:

Payload: [{"className":"Favorites","objectId":"LmR5t9sBQp","createdAt":"2019-07-28T03:54:22.091Z","updatedAt":"2019-07-28T03:54:22.091Z","owner":"pYXeOSGNlF","ad":{"__type":"Pointer","className":"Ad","objectId":"DAP3lcVZRR"},"ACL":{"pYXeOSGNlF":{"read":true,"write":true}}}, {"className":"Favorites","objectId":"TdLzMRtN7R","createdAt":"2020-08-04T00:54:36.271Z","updatedAt":"2020-08-04T00:54:36.271Z","owner":"pYXeOSGNlF","ad":{"__type":"Pointer","className":"Ad","objectId":"pUUFsYYlkS"},"ACL":{"pYXeOSGNlF":{"read":true,"write":true}}}]

But the payload doesn't seem to be displaying correctly.

See the analysis in the debug:

Captura de Tela 2020-08-17 às 08 52 41
Captura de Tela 2020-08-17 às 09 00 21

@MungaraJay
Copy link

Hello @RodrigoSMarques I have checked your answer.

Your payload is like,
Payload: [{"className":"Favorites","objectId":"LmR5t9sBQp","createdAt":"2019-07-28T03:54:22.091Z","updatedAt":"2019-07-28T03:54:22.091Z","owner":"pYXeOSGNlF","ad":{"__type":"Pointer","className":"Ad","objectId":"DAP3lcVZRR"},"ACL":{"pYXeOSGNlF":{"read":true,"write":true}}}, {"className":"Favorites","objectId":"TdLzMRtN7R","createdAt":"2020-08-04T00:54:36.271Z","updatedAt":"2020-08-04T00:54:36.271Z","owner":"pYXeOSGNlF","ad":{"__type":"Pointer","className":"Ad","objectId":"pUUFsYYlkS"},"ACL":{"pYXeOSGNlF":{"read":true,"write":true}}}]

But, can you try adding a new column in your ad pointer and when you will try to fetch those columns it's not going to return it anyway.

I am also getting similar kind of values. But, i am not getting all the columns. I think following three are different columns. You are also going to get those values without even using includeObject method.
"ad":{"__type":"Pointer","className":"Ad","objectId":"pUUFsYYlkS"}

But, i want all the column and properties of my class.

So can you please try this?

Thanks.

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Aug 17, 2020

@MungaraJay
Did you check the print I sent?
The payload does not display the include objects, but they are in the response structure of ParseResponse.

Examine the ParseResponse result in the debug

@MungaraJay
Copy link

@RodrigoSMarques How to map it using dart code if you are getting values?

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Aug 17, 2020

@MungaraJay, try:

    if (parseResponse.success && parseResponse.results != null) {
     parseResponse.results.map((f) {
          print(f);
           final ad = f.get<ParseObject>('ad');
           print(ad);
          final user = ad.get<ParseUser>('owner');
          print(user);
      });

@fischerscode
Copy link
Contributor

fischerscode commented Oct 15, 2020

Are we safe to close?

@MungaraJay
Copy link

You can close this one.

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

4 participants