Relative Content

Tag Archive for swiftdataswift-data-relationship

SwiftData Cascade delete results in N+1 queries?

I have a very simple one-to-many relationship between two models where a Trail has many Coordinates. This relationship is configured with cascading deletes. However, when I delete a single Trail, I get N+1 delete queries.

Complex model relation in SwiftData

I’m having trouble solving the following problem. I want to create a workout app where the user can see their workout history and exercise progress. To achieve this, I’m using SwiftData to model the relationship between workouts and exercises in such a way that: