PrefetchedRowsView
A view on the prefetched associated rows.
struct PrefetchedRowsView
See prefetchedRows
for more information.
A view on the prefetched associated rows.
struct PrefetchedRowsView
See prefetchedRows
for more information.
import GRDB
A toolkit for SQLite databases, with a focus on application development
final class Row
A database row.
var prefetchedRows: Row.PrefetchedRowsView { get }
A view on the prefetched associated rows.
var scopes: ScopesView { get }
A view on the scopes defined by row adapters.
var scopesTree: ScopesTreeView { get }
A view on the scopes tree defined by row adapters.
var unadapted: Row { get }
The raw row fetched from the database.
var unscoped: Row { get }
The row, without any scope of prefetched rows.
subscript<Record>(scope: String) -> Record? where Record : FetchableRecord { get }
The eventual record associated to the given scope.
subscript<Record>(scope: String) -> Record where Record : FetchableRecord { get }
The record associated to the given scope.
subscript<Records>(key: String) -> Records where Records : RangeReplaceableCollection, Records.Element : FetchableRecord { get }
A collection of prefetched records associated to the given association key.
subscript<Record>(key: String) -> Set<Record> where Record : FetchableRecord, Record : Hashable { get }
A set prefetched records associated to the given association key.
struct ScopesTreeView
A view on the scopes tree defined by row adapters.
struct ScopesView
A view on the scopes defined by row adapters.
convenience init()
Creates an empty row.
convenience init(_ dictionary: [String : (any DatabaseValueConvertible)?])
Creates a row from a dictionary of database values.
convenience init?(_ dictionary: [AnyHashable : Any])
Creates a row from a dictionary.
convenience init(dictionaryLiteral elements: (String, (any DatabaseValueConvertible)?)...)
Creates a row initialized with elements. Column order is preserved, and duplicated columns names are allowed.
static func fetchAll(_ db: Database, _ request: some FetchRequest) throws -> [Row]
Returns an array of rows fetched from a fetch request.
static func fetchAll(_ statement: Statement, arguments: StatementArguments? = nil, adapter: (any RowAdapter)? = nil) throws -> [Row]
Returns an array of rows fetched from a prepared statement.
static func fetchAll(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: (any RowAdapter)? = nil) throws -> [Row]
Returns an array of rows fetched from an SQL query.
static func fetchCursor(_ db: Database, _ request: some FetchRequest) throws -> RowCursor
Returns a cursor over rows fetched from a fetch request.
static func fetchCursor(_ statement: Statement, arguments: StatementArguments? = nil, adapter: (any RowAdapter)? = nil) throws -> RowCursor
Returns a cursor over rows fetched from a prepared statement.
static func fetchCursor(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: (any RowAdapter)? = nil) throws -> RowCursor
Returns a cursor over rows fetched from an SQL query.
static func fetchOne(_ db: Database, _ request: some FetchRequest) throws -> Row?
Returns a single row fetched from a fetch request.
static func fetchOne(_ statement: Statement, arguments: StatementArguments? = nil, adapter: (any RowAdapter)? = nil) throws -> Row?
Returns a single row fetched from a prepared statement.
static func fetchOne(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: (any RowAdapter)? = nil) throws -> Row?
Returns a single row fetched from an SQL query.
static func fetchSet(_ db: Database, _ request: some FetchRequest) throws -> Set<Row>
Returns a set of rows fetched from a fetch request.
static func fetchSet(_ statement: Statement, arguments: StatementArguments? = nil, adapter: (any RowAdapter)? = nil) throws -> Set<Row>
Returns a set of rows fetched from a prepared statement.
static func fetchSet(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: (any RowAdapter)? = nil) throws -> Set<Row>
Returns a set of rows fetched from an SQL query.
var columnNames: LazyMapCollection<Row, String> { get }
The names of columns in the row, from left to right.
var containsNonNullValue: Bool { get }
Returns a boolean value indicating if the row contains one value this is not NULL
.
let count: Int
The number of columns in the row.
var databaseValues: LazyMapCollection<Row, DatabaseValue> { get }
The database values in the row, from left to right.
var debugDescription: String { get }
var description: String { get }
var endIndex: Index { get }
var startIndex: Index { get }
subscript(columnName: String) -> (any DatabaseValueConvertible)? { get }
Returns Int64
, Double
, String
, Data
or nil, depending on the value stored at the given column.
subscript(index: Int) -> (any DatabaseValueConvertible)? { get }
Returns Int64
, Double
, String
, Data
or nil, depending on the value stored at the given index.
subscript(column: some ColumnExpression) -> (any DatabaseValueConvertible)? { get }
Returns Int64
, Double
, String
, Data
or nil, depending on the value stored at the given column.
subscript(position: Index) -> (String, DatabaseValue) { get }
Returns the (column, value) pair at given index.
subscript<Value>(columnName: String) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
Returns the value at given column, converted to the requested type.
subscript<Value>(columnName: String) -> Value where Value : DatabaseValueConvertible { get }
Returns the value at given column, converted to the requested type.
subscript<Value>(index: Int) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
Returns the value at given index, converted to the requested type.
subscript<Value>(index: Int) -> Value where Value : DatabaseValueConvertible { get }
Returns the value at given index, converted to the requested type.
subscript<Value>(column: some ColumnExpression) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
Returns the value at given column, converted to the requested type.
subscript<Value>(column: some ColumnExpression) -> Value where Value : DatabaseValueConvertible { get }
Returns the value at given column, converted to the requested type.
static func == (lhs: Row, rhs: Row) -> Bool
Returns true if and only if both rows have the same columns and values, in the same order. Columns are compared in a case-sensitive way.
func coalesce<T>(_ columns: some Collection<any ColumnExpression>) -> T? where T : DatabaseValueConvertible
Returns the first non-null value, if any. Identical to SQL COALESCE
function.
func coalesce<T>(_ columns: some Collection<String>) -> T? where T : DatabaseValueConvertible
Returns the first non-null value, if any. Identical to SQL COALESCE
function.
func copy() -> Row
Returns an immutable copy of the row.
func hasColumn(_ columnName: String) -> Bool
Returns whether the row has one column with the given name (case-insensitive).
func hasNull(atIndex index: Int) -> Bool
Returns whether the row has a NULL
value at given index.
func hash(into hasher: inout Hasher)
func withUnsafeData<T>(at column: some ColumnExpression, _ body: (Data?) throws -> T) throws -> T
Calls the given closure with the Data
at the given column.
func withUnsafeData<T>(atIndex index: Int, _ body: (Data?) throws -> T) throws -> T
Calls the given closure with the Data
at given index.
func withUnsafeData<T>(named columnName: String, _ body: (Data?) throws -> T) throws -> T
Calls the given closure with the Data
at the given column.
struct Index
An index to a (column, value) pair in a Row
.
func dataNoCopy(_ column: some ColumnExpression) -> Data?
Returns the optional Data
at given column.
func dataNoCopy(atIndex index: Int) -> Data?
Returns the optional Data
at given index.
func dataNoCopy(named columnName: String) -> Data?
Returns the optional Data
at given column.
protocol Equatable
A type that can be compared for value equality.
var isEmpty: Bool { get }
A boolean value indicating if there is no prefetched associated rows.
var keys: Set<String> { get }
The available association keys.
subscript(key: String) -> [Row]? { get }
The prefetched rows associated with the given association key.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.