Search code examples
iosquickblox

QuickBlox custom table -- Create relation and getting related records on iOS


How do I create relation between two custom tables with the iOS SDK?

Do I just set the parentID on QBCOCustomObject to create it?

On the REST doc there is a way to get multiple related records, how do I do that with Quickblox iOS sdk?


Solution

  • There is parentID field.

    How it works: for example you have 2 entities: Movies & Comments. Each comment has parentID=movieID. If you will delete this Movie - all Comments will be deleted also.

    To get related records just use extendedRequest param

    NSMutableDictionary *getRequest = [NSMutableDictionary dictionary];
    [getRequest setObject:@"31212412a1269123" forKey:@"_parent_id"];
    
    [QBCustomObjects objectsWithClassName:@"Comment" extendedRequest:getRequest delegate:self];