我在解析服务器中有两个类_User
和Organization
,在User
我有关系列organization
类型
"organization": {
"__type": "Relation",
"className": "Organization"
},
我使用swift 3从Users
类查询我的用户,我希望包含(加入)与每个用户相关的所有组织,所以我尝试了
let innerQuery = PFQuery(className: "Organization")
let query = PFQuery(className: "_User")
query.whereKey("organization", matchesQuery: innerQuery)
query.findObjectsInBackground { }
但是这段代码给了我错误
这是查询
{
"limit": "1500",
"where": {
"organization": {
"$inQuery": {
"className": "Organization"
}
}
},
"_method": "GET"
}
和结果。
{
"code": 102,
"error": "improper usage of $inQuery"
}
为什么这不起作用?
答案 0 :(得分:0)
你可以这样试试:
let query = PFQuery(className: "Organization")
query.whereKey("organization", equalTo: PFObject(withoutDataWithClassName:"_User", objectId:PFUser.currentUser()!))
query.findObjectsInBackground { (objects, error)-> Void in