Reputation: 4962
I am trying to get a row of data from the class, ComparablePhotos in Parse. However, the only row from ComparablePhotos I want to get, is the row whose pointer, column "Parent", has the same objectId (in NewLog) as a string variable I have, markerObjectId, ex: inI9tJ8x7. I would use the simple query in ComparablePhotos where key "Parent" is equal to markerObjectId, but Parent is a pointer, and not a string.
How do I grab the row from ComparablePhotos whos whose pointer, column "Parent", has the same NewLog objectId as a markerObjectId? Something along the lines like if the ComparablePhotos row's Parent.objectId == markerObjectId, store that row into a variable?
ComparablePhotos class in Parse. "Parent" column is a pointer.
NewLogClass. The pointer points here.
Here is my code:
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)
}
Upvotes: 1
Views: 811
Reputation: 119031
Your current code:
var picquery = PFQuery(className:"ComparablePhotos")
picquery.selectKeys(["objectId", "Images", "LocationType", "Parent"])
picquery.includeKey("Parent.objectId")
picquery.orderByAscending("createdAt")
ComparablePhotos
selectKeys
)includeKey
)What you actually want is to get the full object details in the response and to filter by a specified parent. To do that you need to create a PFObject
for the parent object id details you have (see objectWithoutDataWithClassName:objectId:
) and then use whereKey:equalTo:
.
var picquery = PFQuery(className:"ComparablePhotos")
picquery.includeKey("Parent")
picquery.whereKey("Parent", equalTo:parentObject)
picquery.orderByAscending("createdAt")
Upvotes: 2