Querying with @Query
Fetch and sort persisted data in views.
Fetching Saved Data
To show stored records in a view, you fetch them with @Query. It reads from your container and keeps the view fresh. 🔍
The @Query Property
Declare an array property with @Query and SwiftData fills it with every matching record. No manual loading needed.
@Query private var tasks: [Task]All lessons in this course
- Defining @Model Types
- The Model Container & Context
- Querying with @Query
- Inserting, Updating & Deleting