Fails with "to-many key not allowed here"
// parent.children?.contains(where: { $0.name == "Abbiejean" // }) != nil
parent.children.flatMap { children in
children.contains(where: { $0.name == "Abbijean" })
} == true
How are we supposed to query on relationships? This is a huge problem. This is a major limitation blocking migration of CoreData to SwiftData. We can do this with NSPredicate:
let moodAnalysis = NSPredicate(format: "ANY moodAnalysis.labels.title == %@", label.description)
let stateOfMinds = NSPredicate(format: "SUBQUERY(stateOfMinds, $x, SUBQUERY($x.labels, $y, $y.title == %@).@count > 0).@count > 0", label.description)
Swift Predicates are supposed to support idiomatic optionals, but we can't query on optional arrays?
As in you can not use SwiftData to filter on relationships when the container is backed by CloudKit...
How can I achieve this?