Index
An index to a (column, value) pair in a Row
.
struct Index
An index to a (column, value) pair in a Row
.
struct Index
import GRDB
A toolkit for SQLite databases, with a focus on application development
final class Row
A database row.
let count: Int
The number of columns in the row.
subscript(position: Index) -> (String, DatabaseValue) { get }
Returns the (column, value) pair at given index.
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
.
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 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 startIndex: Index { get }
var unadapted: Row { get }
The raw row fetched from the database.
var unscoped: Row { get }
The row, without any scope of prefetched rows.
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<Record>(key: String) -> Set<Record> where Record : FetchableRecord, Record : Hashable { get }
A set prefetched records associated to the given association key.
subscript<Record>(scope: String) -> Record where Record : FetchableRecord { get }
The record associated to the given scope.
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<Records>(key: String) -> Records where Records : RangeReplaceableCollection, Records.Element : FetchableRecord { get }
A collection of prefetched records associated to the given association key.
subscript<Record>(scope: String) -> Record? where Record : FetchableRecord { get }
The eventual record associated to the given scope.
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 PrefetchedRowsView
A view on the prefetched associated rows.
struct ScopesTreeView
A view on the scopes tree defined by row adapters.
struct ScopesView
A view on the scopes defined by row adapters.
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 Comparable : Equatable
A type that can be compared using the relational operators <
, <=
, >=
, and >
.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol Sendable
protocol Strideable<Stride> : Comparable
A type representing continuous, one-dimensional values that can be offset and measured.
static func < (lhs: Self, rhs: Self) -> Bool
static func == (lhs: Self, rhs: Self) -> Bool
func advanced(by n: Int) -> Row.Index
func distance(to other: Self) -> Int
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func ... (minimum: Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func < (x: Self, y: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == (x: Self, y: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.