1

I am developing a Task Management app in flutter and I am using Parse SDK for the backend.

How to fetch data of pointer/ relation columns in a query?

My setup:

I have 4 Classes

  1. User: this is parse user with the username, email, and password

  2. Categories: columns--> cat_name ( name of this category)

  3. Task: below are the columns- task_name ( name of this task ) and task_cat (this is a pointer to Category class)

  4. Activities: Below are the columns: userID ( a pointer to User class ) taskId: ( a pointer to Task Class ) startTime ( DateTime ) endTime ( DateTime) activityNotes ( String ) activityDuration( Number)

I am running the following code:

await ParseObject('Activities').getAll();

And I am getting the following response:

[{"className":"Activities","objectId":"F7TviWDd1H","createdAt":"2021-02-17T07:21:33.723Z","updatedAt":"2021-02-18T08:59:51.649Z","startTime":{"__type":"Date","iso":"2021-02-17T06:21:00.000Z"},"endTime":{"__type":"Date","iso":"2021-02-17T07:21:00.000Z"},"userID":{"__type":"Pointer","className":"_User","objectId":"1tHoCAv1QW"},"taskID":{"__type":"Pointer","className":"Tasks","objectId":"MFC2oMP2wL"},"activityNotes":"This is a Test Activity","activityDuration":11234000,"ACL":{"":{"read":true}}}, {"className":"Activities","objectId":"5dNxryEGdi","createdAt":"2021-02-17T08:50:58.480Z","updatedAt":"2021-02-18T08:59:58.736Z","startTime":{"__type":"Date","iso":"2021-02-17T04:50:00.000Z"},"endTime":{"__type":"Date","iso":"2021-02-17T06:50:00.000Z"},"userID":{"__type":"Pointer","className":"_User","objectId":"1tHoCAv1QW"},"taskID":{"__type":"Pointer","className":"Tasks","objectId":"rghVxYA6BX"},"activityNotes":"This is another test activity","activityDuration":33456000,"ACL":{"":{"read":true}}} ]

My query:

How can I get the username, task_name, and cat_name associated with an activity in a single query??

  • 1
    Have you tried the `includeObject` function? – Davi Macêdo Feb 24 '21 at 19:56
  • Yes, I did try the code: **QueryBuilder queryActivities = QueryBuilder(ParseObject('Activities')) ..includeObject(['Tasks']); ** the response is still same – kamran alam Feb 25 '21 at 08:48
  • What are the CLP/ACLs that you have in place for the classes/objects that you want to include? – Davi Macêdo Feb 25 '21 at 17:49
  • ACL and CLP on classes User and Tasks are "read: public" & "write: authenticated" – kamran alam Feb 25 '21 at 17:53
  • 1
    One more thing. It should be actually `QueryBuilder queryActivities = QueryBuilder(ParseObject('Activities')) ..includeObject(['taskID']);` Could you please try with that? – Davi Macêdo Feb 26 '21 at 19:22
  • Tried QueryBuilder queryActivities = QueryBuilder(ParseObject('Activities')) ..includeObject(['taskID']); But the response is same: {"className":"Activities","objectId":"F7TviWDd1H","createdAt":"2021-02-17T07:21:33.723Z","updatedAt":"2021-02-18T08:59:51.649Z","userID":{"__type":"Pointer","className":"_User","objectId":"1tHoCAv1QW"},"taskID":{"__type":"Pointer","className":"Tasks","objectId":"MFC2oMP2wL"}, – kamran alam Mar 07 '21 at 05:28
  • 1
    Could you please double check if MFC2oMP2wL really exists in Tasks class? – Davi Macêdo Mar 07 '21 at 23:09
  • Yes, it exists. – kamran alam Mar 08 '21 at 11:14

0 Answers0