Hi all! Very new to using Parse, which I am doing via Back4App, and I am having trouble with retrieving data from a row’s Relation column in my SwiftUI app. I hope this hasn’t been discussed elsewhere that I have missed.
I am successfully retrieving the rows from a table named Channel which, in addition to the data I am able to retrieve for each row, such as title, description, image, etc. has a Relation column called ‘stops’ which contains related Stop objects. I cannot for the life of me figure out how to get the Stops associated with each Channel.
This works to get me the data for each Channel:
guard let channelId = parseChannel.objectId,
let channelTitle = parseChannel.title,
let channelDesc = parseChannel.description
else { …
but it falls apart for me here:
if let stopsRelation = parseChannel.stops {
print(" stopsRelation: (stopsRelation)“) gives me “stopsRelation: {”__type”:“Relation”,“className”:“Stop”}" so it seems I am getting to a valid Relation.
do {
// Use find() on the relation query
let relatedParseStops: [ParseStop] = try await stopsRelation.query().find()
seems to be the problem.
I drop through to:
} catch { print(“>>> ERROR fetching related stops for channel ‘(channelTitle)’: (error)”) }
which gives me:
ERROR fetching related stops for channel ‘Test Channel Name’: ParseError code=-1 error=ParseRelation must have the parent set.
Am I doing something obviously stupid here?:
let relatedParseStops: [ParseStop] = try await stopsRelation.query().find()
Or somewhere else?
Any suggestions would be greatly appreciated!
Thanks!