I am trying to use SwiftData to perform a Query based on the name of the actor, which is inside a movie model. Here is the Movie model. @Model final class Movie {
var title: String
var year: Int
@Relationship(.noAction, inverse: \Actor.movies)
var actors: [Actor] = []
init(title: String, year: Int) {
self.title = title
self.year = year
}
} Here is my actual Query:
_movies = Query(filter: #Predicate { $0.actors.contains(where: { $0.name.contains(actorName) }) })
But it returns nothing, even though I am passing actorName which exists in the movie.