79395857

Date: 2025-01-29 06:23:35
Score: 2
Natty:
Report link

The solution (thanks to Chris Parker) was to add var id = UUID() to the model definition so the final result would look something like:

@Model
final class Character {
    var id = UUID()
    var name: String
    var production: Production?
    var myCharacter: Bool
    
    init(name: String, production: Production?, myCharacter: Bool = false) {
        self.name = name
        self.production = production
        self.myCharacter = myCharacter
    }
}

@Model
final class Production {
    var id = UUID()
    var name: String

    @Relationship(deleteRule: .cascade, inverse: \Act.production) var acts: [Act] = []
    
    init(name: String) {
        self.name = name
    }
}
Reasons:
  • Blacklisted phrase (0.5): thanks
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: The-Wolf