Swift&Parse:查询结果,其中列类等于用户类中的列

问题描述 投票:0回答:2

我已经广泛搜索了这个答案。用书面英语我试着做以下事情:

查询结果,其中“Issues”类中的“WorkGroup”列等于“Users”类中的“WorkGroup”列。

我尝试了无数的事情,包括; NotContainedIn,ObjectForKey,wherekey(matchesquery),includeKey,add pointers等。

let query = PFQuery(className: ISSUES_CLASS_NAME)
let now = Date()

query.whereKey(ISSUES_SUB_DATE, lessThanOrEqualTo: now)
query.whereKey(ISSUES_STATUS, notEqualTo: "Closed")
query.order(byDescending: ISSUES_SUB_DATE)

// Add Where Issues WorkGroup value = Users WorkGroup value.
swift parse-platform pfquery
2个回答
1
投票
let userQuery = PFUser.query();
// Set up user query
let issueQuery = PFQuery(className:"Issue");
issueQuery.whereKey("WorkGroup", matchesKey:"WorkGroup", inQuery:userQuery);

http://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFQuery.html#/c:objc(cs)PFQuery(im)whereKey:matchesKey:inQuery


0
投票

试试这个

func yes(){
    let query = PFUser.query()
    query?.findObjectsInBackground(block: { (objects: [PFObject]?, error: Error?) in
        if error == nil{
            for object in objects!{
                self.array.insert(object.object(forKey: WorkGroup) as! String, at: 0)
                let dataQuery = PFQuery(className: "Issues")
                dataQuery.whereKey(WorkGroup, containedIn: self.array)
                dataQuery.findObjectsInBackground(block: { (objects: [PFObject]?, error: Error?) in
                    if error == nil{
                        for object in objects!{
                        }
                    }
                })
            }
        }
    })
}

仔细检查括号

© www.soinside.com 2019 - 2024. All rights reserved.