iosparse-platformpfrelation

Count number of objects in PFRelation


I have a custom Parse class that represents an event. The event has 3 PFRelation columns that represent users that have been invited to the event, users that have accepted the event and users that have declined the event.

Is there any way to count the total number of people in each PFRelation without querying the class again?


Solution

  • You would need to query each relation to get the count (which you can do without pulling all of the objects back and counting them).

    A better idea is to use cloud code, either to update a variable whenever a relationship is changed (a save hook) to store the count or so that you can query all of the counts for one object in a single request.