my question is how to filter in search text for city.name in Concert ? i tried to reach city name using nested compact map but couldn't handle it.
class Concert {
var kindOf : String
var city : [City]
}
class City {
var name : String
@Relationship(inverse: \Concert.city) var concert : [Concert]
}
@Query var concerts : [Concert]
@State var searchQuery : String = ""
var filteredConcert : [Concert] {
if searchQuery.isEmpty {
return concerts
}
let filteredConcerts = concerts.compactMap { concert in
let kindOfContainsSearch = concert.kindOf.range(of: searchQuery) != nil
return (kindOfContainsSearch ) ? concert : nil
}
return filteredConcerts
}