I’m developing a social media app using CloudKit and I’m trying to determine the best way to store approved follow requests. My goals are to minimize fetches while allowing for flexibility and scalability. When a user approves a follow request, I have three options for storing the data:
Option 1: Add userID to “following” string list on the user’s profile record
- Pros:
Get all the user’s following IDs when their profile record is loaded. - Cons: Could become a very large list over time, potentially impacting performance.
Option 2: Fetch all follow request records where creatorID == the user & status == approved
-
Pros: More suitable for scalability and large followings. Supports cursor/paging for better data handling.
-
Cons: Would require fetching many CKRecords just to identify the user’s followings, which might impact performance.
Option 3: Store the user’s ID on a string list on the OTHER user’s profile record
-
Pros: Can query and retrieve following records where the “followers” list contains the user ID.
-
Cons: Similar to Option 1, the list could become very large and impact performance.
Given these options, which approach would be the most efficient for minimizing fetches while maintaining flexibility and scalability?
Are there any alternative methods or best practices in CloudKit for handling such scenarios?
5