嵌套查询在iOS sdk中不起作用,但在loopback explorer中工作正常

目前我正在开发一个使用iOS loopback sdk获取值的项目.如果它是一个查询,那么书中的一切都可以正常工作.

但是当嵌套查询(如下所示)发生时,它会显示错误

Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 500" UserInfo={NSLocalizedRecoverySuggestion={"error":{"name":"Error","status":500,"message":"Relation \"relation\" is not defined for UserGroup model","stack":"Error: Relation \"relation\" is not defined for UserGroup model

查询如下

NSDictionary *filterParams = @{
                                   @"where" : @{
                                           @"group_id" : self.groupDetails[@"groupId"]},
                                   @"include" : @[@"invitedusers",
                                                  @{
                                                      @"relation" : @"userstatus",
                                                      @"scope": @{
                                                              @"include":@[ @"useruploads" ]
                                                        }
                                                }]
                                   };

最佳答案

NSDictionary *filterParams = @{
                               @"where" : @{
                                       @"group_id" : self.groupDetails[@"groupId"]
                                       },
                               @"include" : @[ @"invitedusers",
                                               @{
                                                   @"userstatus" : @"useruploads"
                                                   }
                                               ]
                               };

您也可以参考:https://loopback.io/doc/en/lb2/Include-filter.html

点赞