DatabaseRegionConvertible
A type that operates on a specific DatabaseRegion
.
protocol DatabaseRegionConvertible : Sendable
Browse conforming typesA DatabaseRegionConvertible
instance feeds database observation tools such as DatabaseRegionObservation
and ValueObservation
:
// An observation triggered by all changes to the database
DatabaseRegionObservation(tracking: .fullDatabase)
// An observation triggered by all changes to the 'player' table
DatabaseRegionObservation(tracking: Table("player"))
// An observation triggered by all changes to the row
// with rowid 1 in the 'player' table
DatabaseRegionObservation(tracking: Player.filter(id: 1))
// An observation triggered by all changes to the 'score' column
// of the 'player' table
DatabaseRegionObservation(tracking: SQLRequest("SELECT score FROM player"))
Specifying a region from a FetchRequest
does not execute the request. In the above example, Player.filter(id: 1)
and SELECT score FROM player
are only compiled by SQLite, so that GRDB can understand the tables, rows, and columns that constitute the database region.
Creating a DatabaseRegion
static var fullDatabase: Self
The region that covers the full database: all columns and all rows from all tables.
func databaseRegion(Database
) throws -> DatabaseRegion Returns a database region.
Supporting Types
struct AnyDatabaseRegionConvertible
A type-erased DatabaseRegionConvertible