mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Documentation
This commit is contained in:
1 parent
91c17aca41
commit
2862edcea8
4 files changed
+22
-6
No files matched your search
@@ -6,14 +6,16 @@ import GRDB
|
||||
/// It applies the pratices recommended at
|
||||
/// https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md
|
||||
struct AppDatabase {
|
||||
/// Creates an `AppDatabase` from a database connection,
|
||||
/// and make sure the database schema is ready.
|
||||
/// Creates an `AppDatabase`, and make sure the database schema is ready.
|
||||
init(_ dbWriter: DatabaseWriter) throws {
|
||||
self.dbWriter = dbWriter
|
||||
try migrator.migrate(dbWriter)
|
||||
}
|
||||
|
||||
/// The database connection
|
||||
/// Provides access to the database. Application can use a `DatabasePool`,
|
||||
/// and tests can use a fast in-memory `DatabaseQueue`.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
|
||||
private let dbWriter: DatabaseWriter
|
||||
|
||||
/// The DatabaseMigrator that defines the database schema.
|
||||
|
||||
@@ -40,3 +40,9 @@ The topics covered in this demo are:
|
||||
- [PlayerForm.swift](GRDBCombineDemo/Views/PlayerForm.swift), [PlayerEditionView.swift](GRDBCombineDemo/Views/PlayerEditionView.swift), [PlayerCreationSheet.swift](GRDBCombineDemo/Views/PlayerCreationSheet.swift) and [PlayerFormViewModel.swift](GRDBCombineDemo/ViewModels/PlayerFormViewModel.swift).
|
||||
|
||||
`PlayerForm` is the SwiftUI view that displays a Player editing form. It is embedded in `PlayerEditionView` and `PlayerCreationSheet`, two SwiftUI views that edit or create a player. All those views are fed by `PlayerFormViewModel`.
|
||||
|
||||
- [GRDBCombineDemoTests](GRDBCombineDemoTests)
|
||||
|
||||
- Test the database schema
|
||||
- Test the `Player` record and its requests
|
||||
- Test the `AppDatabase` methods that let the app access the application.
|
||||
@@ -5,14 +5,16 @@ import GRDB
|
||||
/// It applies the pratices recommended at
|
||||
/// https://github.com/groue/GRDB.swift/blob/master/Documentation/GoodPracticesForDesigningRecordTypes.md
|
||||
final class AppDatabase {
|
||||
/// Creates an `AppDatabase` from a database connection,
|
||||
/// and make sure the database schema is ready.
|
||||
/// Creates an `AppDatabase`, and make sure the database schema is ready.
|
||||
init(_ dbWriter: DatabaseWriter) throws {
|
||||
self.dbWriter = dbWriter
|
||||
try migrator.migrate(dbWriter)
|
||||
}
|
||||
|
||||
/// The database connection
|
||||
/// Provides access to the database. Application can use a `DatabasePool`,
|
||||
/// and tests can use a fast in-memory `DatabaseQueue`.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/blob/master/README.md#database-connections
|
||||
private let dbWriter: DatabaseWriter
|
||||
|
||||
/// The DatabaseMigrator that defines the database schema.
|
||||
|
||||
@@ -35,3 +35,9 @@ The topics covered in this demo are:
|
||||
- [PlayerEditionViewController.swift](GRDBDemoiOS/ViewControllers/PlayerEditionViewController.swift)
|
||||
|
||||
`PlayerEditionViewController` can create or edit a player, and save it in the database.
|
||||
|
||||
- [GRDBDemoiOSTests](GRDBDemoiOSTests)
|
||||
|
||||
- Test the database schema
|
||||
- Test the `Player` record and its requests
|
||||
- Test the `AppDatabase` methods that let the app access the application.
|
||||
Reference in new issue
Block a user