Swift & Parse: 列 Class 等于用户 Class 中的列的查询结果
Swift & Parse: Query Results Where Column Class Is Equal To A Column In Users Class
我已经广泛搜索了这个问题的答案。在书面英语中,我正在尝试执行以下操作:
查询结果"Issues"class中的"WorkGroup"列等于"Users"class中的"WorkGroup"列。
我尝试了无数种方法,包括; NotContainedIn、ObjectForKey、wherekey(matchesquery)、includeKey、添加指针等
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.
试试这个
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!{
}
}
})
}
}
})
}
仔细检查括号
let userQuery = PFUser.query();
// Set up user query
let issueQuery = PFQuery(className:"Issue");
issueQuery.whereKey("WorkGroup", matchesKey:"WorkGroup", inQuery:userQuery);
我已经广泛搜索了这个问题的答案。在书面英语中,我正在尝试执行以下操作:
查询结果"Issues"class中的"WorkGroup"列等于"Users"class中的"WorkGroup"列。
我尝试了无数种方法,包括; NotContainedIn、ObjectForKey、wherekey(matchesquery)、includeKey、添加指针等
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.
试试这个
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!{
}
}
})
}
}
})
}
仔细检查括号
let userQuery = PFUser.query();
// Set up user query
let issueQuery = PFQuery(className:"Issue");
issueQuery.whereKey("WorkGroup", matchesKey:"WorkGroup", inQuery:userQuery);