Good day
I have 2 classes as follows:
class AnimalModel: Object, ObjectKeyIdentifiable {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted(originProperty: "animals") var group: LinkingObjects<AnimalGroup>
@Persisted var animalId: String = "(randomName())"
@Persisted var ownerId : String = ""}
class AnimalGroup: Object, ObjectKeyIdentifiable {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var animals = RealmSwift.List<AnimalModel>()
@Persisted var ownerId : String
}
When i access a Button to delete an Animal :
Button(action: {
$animalGroup.animals.remove(at: animalIndex)
}) { Image(systemName: "minus") }
This only deletes the linked portion af Animal to the animal Group but not the actual item from the DB.
I am looking for a solution to permanently remove the animal-object from the realm DB
Tried to delete with:
realm.write{
$animalGroup.animal.remove(ID)
}
but that also didnt work