简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM