How do you create an inverse relationship to the same model in SwiftData

I have a Person model that needs to have a relationships with other instances of Person objects. CloudKit requires an inverse relationship be setup but I don't know how to configure it.

You need to add another property that can be used for the inverse relationship. You don't have to use this property, it's just to satisfy SwiftData's relationship requirements.

For example:

@Model final class Person {
    var name = ""

    @Relationship(inverse: \Person.parent) var children: [Person]?
    @Relationship var parent: Person? // can make private if not using elsewhere
}
How do you create an inverse relationship to the same model in SwiftData
 
 
Q