Documentation/DemoApps/GRDBDemo/README.md
GRDBDemo demonstrates how GRDB can fuel a SwiftUI application.
Note: This demo app is not a project template. Do not copy it as a starting point for your application. Instead, create a new project, choose a GRDB installation method, and use the demo as an inspiration.
The topics covered in this demo are:
Files of interest:
GRDBDemoApp feeds the SwiftUI app with a database, through the SwiftUI environment.
AppDatabase is the type that grants database access. It uses DatabaseMigrator in order to setup the database schema, and provides methods that read and write.
AppDatabase is tested.
This file instantiates various AppDatabase for the various projects needs: one database on disk for the application, and in-memory databases for SwiftUI previews.
Player is a Record type, able to read and write in the database. It conforms to the standard Codable protocol in order to gain all advantages of Codable Records.
PlayerListModel is an @Observable object that observes the database, displays always fresh values on screen, and performs actions.
PlayerListModel is tested.
PlayersNavigationView is the main navigation view of the application. It instantiates a PlayerListModel from the AppDatabase stored in the SwiftUI environment.