iosswiftmbaassyncano

iOS: Modeling Friends List with Syncano DB


I'm trying to get a handle on how to use custom Swift classes to model my Syncano backend. I have classes MPUser and MPUserProfile exactly as described in this guide. However, instead of adding an avatar field, I'd like to add a friends list. Should this property be:

Edit: their page on classes makes it sounds like I would want an array of type Reference (referring to users' IDs) but their arrays can only have string/int/boolean/float. I'm now wondering if an array of (non-Reference) integers will work fine.

Thank you for your help.


Solution

  • Currently Syncano doesn't support holding arrays of references. It's something we are working on (adding many-to-many relationships), but in the meantime you should could safely just use array type and store ID of referenced objects in there.

    When you store array of IDs, you can use either ID of a user, or ID of a user profile.

    The connection between them is as follows: User is a physical user that logs into your app. His profile is an object that belongs to him. User A cannot be accessed by user B, but profile of user A can be accessed by user B.

    You can get a profile of user A either by using profile ID (object id from user_profile class), or by using user A id (owner field in object inside user_profile class).

    Depending on which route you take, you can then ask Syncano for list of all friends doing either:

    User Id and his profile