我正在尝试从Parse中的ComparablePhotos类中获取一行数据。但是,我想从ComparablePhotos中获得的唯一一行是其指针列“Parent”具有与我拥有的字符串变量markerObjectId(例如inI9tJ8x7)相同的objectId(在NewLog中)的行。我将在ComparablePhotos中使用简单的查询,其中键“Parent”等于markerObjectId,但是Parent是一个指针,而不是字符串。如何从ComparablePhotos whos中获取行,其指针的列“Parent”具有与markerObjectId相同的NewLog objectId?类似于如果ComparablePhotos行的Parent.objectId == markerObjectId,将该行存储到变量中?
解析中的ComparablePhotos类。 “父”列是一个指针。
NewLogClass。指针指向此处。
这是我的代码:
var newLogObjectsArray: [PFObject] = [PFObject]()
//newLogObjectId is a string im comparing to, ex: inI9tJ8x7
newLogObjectId = objectIdArray[markerIndex]
var picquery = PFQuery(className:"ComparablePhotos")
picquery.selectKeys(["objectId", "Images", "LocationType", "Parent"])
picquery.includeKey("Parent.objectId")
picquery.orderByAscending("createdAt")
picquery.findObjectsInBackgroundWithBlock { (NewLog, error) -> Void in
//Here prints are all our rows from the class, ComparablePhotos.
println("NewLog")
if let NewLog = NewLog as? [PFObject] {
for log in NewLog {
//Here are all our rows from the class, NewLog.
var ParseNewLogClass: PFObject = (log["Parent"] as? PFObject)!
self.newLogObjectsArray.append(ParseNewLogClass)
}
最佳答案
您当前的代码:
var picquery = PFQuery(className:"ComparablePhotos")
picquery.selectKeys(["objectId", "Images", "LocationType", "Parent"])
picquery.includeKey("Parent.objectId")
picquery.orderByAscending("createdAt")
ComparablePhotos
创建一个查询selectKeys
)includeKey
)您真正想要的是在响应中获取完整的对象详细信息,并按指定的父对象进行过滤。为此,您需要为您拥有的父对象ID详细信息创建一个
PFObject
(请参阅objectWithoutDataWithClassName:objectId:
),然后使用whereKey:equalTo:
。var picquery = PFQuery(className:"ComparablePhotos")
picquery.includeKey("Parent")
picquery.whereKey("Parent", equalTo:parentObject)
picquery.orderByAscending("createdAt")