RowAdapter
RowAdapter
is a protocol that helps two incompatible row interfaces
working together.
GRDB ships with four concrete types that adopt the RowAdapter protocol:
ColumnMapping
: renames row columnsEmptyRowAdapter
: hides all columnsRangeRowAdapter
: exposes a range of columnsRenameColumnAdapter
: transforms column names with a functionScopeAdapter
: defines row scopesSuffixRowAdapter
: hides the first columns of a row
To use a row adapter, provide it to any method that fetches:
let adapter = SuffixRowAdapter(fromIndex: 2)
let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
// [baz:3]
try Row.fetchOne(db, sql: sql, adapter: adapter)
-
addingScopes(_:
Extension method) Returns an adapter based on self, with added scopes.
If self already defines scopes, the added scopes replace eventual existing scopes with the same name.