diff --git a/docs/5.16/Classes.html b/docs/5.16/Classes.html new file mode 100644 index 000000000..a2c145259 --- /dev/null +++ b/docs/5.16/Classes.html @@ -0,0 +1,2358 @@ + + + + Classes Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Classes

+

The following classes are available globally.

+ +
+
+
+
+ + +
+ +

Specialized Cursors +

+
+
+
    +
  • +
    + + + + AnyCursor + +
    +
    +
    +
    +
    +
    +

    A type-erased cursor of Element.

    + +

    This cursor forwards its next() method to an arbitrary underlying cursor +having the same Element type, hiding the specifics of the underlying +cursor.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class AnyCursor<Element> : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Database + +
    +
    +
    +
    +
    +
    +

    A Database connection.

    + +

    You don’t create a database directly. Instead, you use a DatabaseQueue, or +a DatabasePool:

    +
    let dbQueue = DatabaseQueue(...)
    +
    +// The Database is the `db` in the closure:
    +try dbQueue.write { db in
    +    try Player(...).insert(db)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class Database : CustomStringConvertible, CustomDebugStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLStatementCursor + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class SQLStatementCursor : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseCollation + +
    +
    +
    +
    +
    +
    +

    A Collation is a string comparison function used by SQLite.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseCollation
    +
    extension DatabaseCollation: Hashable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseFunction + +
    +
    +
    +
    +
    +
    +

    An SQL function or aggregate.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseFunction : Hashable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabasePool + +
    +
    +
    +
    +
    +
    +

    A DatabasePool grants concurrent accesses to an SQLite database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabasePool : DatabaseWriter
    +
    extension DatabasePool: DatabaseReader
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseQueue + +
    +
    +
    +
    +
    +
    +

    A DatabaseQueue serializes access to an SQLite database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseQueue : DatabaseWriter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + AnyDatabaseReader + +
    +
    +
    +
    +
    +
    +

    A type-erased DatabaseReader

    + +

    Instances of AnyDatabaseReader forward their methods to an arbitrary +underlying database reader.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class AnyDatabaseReader : DatabaseReader
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseSnapshot + +
    +
    +
    +
    +
    +
    +

    A DatabaseSnapshot sees an unchanging database content, as it existed at the +moment it was created.

    + +

    See DatabasePool.makeSnapshot()

    + +

    For more information, read about “snapshot isolation” at https://sqlite.org/isolation.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class DatabaseSnapshot : DatabaseReader
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Cursors +

+
+
+
    +
  • +
    + + + + DatabaseValueCursor + +
    +
    +
    +
    +
    +
    +

    A cursor of database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let urls: DatabaseValueCursor<URL> = try URL.fetchCursor(db, sql: "SELECT url FROM link")
    +    while let url = urls.next() { // URL
    +        print(url)
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A cursor of optional database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let urls: NullableDatabaseValueCursor<URL> = try Optional<URL>.fetchCursor(db, sql: "SELECT url FROM link")
    +    while let url = urls.next() { // URL?
    +        print(url)
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class NullableDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseFuture + +
    +
    +
    +
    +
    +
    +

    A future database value, returned by the DatabaseWriter.concurrentRead(_:) +method.

    +
    let futureCount: Future<Int> = try writer.writeWithoutTransaction { db in
    +    try Player(...).insert()
    +
    +    // Count players concurrently
    +    return writer.concurrentRead { db in
    +        return try Player.fetchCount()
    +    }
    +}
    +
    +let count: Int = try futureCount.wait()
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class DatabaseFuture<Value>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + AnyDatabaseWriter + +
    +
    +
    +
    +
    +
    +

    A type-erased DatabaseWriter

    + +

    Instances of AnyDatabaseWriter forward their methods to an arbitrary +underlying database writer.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class AnyDatabaseWriter : DatabaseWriter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Row + +
    +
    +
    +
    +
    +
    +

    A database row.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class Row: Equatable, Hashable, RandomAccessCollection,
    +                        ExpressibleByDictionaryLiteral, CustomStringConvertible,
    +                        CustomDebugStringConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

RowCursor +

+
+
+
    +
  • +
    + + + + RowCursor + +
    +
    +
    +
    +
    +
    +

    A cursor of database rows. For example:

    +
    try dbQueue.read { db in
    +    let rows: RowCursor = try Row.fetchCursor(db, sql: "SELECT * FROM player")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class RowCursor : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Statement + +
    +
    +
    +
    +
    +
    +

    A statement represents an SQL query.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class Statement
    +
    extension Statement: _RowLayout
    +
    extension Statement: CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Cursors +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    A cursor of database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let names: ColumnCursor<String> = try String.fetchCursor(db, sql: "SELECT name FROM player")
    +    while let name = names.next() { // String
    +        print(name)
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FastDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible, Value : StatementColumnConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A cursor of optional database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let emails: FastNullableDatabaseValueCursor<String> =
    +        try Optional<String>.fetchCursor(db, sql: "SELECT email FROM player")
    +    while let email = emails.next() { // String?
    +        print(email ?? "<NULL>")
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FastNullableDatabaseValueCursor<Value>: Cursor
    +where Value: DatabaseValueConvertible & StatementColumnConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS3TableDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS3TableDefinition class lets you define columns of a FTS3 virtual table.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "document", using: FTS3()) { t in // t is FTS3TableDefinition
    +    t.column("content")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FTS3TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS4TableDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS4TableDefinition class lets you define columns of a FTS4 virtual table.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in // t is FTS4TableDefinition
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FTS4TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS4ColumnDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS4ColumnDefinition class lets you refine a column of an FTS4 +virtual table.

    + +

    You get instances of this class when you create an FTS4 table:

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("content")      // FTS4ColumnDefinition
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FTS4ColumnDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5TableDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "document", using: FTS5()) { t in // t is FTS5TableDefinition
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5ColumnDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS5ColumnDefinition class lets you refine a column of an FTS5 +virtual table.

    + +

    You get instances of this class when you create an FTS5 table:

    +
    try db.create(virtualTable: "document", using: FTS5()) { t in
    +    t.column("content")      // FTS5ColumnDefinition
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

TableAlias +

+
+
+
    +
  • +
    + + + + TableAlias + +
    +
    +
    +
    +
    +
    +

    Experimental

    + +

    A TableAlias identifies a table in a request.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class TableAlias : Hashable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + TableDefinition + +
    +
    +
    +
    +
    +
    +

    The TableDefinition class lets you define table columns and constraints.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(table:) method:

    +
    try db.create(table: "player") { t in // t is TableDefinition
    +    t.column(...)
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + TableAlteration + +
    +
    +
    +
    +
    +
    +

    The TableAlteration class lets you alter database tables.

    + +

    You don’t create instances of this class. Instead, you use the Database +alter(table:) method:

    +
    try db.alter(table: "player") { t in // t is TableAlteration
    +    t.add(column: ...)
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class TableAlteration
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnDefinition + +
    +
    +
    +
    +
    +
    +

    The ColumnDefinition class lets you refine a table column.

    + +

    You get instances of this class when you create or alter a database table:

    +
    try db.create(table: "player") { t in
    +    t.column(...)      // ColumnDefinition
    +}
    +
    +try db.alter(table: "player") { t in
    +    t.add(column: ...) // ColumnDefinition
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html and +https://www.sqlite.org/lang_altertable.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class ColumnDefinition
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

RecordCursor +

+
+
+
    +
  • +
    + + + + RecordCursor + +
    +
    +
    +
    +
    +
    +

    A cursor of records. For example:

    +
    struct Player : FetchableRecord { ... }
    +try dbQueue.read { db in
    +    let players: RecordCursor<Player> = try Player.fetchCursor(db, sql: "SELECT * FROM player")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class RecordCursor<Record> : Cursor where Record : FetchableRecord
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Record +

+
+
+
    +
  • +
    + + + + Record + +
    +
    +
    +
    +
    +
    +

    Record is a class that wraps a table row, or the result of any query. It is +designed to be subclassed.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class Record : FetchableRecord, TableRecord, PersistableRecord
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A type-erasing cancellable object that executes a provided closure +when canceled.

    + +

    An AnyDatabaseCancellable instance automatically calls cancel() + when deinitialized.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class AnyDatabaseCancellable : DatabaseCancellable
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Experimental

    + +

    A shared value observation that shares a single underlying database +observation for all subscriptions, and thus spares database resources.

    + +

    For example:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +
    +let cancellable = try sharedObservation.start(
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed.")
    +    })
    +
    + +

    The sharing only applies if you start observing the database from the +same SharedValueObservation instance:

    +
    // NOT shared
    +let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +
    +// Shared
    +let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
    +let cancellable1 = sharedObservation.start(...)
    +let cancellable2 = sharedObservation.start(...)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class SharedValueObservation<Element>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    ValueObservationScheduler determines how ValueObservation notifies its +fresh values.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class ValueObservationScheduler
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/AnyCursor.html b/docs/5.16/Classes/AnyCursor.html new file mode 100644 index 000000000..2e21577bf --- /dev/null +++ b/docs/5.16/Classes/AnyCursor.html @@ -0,0 +1,1272 @@ + + + + AnyCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyCursor

+
+
+ +
public final class AnyCursor<Element> : Cursor
+ +
+
+

A type-erased cursor of Element.

+ +

This cursor forwards its next() method to an arbitrary underlying cursor +having the same Element type, hiding the specifics of the underlying +cursor.

+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps a base cursor but whose type depends only on +the base cursor’s element type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ base: C) where Element == C.Element, C : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(iterator:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps a base iterator but whose type depends only +on the base iterator’s element type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init<I>(iterator: I) where Element == I.Element, I : IteratorProtocol
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps a base sequence but whose type depends only +on the base sequence’s element type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init<S>(_ s: S) where Element == S.Element, S : Sequence
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps the given closure in its next() method

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ body: @escaping () throws -> Element?)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Element?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/AnyDatabaseCancellable.html b/docs/5.16/Classes/AnyDatabaseCancellable.html new file mode 100644 index 000000000..2c25ee310 --- /dev/null +++ b/docs/5.16/Classes/AnyDatabaseCancellable.html @@ -0,0 +1,1210 @@ + + + + AnyDatabaseCancellable Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseCancellable

+
+
+ +
public class AnyDatabaseCancellable : DatabaseCancellable
+ +
+
+

A type-erasing cancellable object that executes a provided closure +when canceled.

+ +

An AnyDatabaseCancellable instance automatically calls cancel() + when deinitialized.

+ + +
+
+
+
    +
  • +
    + + + + init(cancel:) + +
    +
    +
    +
    +
    +
    +

    Initializes the cancellable object with the given cancel-time closure.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(cancel: @escaping () -> Void)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Initializes a cancellable object that forwards cancellation to the +provided cancellable.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(_ cancellable: DatabaseCancellable)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + cancel() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func cancel()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/AnyDatabaseReader.html b/docs/5.16/Classes/AnyDatabaseReader.html new file mode 100644 index 000000000..235518ed8 --- /dev/null +++ b/docs/5.16/Classes/AnyDatabaseReader.html @@ -0,0 +1,1378 @@ + + + + AnyDatabaseReader Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseReader

+
+
+ +
public final class AnyDatabaseReader : DatabaseReader
+ +
+
+

A type-erased DatabaseReader

+ +

Instances of AnyDatabaseReader forward their methods to an arbitrary +underlying database reader.

+ + +
+
+
+ +
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/AnyDatabaseWriter.html b/docs/5.16/Classes/AnyDatabaseWriter.html new file mode 100644 index 000000000..832069807 --- /dev/null +++ b/docs/5.16/Classes/AnyDatabaseWriter.html @@ -0,0 +1,1625 @@ + + + + AnyDatabaseWriter Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseWriter

+
+
+ +
public final class AnyDatabaseWriter : DatabaseWriter
+ +
+
+

A type-erased DatabaseWriter

+ +

Instances of AnyDatabaseWriter forward their methods to an arbitrary +underlying database writer.

+ + +
+
+
+ +
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ + +
+ +

Writing in Database +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/ColumnDefinition.html b/docs/5.16/Classes/ColumnDefinition.html new file mode 100644 index 000000000..03f13d8a6 --- /dev/null +++ b/docs/5.16/Classes/ColumnDefinition.html @@ -0,0 +1,1868 @@ + + + + ColumnDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnDefinition

+
+
+ +
public final class ColumnDefinition
+ +
+
+

The ColumnDefinition class lets you refine a table column.

+ +

You get instances of this class when you create or alter a database table:

+
try db.create(table: "player") { t in
+    t.column(...)      // ColumnDefinition
+}
+
+try db.alter(table: "player") { t in
+    t.add(column: ...) // ColumnDefinition
+}
+
+ +

See https://www.sqlite.org/lang_createtable.html and +https://www.sqlite.org/lang_altertable.html

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    The GeneratedColumnQualification enum defines whether a generated +column sis virtual or stored.

    + +

    See https://sqlite.org/gencol.html#virtual_versus_stored_columns

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum GeneratedColumnQualification
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Adds a primary key constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("id", .integer).primaryKey()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#primkeyconst and +https://www.sqlite.org/lang_createtable.html#rowid

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func primaryKey(
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    autoincrement: Bool = false)
    +-> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    + + autoincrement + + +
    +

    If true, the primary key is autoincremented.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + notNull(onConflict:) + +
    +
    +
    +
    +
    +
    +

    Adds a NOT NULL constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).notNull()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#notnullconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func notNull(onConflict conflictResolution: Database.ConflictResolution? = nil) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + unique(onConflict:) + +
    +
    +
    +
    +
    +
    +

    Adds a UNIQUE constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("email", .text).unique()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#uniqueconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func unique(onConflict conflictResolution: Database.ConflictResolution? = nil) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + indexed() + +
    +
    +
    +
    +
    +
    +

    Adds an index of the column.

    +
    try db.create(table: "player") { t in
    +    t.column("email", .text).indexed()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#uniqueconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func indexed() -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + check(_:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).check { length($0) > 0 }
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func check(_ condition: (Column) -> SQLExpressible) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + condition + + +
    +

    A closure whose argument is an Column that +represents the defined column, and returns the expression to check.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + check(sql:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).check(sql: "LENGTH(name) > 0")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func check(sql: String) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL snippet.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + defaults(to:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column value.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).defaults(to: "Anonymous")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#dfltval

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func defaults(to value: DatabaseValueConvertible) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A DatabaseValueConvertible value.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + defaults(sql:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column value.

    +
    try db.create(table: "player") { t in
    +    t.column("creationDate", .DateTime).defaults(sql: "CURRENT_TIMESTAMP")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#dfltval

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func defaults(sql: String) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL snippet.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + collate(_:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column collation.

    +
    try db.create(table: "player") { t in
    +    t.column("email", .text).collate(.nocase)
    +}
    +
    + +

    See https://www.sqlite.org/datatype3.html#collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func collate(_ collation: Database.CollationName) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + collation + + +
    +

    An Database.CollationName.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + collate(_:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column collation.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).collate(.localizedCaseInsensitiveCompare)
    +}
    +
    + +

    See https://www.sqlite.org/datatype3.html#collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func collate(_ collation: DatabaseCollation) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + collation + + +
    +

    A custom DatabaseCollation.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + generatedAs(sql:_:) + +
    +
    +
    +
    +
    +
    +

    Defines the column as a generated column.

    +
    try db.create(table: "player") { t in
    +    t.column("id", .integer).primaryKey()
    +    t.column("score", .integer).notNull()
    +    t.column("bonus", .integer).notNull()
    +    t.column("totalScore", .integer).generatedAs(sql: "score + bonus", .stored)
    +}
    +
    + +

    See https://sqlite.org/gencol.html. Note particularly the limitations of +generated columns, e.g. they may not have a default value.

    + +
    +
    +
    +
  • +
  • +
    + + + + generatedAs(_:_:) + +
    +
    +
    +
    +
    +
    +

    Defines the column as a generated column.

    +
    try db.create(table: "player") { t in
    +    t.column("id", .integer).primaryKey()
    +    t.column("score", .integer).notNull()
    +    t.column("bonus", .integer).notNull()
    +    t.column("totalScore", .integer).generatedAs(Column("score") + Column("bonus"), .stored)
    +}
    +
    + +

    See https://sqlite.org/gencol.html. Note particularly the limitations of +generated columns, e.g. they may not have a default value.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Defines a foreign key.

    +
    try db.create(table: "book") { t in
    +    t.column("authorId", .integer).references("author", onDelete: .cascade)
    +}
    +
    + +

    See https://www.sqlite.org/foreignkeys.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func references(
    +    _ table: String,
    +    column: String? = nil,
    +    onDelete deleteAction: Database.ForeignKeyAction? = nil,
    +    onUpdate updateAction: Database.ForeignKeyAction? = nil,
    +    deferred: Bool = false) -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/ColumnDefinition/GeneratedColumnQualification.html b/docs/5.16/Classes/ColumnDefinition/GeneratedColumnQualification.html new file mode 100644 index 000000000..32aa23d3c --- /dev/null +++ b/docs/5.16/Classes/ColumnDefinition/GeneratedColumnQualification.html @@ -0,0 +1,1179 @@ + + + + GeneratedColumnQualification Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

GeneratedColumnQualification

+
+
+ +
public enum GeneratedColumnQualification
+ +
+
+

The GeneratedColumnQualification enum defines whether a generated +column sis virtual or stored.

+ +

See https://sqlite.org/gencol.html#virtual_versus_stored_columns

+ + +
+
+
+
    +
  • +
    + + + + virtual + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case virtual
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + stored + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case stored
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database.html b/docs/5.16/Classes/Database.html new file mode 100644 index 000000000..f67c67674 --- /dev/null +++ b/docs/5.16/Classes/Database.html @@ -0,0 +1,5443 @@ + + + + Database Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Database

+
+
+ +
public final class Database : CustomStringConvertible, CustomDebugStringConvertible
+ +
+
+

A Database connection.

+ +

You don’t create a database directly. Instead, you use a DatabaseQueue, or +a DatabasePool:

+
let dbQueue = DatabaseQueue(...)
+
+// The Database is the `db` in the closure:
+try dbQueue.write { db in
+    try Player(...).insert(db)
+}
+
+ + +
+
+
+
+ + +
+ +

SQLite C API +

+
+
+
    +
  • +
    + + + + sqliteConnection + +
    +
    +
    +
    +
    +
    +

    The raw SQLite connection, suitable for the SQLite C API. +It is constant, until close() sets it to nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqliteConnection: SQLiteConnection?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Configuration +

+
+
+
    +
  • +
    + + + + logError + +
    +
    +
    +
    +
    +
    +

    The error logging function.

    + +

    Quoting https://www.sqlite.org/errlog.html:

    + +
    +

    SQLite can be configured to invoke a callback function containing an +error code and a terse error message whenever anomalies occur. This +mechanism is very helpful in tracking obscure problems that occur +rarely and in the field. Application developers are encouraged to take +advantage of the error logging facility of SQLite in their products, +as it is very low CPU and memory cost but can be a huge aid +for debugging.

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var logError: LogErrorFunction? { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let configuration: Configuration
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + description + +
    +
    +
    +
    +
    + +
    +

    Declaration

    +
    +

    Swift

    +
    public let description: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + debugDescription + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var debugDescription: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Information +

+
+
+
    +
  • +
    + + + + lastInsertedRowID + +
    +
    +
    +
    +
    +
    +

    The rowID of the most recently inserted row.

    + +

    If no row has ever been inserted using this database connection, +returns zero.

    + +

    For more detailed information, see https://www.sqlite.org/c3ref/last_insert_rowid.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var lastInsertedRowID: Int64 { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + changesCount + +
    +
    +
    +
    +
    +
    +

    The number of rows modified, inserted or deleted by the most recent +successful INSERT, UPDATE or DELETE statement.

    + +

    For more detailed information, see https://www.sqlite.org/c3ref/changes.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var changesCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + totalChangesCount + +
    +
    +
    +
    +
    +
    +

    The total number of rows modified, inserted or deleted by all successful +INSERT, UPDATE or DELETE statements since the database connection was +opened.

    + +

    For more detailed information, see https://www.sqlite.org/c3ref/total_changes.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var totalChangesCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isInsideTransaction + +
    +
    +
    +
    +
    +
    +

    True if the database connection is currently in a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isInsideTransaction: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lastErrorCode + +
    +
    +
    +
    +
    +
    +

    The last error code

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var lastErrorCode: ResultCode { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lastErrorMessage + +
    +
    +
    +
    +
    +
    +

    The last error message

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var lastErrorMessage: String? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Limits +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    The maximum number of arguments accepted by an SQLite statement.

    + +

    For example, requests such as the one below must make sure the ids +array does not contain more than maximumStatementArgumentCount +elements:

    +
    let ids: [Int] = ...
    +try dbQueue.write { db in
    +    try Player.deleteAll(db, keys: ids)
    +}
    +
    + +

    See https://www.sqlite.org/limits.html +and SQLITE_LIMIT_VARIABLE_NUMBER.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var maximumStatementArgumentCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Functions +

+
+
+
    +
  • +
    + + + + add(function:) + +
    +
    +
    +
    +
    +
    +

    Add or redefine an SQL function.

    +
    let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
    +    guard let int = Int.fromDatabaseValue(dbValues[0]) else {
    +        return nil
    +    }
    +    return int + 1
    +}
    +db.add(function: fn)
    +try Int.fetchOne(db, sql: "SELECT succ(1)")! // 2
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(function: DatabaseFunction)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove(function:) + +
    +
    +
    +
    +
    +
    +

    Remove an SQL function.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(function: DatabaseFunction)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Collations +

+
+
+
    +
  • +
    + + + + add(collation:) + +
    +
    +
    +
    +
    +
    +

    Add or redefine a collation.

    +
    let collation = DatabaseCollation("localized_standard") { (string1, string2) in
    +    return (string1 as NSString).localizedStandardCompare(string2)
    +}
    +db.add(collation: collation)
    +try db.execute(sql: "CREATE TABLE files (name TEXT COLLATE localized_standard")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(collation: DatabaseCollation)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove(collation:) + +
    +
    +
    +
    +
    +
    +

    Remove a collation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(collation: DatabaseCollation)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Trace +

+
+
+
    +
  • +
    + + + + trace(options:_:) + +
    +
    +
    +
    +
    +
    +

    Registers a tracing function.

    + +

    For example:

    +
    // Trace all SQL statements executed by the database
    +var configuration = Configuration()
    +configuration.prepareDatabase { db in
    +    db.trace(options: .statement) { event in
    +        print("SQL: \(event)")
    +    }
    +}
    +let dbQueue = try DatabaseQueue(path: "...", configuration: configuration)
    +
    + +

    Pass an empty options set in order to stop database tracing:

    +
    // Stop tracing
    +db.trace(options: [])
    +
    + +

    See https://www.sqlite.org/c3ref/trace_v2.html for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func trace(options: TracingOptions = .statement, _ trace: ((TraceEvent) -> Void)? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + options + + +
    +

    The set of desired event kinds. Defaults to +.statement, which notifies all executed database statements.

    +
    +
    + + trace + + +
    +

    the tracing function.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

WAL Checkpoints +

+
+
+
    +
  • +
    + + + + checkpoint(_:on:) + +
    +
    +
    +
    +
    +
    +

    Runs a WAL checkpoint.

    + +

    See https://www.sqlite.org/wal.html and +https://www.sqlite.org/c3ref/wal_checkpoint_v2.html for +more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func checkpoint(_ kind: Database.CheckpointMode = .passive, on dbName: String? = "main") throws
    +-> (walFrameCount: Int, checkpointedFrameCount: Int)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The checkpoint mode (default passive)

    +
    +
    + + dbName + + +
    +

    The database name (default “main”)

    +
    +
    +
    +
    +

    Return Value

    +

    A tuple: + +

      +
    • walFrameCount: the total number of frames in the log file
    • +
    • checkpointedFrameCount: the total number of checkpointed frames +in the log file
    • +

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Suspension +

+
+
+ +
+
+
+ + +
+ +

Transactions & Savepoint +

+
+
+
    +
  • +
    + + + + inTransaction(_:_:) + +
    +
    +
    +
    +
    +
    +

    Executes a block inside a database transaction.

    +
    try dbQueue.inDatabase do {
    +    try db.inTransaction {
    +        try db.execute(sql: "INSERT ...")
    +        return .commit
    +    }
    +}
    +
    + +

    If the block throws an error, the transaction is rollbacked and the +error is rethrown.

    + +

    This method is not reentrant: you can’t nest transactions.

    +
    +

    Throws

    + The error thrown by the block. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inTransaction(_ kind: TransactionKind? = nil, _ block: () throws -> TransactionCompletion) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the transaction +type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    + + block + + +
    +

    A block that executes SQL statements and return either +.commit or .rollback.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + inSavepoint(_:) + +
    +
    +
    +
    +
    +
    +

    Executes a block inside a savepoint.

    +
    try dbQueue.inDatabase do {
    +    try db.inSavepoint {
    +        try db.execute(sql: "INSERT ...")
    +        return .commit
    +    }
    +}
    +
    + +

    If the block throws an error, the savepoint is rollbacked and the +error is rethrown.

    + +

    This method is reentrant: you can nest savepoints.

    +
    +

    Throws

    + The error thrown by the block. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inSavepoint(_ block: () throws -> TransactionCompletion) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + block + + +
    +

    A block that executes SQL statements and return +either .commit or .rollback.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + beginTransaction(_:) + +
    +
    +
    +
    +
    +
    +

    Begins a database transaction.

    +
    +

    Throws

    + The error thrown by the block. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func beginTransaction(_ kind: TransactionKind? = nil) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the +transaction type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + rollback() + +
    +
    +
    +
    +
    +
    +

    Rollbacks a database transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func rollback() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + commit() + +
    +
    +
    +
    +
    +
    +

    Commits a database transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func commit() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Schema +

+
+
+
    +
  • +
    + + + + clearSchemaCache() + +
    +
    +
    +
    +
    +
    +

    Clears the database schema cache.

    + +

    You may need to clear the cache manually if the database schema is +modified by another connection.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func clearSchemaCache()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + tableExists(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a table exists in the main or temp schema.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func tableExists(_ name: String) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal SQLite table.

    + +

    Those are tables whose name begins with sqlite_ and pragma_.

    + +

    For more information, see https://www.sqlite.org/fileformat2.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func isSQLiteInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal SQLite table.

    + +

    Those are tables whose name begins with sqlite_ and pragma_.

    + +

    For more information, see https://www.sqlite.org/fileformat2.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Use Database.isSQLiteInternalTable(_:﹚ static method instead.")
    +public func isSQLiteInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal GRDB table.

    + +

    Those are tables whose name begins with “grdb_”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func isGRDBInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal GRDB table.

    + +

    Those are tables whose name begins with “grdb_”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Use Database.isGRDBInternalTable(_:﹚ static method instead.")
    +public func isGRDBInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + viewExists(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a view exists in the main or temp schema.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func viewExists(_ name: String) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + triggerExists(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a trigger exists in the main or temp schema.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func triggerExists(_ name: String) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + primaryKey(_:) + +
    +
    +
    +
    +
    +
    +

    The primary key for table named tableName.

    + +

    All tables have a primary key, even when it is not explicit. When a +table has no explicit primary key, the result is the hidden +“rowid” column.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func primaryKey(_ tableName: String) throws -> PrimaryKeyInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + indexes(on:) + +
    +
    +
    +
    +
    +
    +

    The indexes on table named tableName.

    + +

    Only indexes on columns are returned. Indexes on expressions are +not returned.

    + +

    SQLite does not define any index for INTEGER PRIMARY KEY columns: this +method does not return any index that represents the primary key.

    + +

    If you want to know if a set of columns uniquely identify a row, prefer +table(_:hasUniqueKey:) instead.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func indexes(on tableName: String) throws -> [IndexInfo]
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    True if a sequence of columns uniquely identifies a row, that is to say +if the columns are the primary key, or if there is a unique index on them.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func table<T: Sequence>(
    +    _ tableName: String,
    +    hasUniqueKey columns: T)
    +throws -> Bool
    +where T.Iterator.Element == String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + foreignKeys(on:) + +
    +
    +
    +
    +
    +
    +

    The foreign keys defined on table named tableName.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKeys(on tableName: String) throws -> [ForeignKeyInfo]
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over foreign key violations in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKeyViolations() throws -> RecordCursor<ForeignKeyViolation>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over foreign key violations in the table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKeyViolations(in tableName: String) throws -> RecordCursor<ForeignKeyViolation>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + checkForeignKeys() + +
    +
    +
    +
    +
    +
    +

    Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY +if there exists a foreign key violation in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func checkForeignKeys() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + checkForeignKeys(in:) + +
    +
    +
    +
    +
    +
    +

    Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY +if there exists a foreign key violation in the table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func checkForeignKeys(in tableName: String) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + columns(in:) + +
    +
    +
    +
    +
    +
    +

    The columns in the table named tableName.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func columns(in tableName: String) throws -> [ColumnInfo]
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Statements +

+
+
+
    +
  • +
    + + + + makeStatement(sql:) + +
    +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.makeStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makeStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeStatement(literal: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.makeStatement(literal: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try makeStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try makeStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try makeStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makeStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeSelectStatement(sql: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(sql:﹚")
    +public func makeSelectStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try makeSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try makeSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try makeSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(literal:﹚")
    +public func makeSelectStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • +
    + + + + cachedStatement(sql:) + +
    +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedStatement(sql: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.cachedStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    + +

    The returned statement may have already been used: it may or may not +contain values for its eventual arguments.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func cachedStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedStatement(literal: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.cachedStatement(literal: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try cachedStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try cachedStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try cachedStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func cachedStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedSelectStatement(sql: "SELECT COUNT(*) FROM player WHERE score > ?")
    +let moreThanTwentyCount = try Int.fetchOne(statement, arguments: [20])!
    +let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
    +
    + +

    The returned statement may have already been used: it may or may not +contain values for its eventual arguments.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(sql:﹚")
    +public func cachedSelectStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedSelectStatement(literal: "SELECT COUNT(*) FROM player WHERE score > \(20)")
    +let moreThanTwentyCount = try Int.fetchOne(statement)!
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try cachedSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try cachedSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try cachedSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(literal:﹚")
    +public func cachedSelectStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeUpdateStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(sql:﹚")
    +public func makeUpdateStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    An UpdateStatement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try makeUpdateStatement(literal: """
    +    UPDATE player SET name = ?
    +    """)
    +try makeUpdateStatement(literal: """
    +    UPDATE player SET name = \("O'Brien")
    +    """)
    +
    +// NOT OK
    +try makeUpdateStatement(literal: """
    +    UPDATE player SET name = ?, score = \(10)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(literal:﹚")
    +public func makeUpdateStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedUpdateStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    + +

    The returned statement may have already been used: it may or may not +contain values for its eventual arguments.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(sql:﹚")
    +public func cachedUpdateStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try cachedUpdateStatement(literal: """
    +    UPDATE player SET name = ?
    +    """)
    +try cachedUpdateStatement(literal: """
    +    UPDATE player SET name = \("O'Brien")
    +    """)
    +
    +// NOT OK
    +try cachedUpdateStatement(literal: """
    +    UPDATE player SET name = ?, score = \(10)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(sql:﹚")
    +public func cachedUpdateStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor of all SQL statements separated by semi-colons.

    +
    let statements = try db.allStatements(sql: """
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    """, arguments: ["Arthur", "Barbara", "O'Brien"])
    +while let statement = try statements.next() {
    +    try statement.execute()
    +}
    +
    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    +

    Precondition

    +

    Arguments must be nil, or all arguments must be set. +The returned cursor will throw an error otherwise.

    +
    // OK
    +try allStatements(sql: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """)
    +try allStatements(sql: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """, arguments: [1000, 1000])
    +
    +// NOT OK
    +try allStatements(sql: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """, arguments: [1000])
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func allStatements(sql: String, arguments: StatementArguments? = nil)
    +throws -> SQLStatementCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor of Statement

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor of all SQL statements separated by semi-colons.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    let statements = try db.allStatements(literal: """
    +    INSERT INTO player (name) VALUES (\("Arthur"));
    +    INSERT INTO player (name) VALUES (\("Barbara"));
    +    INSERT INTO player (name) VALUES (\("O'Brien"));
    +    """)
    +while let statement = try statements.next() {
    +    try statement.execute()
    +}
    +
    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +The returned cursor will throw an error otherwise.

    +
    // OK
    +try allStatements(literal: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """)
    +try allStatements(literal: """
    +    SELECT COUNT(*) FROM player WHERE score < \(1000);
    +    SELECT COUNT(*) FROM player WHERE score > \(1000);
    +    """)
    +
    +// NOT OK
    +try allStatements(literal: """
    +    SELECT COUNT(*) FROM player WHERE score < \(1000);
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func allStatements(literal sqlLiteral: SQL) throws -> SQLStatementCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor of Statement

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Executes one or several SQL statements, separated by semi-colons.

    +
    try db.execute(
    +    sql: "INSERT INTO player (name) VALUES (:name)",
    +    arguments: ["name": "Arthur"])
    +
    +try db.execute(sql: """
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    """, arguments: ["Arthur", "Barbara", "O'Brien"])
    +
    + +

    This method may throw a DatabaseError.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func execute(sql: String, arguments: StatementArguments = StatementArguments()) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + execute(literal:) + +
    +
    +
    +
    +
    +
    +

    Executes one or several SQL statements, separated by semi-colons.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    try db.execute(literal: """
    +    INSERT INTO player (name) VALUES (\("Arthur"))
    +    """)
    +
    +try db.execute(literal: """
    +    INSERT INTO player (name) VALUES (\("Arthur"));
    +    INSERT INTO player (name) VALUES (\("Barbara"));
    +    INSERT INTO player (name) VALUES (\("O'Brien"));
    +    """)
    +
    + +

    This method may throw a DatabaseError.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func execute(literal sqlLiteral: SQL) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database-Related Types +

+
+
+ +
+
+
+ + +
+ +

Database Observation +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Add a transaction observer, so that it gets notified of +database changes.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(
    +    transactionObserver: TransactionObserver,
    +    extent: TransactionObservationExtent = .observerLifetime)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + transactionObserver + + +
    +

    A transaction observer.

    +
    +
    + + extent + + +
    +

    The duration of the observation. The default is +the observer lifetime (observation lasts until observer +is deallocated).

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Remove a transaction observer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(transactionObserver: TransactionObserver)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Registers a closure to be executed after the next or current +transaction completion.

    +
    try dbQueue.write { db in
    +    db.afterNextTransactionCommit { _ in
    +        print("success")
    +    }
    +    ...
    +} // prints "success"
    +
    + +

    If the transaction is rollbacked, the closure is not executed.

    + +

    If the transaction is committed, the closure is executed in a protected +dispatch queue, serialized will all database updates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func afterNextTransactionCommit(_ closure: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The extent of a transaction observation

    + +

    See Database.add(transactionObserver:extent:)

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum TransactionObservationExtent
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Deletes the synchronization triggers for a synchronized FTS4 table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropFTS4SynchronizationTriggers(forTable tableName: String) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Schema +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a database table.

    +
    try db.create(table: "place") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("title", .text)
    +    t.column("favorite", .boolean).notNull().default(false)
    +    t.column("longitude", .double).notNull()
    +    t.column("latitude", .double).notNull()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html and +https://www.sqlite.org/withoutrowid.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(
    +    table name: String,
    +    temporary: Bool = false,
    +    ifNotExists: Bool = false,
    +    withoutRowID: Bool = false,
    +    body: (TableDefinition) -> Void)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + temporary + + +
    +

    If true, creates a temporary table.

    +
    +
    + + ifNotExists + + +
    +

    If false (the default), an error is thrown if the +table already exists. Otherwise, the table is created unless it +already exists.

    +
    +
    + + withoutRowID + + +
    +

    If true, uses WITHOUT ROWID optimization.

    +
    +
    + + body + + +
    +

    A closure that defines table columns and constraints.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + rename(table:to:) + +
    +
    +
    +
    +
    +
    +

    Renames a database table.

    + +

    See https://www.sqlite.org/lang_altertable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func rename(table name: String, to newName: String) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + alter(table:body:) + +
    +
    +
    +
    +
    +
    +

    Modifies a database table.

    +
    try db.alter(table: "player") { t in
    +    t.add(column: "url", .text)
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func alter(table name: String, body: (TableAlteration) -> Void) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + body + + +
    +

    A closure that defines table alterations.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + drop(table:) + +
    +
    +
    +
    +
    +
    +

    Deletes a database table.

    + +

    See https://www.sqlite.org/lang_droptable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func drop(table name: String) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates an index.

    +
    try db.create(index: "playerByEmail", on: "player", columns: ["email"])
    +
    + +

    SQLite can also index expressions (https://www.sqlite.org/expridx.html) +and use specific collations. To create such an index, use a raw SQL +query.

    +
    try db.execute(sql: "CREATE INDEX ...")
    +
    + +

    See https://www.sqlite.org/lang_createindex.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(
    +    index name: String,
    +    on table: String,
    +    columns: [String],
    +    unique: Bool = false,
    +    ifNotExists: Bool = false,
    +    condition: SQLExpressible? = nil)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The index name.

    +
    +
    + + table + + +
    +

    The name of the indexed table.

    +
    +
    + + columns + + +
    +

    The indexed columns.

    +
    +
    + + unique + + +
    +

    If true, creates a unique index.

    +
    +
    + + ifNotExists + + +
    +

    If false, no error is thrown if index already exists.

    +
    +
    + + condition + + +
    +

    If not nil, creates a partial index +(see https://www.sqlite.org/partialindex.html).

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + drop(index:) + +
    +
    +
    +
    +
    +
    +

    Deletes a database index.

    + +

    See https://www.sqlite.org/lang_dropindex.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func drop(index name: String) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reindex(collation:) + +
    +
    +
    +
    +
    +
    +

    Delete and recreate from scratch all indices that use this collation.

    + +

    This method is useful when the definition of a collation sequence +has changed.

    + +

    See https://www.sqlite.org/lang_reindex.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reindex(collation: Database.CollationName) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reindex(collation:) + +
    +
    +
    +
    +
    +
    +

    Delete and recreate from scratch all indices that use this collation.

    + +

    This method is useful when the definition of a collation sequence +has changed.

    + +

    See https://www.sqlite.org/lang_reindex.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reindex(collation: DatabaseCollation) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a virtual database table.

    +
    try db.create(virtualTable: "vocabulary", using: "spellfix1")
    +
    + +

    See https://www.sqlite.org/lang_createtable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(virtualTable name: String, ifNotExists: Bool = false, using module: String) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + ifNotExists + + +
    +

    If false (the default), an error is thrown if the +table already exists. Otherwise, the table is created unless it +already exists.

    +
    +
    + + module + + +
    +

    The name of an SQLite virtual table module.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a virtual database table.

    +
    let module = ...
    +try db.create(virtualTable: "book", using: module) { t in
    +    ...
    +}
    +
    + +

    The type of the closure argument t depends on the type of the module +argument: refer to this module’s documentation.

    + +

    Use this method to create full-text tables using the FTS3, FTS4, or +FTS5 modules:

    +
    try db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.column("title")
    +    t.column("author")
    +    t.column("body")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create<Module: VirtualTableModule>(
    +    virtualTable tableName: String,
    +    ifNotExists: Bool = false,
    +    using module: Module,
    +    _ body: ((Module.TableDefinition) -> Void)? = nil)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + ifNotExists + + +
    +

    If false (the default), an error is thrown if the +table already exists. Otherwise, the table is created unless it +already exists.

    +
    +
    + + module + + +
    +

    a VirtualTableModule

    +
    +
    + + body + + +
    +

    An optional closure that defines the virtual table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/BusyMode.html b/docs/5.16/Classes/Database/BusyMode.html new file mode 100644 index 000000000..de3d87727 --- /dev/null +++ b/docs/5.16/Classes/Database/BusyMode.html @@ -0,0 +1,1236 @@ + + + + BusyMode Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

BusyMode

+
+
+ +
public enum BusyMode
+ +
+
+

When there are several connections to a database, a connection may try +to access the database while it is locked by another connection.

+ +

The BusyMode enum describes the behavior of GRDB when such a situation +occurs:

+ +
    +
  • .immediateError: The SQLITE_BUSY error is immediately returned to the +connection that tries to access the locked database.

  • +
  • .timeout: The SQLITE_BUSY error will be returned only if the database +remains locked for more than the specified duration.

  • +
  • .callback: Perform your custom lock handling.

  • +
+ +

To set the busy mode of a database, use Configuration:

+
// Wait 1 second before failing with SQLITE_BUSY
+let configuration = Configuration(busyMode: .timeout(1))
+let dbQueue = DatabaseQueue(path: "...", configuration: configuration)
+
+ +

Relevant SQLite documentation:

+ + + + +
+
+
+
    +
  • +
    + + + + immediateError + +
    +
    +
    +
    +
    +
    +

    The SQLITE_BUSY error is immediately returned to the connection that +tries to access the locked database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case immediateError
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + timeout(_:) + +
    +
    +
    +
    +
    +
    +

    The SQLITE_BUSY error will be returned only if the database remains +locked for more than the specified duration (in seconds).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeout(TimeInterval)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + callback(_:) + +
    +
    +
    +
    +
    +
    +

    A custom callback that is called when a database is locked. +See https://www.sqlite.org/c3ref/busy_handler.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case callback(BusyCallback)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/CheckpointMode.html b/docs/5.16/Classes/Database/CheckpointMode.html new file mode 100644 index 000000000..8a110e1ca --- /dev/null +++ b/docs/5.16/Classes/Database/CheckpointMode.html @@ -0,0 +1,1236 @@ + + + + CheckpointMode Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CheckpointMode

+
+
+ +
public enum CheckpointMode : Int32
+ +
+
+

The available checkpoint modes.

+ + +
+
+
+
    +
  • +
    + + + + passive + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_PASSIVE mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case passive = 0
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + full + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_FULL mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case full = 1
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + restart + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_RESTART mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case restart = 2
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + truncate + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_TRUNCATE mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case truncate = 3
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/CollationName.html b/docs/5.16/Classes/Database/CollationName.html new file mode 100644 index 000000000..5d89a1199 --- /dev/null +++ b/docs/5.16/Classes/Database/CollationName.html @@ -0,0 +1,1238 @@ + + + + CollationName Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CollationName

+
+
+ +
public struct CollationName : RawRepresentable, Hashable
+ +
+
+

A built-in SQLite collation.

+ +

See https://www.sqlite.org/datatype3.html#collation

+ + +
+
+
+
    +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    +

    Creates a built-in collation name.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawValue: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + binary + +
    +
    +
    +
    +
    +
    +

    The BINARY built-in SQL collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let binary: Database.CollationName
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + nocase + +
    +
    +
    +
    +
    +
    +

    The NOCASE built-in SQL collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let nocase: Database.CollationName
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rtrim + +
    +
    +
    +
    +
    +
    +

    The RTRIM built-in SQL collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let rtrim: Database.CollationName
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/ColumnType.html b/docs/5.16/Classes/Database/ColumnType.html new file mode 100644 index 000000000..59d399e88 --- /dev/null +++ b/docs/5.16/Classes/Database/ColumnType.html @@ -0,0 +1,1393 @@ + + + + ColumnType Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnType

+
+
+ +
public struct ColumnType : RawRepresentable, Hashable
+ +
+
+

An SQL column type.

+
try db.create(table: "player") { t in
+    t.autoIncrementedPrimaryKey("id")
+    t.column("title", .text)
+}
+
+ +

See https://www.sqlite.org/datatype3.html

+ + +
+
+
+
    +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    +

    Creates an SQL column type.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawValue: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + text + +
    +
    +
    +
    +
    +
    +

    The TEXT SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let text: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + integer + +
    +
    +
    +
    +
    +
    +

    The INTEGER SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let integer: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + double + +
    +
    +
    +
    +
    +
    +

    The DOUBLE SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let double: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + numeric + +
    +
    +
    +
    +
    +
    +

    The NUMERIC SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let numeric: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + boolean + +
    +
    +
    +
    +
    +
    +

    The BOOLEAN SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let boolean: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + blob + +
    +
    +
    +
    +
    +
    +

    The BLOB SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let blob: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + date + +
    +
    +
    +
    +
    +
    +

    The DATE SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let date: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + datetime + +
    +
    +
    +
    +
    +
    +

    The DATETIME SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let datetime: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/ConflictResolution.html b/docs/5.16/Classes/Database/ConflictResolution.html new file mode 100644 index 000000000..7767badf2 --- /dev/null +++ b/docs/5.16/Classes/Database/ConflictResolution.html @@ -0,0 +1,1268 @@ + + + + ConflictResolution Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ConflictResolution

+
+
+ +
public enum ConflictResolution : String
+ +
+
+

An SQLite conflict resolution.

+ +

See https://www.sqlite.org/lang_conflict.html

+ + +
+
+
+
    +
  • +
    + + + + rollback + +
    +
    +
    +
    +
    +
    +

    The ROLLBACK conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case rollback = "ROLLBACK"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + abort + +
    +
    +
    +
    +
    +
    +

    The ABORT conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case abort = "ABORT"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fail + +
    +
    +
    +
    +
    +
    +

    The FAIL conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case fail = "FAIL"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ignore + +
    +
    +
    +
    +
    +
    +

    The IGNORE conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case ignore = "IGNORE"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + replace + +
    +
    +
    +
    +
    +
    +

    The REPLACE conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case replace = "REPLACE"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/ForeignKeyAction.html b/docs/5.16/Classes/Database/ForeignKeyAction.html new file mode 100644 index 000000000..5530afa7c --- /dev/null +++ b/docs/5.16/Classes/Database/ForeignKeyAction.html @@ -0,0 +1,1238 @@ + + + + ForeignKeyAction Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyAction

+
+
+ +
public enum ForeignKeyAction : String
+ +
+
+

A foreign key action.

+ +

See https://www.sqlite.org/foreignkeys.html

+ + +
+
+
+
    +
  • +
    + + + + cascade + +
    +
    +
    +
    +
    +
    +

    The CASCADE foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case cascade = "CASCADE"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + restrict + +
    +
    +
    +
    +
    +
    +

    The RESTRICT foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case restrict = "RESTRICT"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + setNull + +
    +
    +
    +
    +
    +
    +

    The SET NULL foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case setNull = "SET NULL"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + setDefault + +
    +
    +
    +
    +
    +
    +

    The SET DEFAULT foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case setDefault = "SET DEFAULT"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/TraceEvent.html b/docs/5.16/Classes/Database/TraceEvent.html new file mode 100644 index 000000000..7a9ff89da --- /dev/null +++ b/docs/5.16/Classes/Database/TraceEvent.html @@ -0,0 +1,1236 @@ + + + + TraceEvent Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TraceEvent

+
+
+ +
public enum TraceEvent : CustomStringConvertible
+ +
+
+

An event reported by Database.trace(options:_:)

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/TraceEvent/Statement.html b/docs/5.16/Classes/Database/TraceEvent/Statement.html new file mode 100644 index 000000000..5dded6227 --- /dev/null +++ b/docs/5.16/Classes/Database/TraceEvent/Statement.html @@ -0,0 +1,1184 @@ + + + + Statement Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Statement

+
+
+ +
public struct Statement
+ +
+
+

Information about a statement reported by Database.trace(options:_:)

+ + +
+
+
+
    +
  • +
    + + + + sql + +
    +
    +
    +
    +
    +
    +

    The executed SQL, where bound parameters are not expanded.

    + +

    For example:

    +
    UPDATE player SET score = ? WHERE id = ?
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sql: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + expandedSQL + +
    +
    +
    +
    +
    +
    +

    The executed SQL, where bound parameters are expanded.

    + +

    For example:

    +
    UPDATE player SET score = 1000 WHERE id = 1
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var expandedSQL: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/TracingOptions.html b/docs/5.16/Classes/Database/TracingOptions.html new file mode 100644 index 000000000..976c0a216 --- /dev/null +++ b/docs/5.16/Classes/Database/TracingOptions.html @@ -0,0 +1,1250 @@ + + + + TracingOptions Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TracingOptions

+
+
+ +
public struct TracingOptions : OptionSet
+ +
+
+

An option for Database.trace(options:_:)

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/TransactionCompletion.html b/docs/5.16/Classes/Database/TransactionCompletion.html new file mode 100644 index 000000000..3cd356236 --- /dev/null +++ b/docs/5.16/Classes/Database/TransactionCompletion.html @@ -0,0 +1,1177 @@ + + + + TransactionCompletion Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionCompletion

+
+
+ +
@frozen
+public enum TransactionCompletion
+ +
+
+

Confirms or cancels the changes performed by a transaction or savepoint.

+ + +
+
+
+
    +
  • +
    + + + + commit + +
    +
    +
    +
    +
    +
    +

    Confirms changes

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case commit
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rollback + +
    +
    +
    +
    +
    +
    +

    Cancel changes

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case rollback
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/TransactionKind.html b/docs/5.16/Classes/Database/TransactionKind.html new file mode 100644 index 000000000..a48aaa97c --- /dev/null +++ b/docs/5.16/Classes/Database/TransactionKind.html @@ -0,0 +1,1206 @@ + + + + TransactionKind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionKind

+
+
+ +
public enum TransactionKind : String
+ +
+
+

An SQLite transaction kind. See https://www.sqlite.org/lang_transaction.html

+ + +
+
+
+
    +
  • +
    + + + + deferred + +
    +
    +
    +
    +
    +
    +

    The DEFERRED transaction kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferred = "DEFERRED"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + immediate + +
    +
    +
    +
    +
    +
    +

    The IMMEDIATE transaction kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case immediate = "IMMEDIATE"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + exclusive + +
    +
    +
    +
    +
    +
    +

    The EXCLUSIVE transaction kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case exclusive = "EXCLUSIVE"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Database/TransactionObservationExtent.html b/docs/5.16/Classes/Database/TransactionObservationExtent.html new file mode 100644 index 000000000..072db12d7 --- /dev/null +++ b/docs/5.16/Classes/Database/TransactionObservationExtent.html @@ -0,0 +1,1208 @@ + + + + TransactionObservationExtent Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionObservationExtent

+
+
+ +
public enum TransactionObservationExtent
+ +
+
+

The extent of a transaction observation

+ +

See Database.add(transactionObserver:extent:)

+ + +
+
+
+
    +
  • +
    + + + + observerLifetime + +
    +
    +
    +
    +
    +
    +

    Observation lasts until observer is deallocated

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case observerLifetime
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + nextTransaction + +
    +
    +
    +
    +
    +
    +

    Observation lasts until the next transaction

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case nextTransaction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseLifetime + +
    +
    +
    +
    +
    +
    +

    Observation lasts until the database is closed

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case databaseLifetime
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabaseCollation.html b/docs/5.16/Classes/DatabaseCollation.html new file mode 100644 index 000000000..75241c576 --- /dev/null +++ b/docs/5.16/Classes/DatabaseCollation.html @@ -0,0 +1,1442 @@ + + + + DatabaseCollation Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseCollation

+
+
+ +
public final class DatabaseCollation
+
extension DatabaseCollation: Hashable
+ +
+
+

A Collation is a string comparison function used by SQLite.

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:function:) + +
    +
    +
    +
    +
    +
    +

    Creates a collation.

    +
    let collation = DatabaseCollation("localized_standard") { (string1, string2) in
    +    return (string1 as NSString).localizedStandardCompare(string2)
    +}
    +db.add(collation: collation)
    +try db.execute(sql: "CREATE TABLE file (name TEXT COLLATE localized_standard")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ name: String, function: @escaping (String, String) -> ComparisonResult)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    The function name.

    +
    +
    + + function + + +
    +

    A function that compares two strings.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQLite Collations +

+
+
+
    +
  • +
    + + + + unicodeCompare + +
    +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in == and <= operators.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.caseInsensitiveCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let unicodeCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in caseInsensitiveCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.caseInsensitiveCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let caseInsensitiveCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in localizedCaseInsensitiveCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.localizedCaseInsensitiveCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let localizedCaseInsensitiveCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedCompare + +
    +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in localizedCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.localizedCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let localizedCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in localizedStandardCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.localizedStandardCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let localizedStandardCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabaseFunction.html b/docs/5.16/Classes/DatabaseFunction.html new file mode 100644 index 000000000..4e29f3ff7 --- /dev/null +++ b/docs/5.16/Classes/DatabaseFunction.html @@ -0,0 +1,1671 @@ + + + + DatabaseFunction Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseFunction

+
+
+ +
public final class DatabaseFunction : Hashable
+ +
+
+

An SQL function or aggregate.

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the SQL function

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var name: String { get }
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates an SQL function.

    + +

    For example:

    +
    let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
    +    guard let int = Int.fromDatabaseValue(dbValues[0]) else {
    +        return nil
    +    }
    +    return int + 1
    +}
    +db.add(function: fn)
    +try Int.fetchOne(db, sql: "SELECT succ(1)")! // 2
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    _ name: String,
    +    argumentCount: Int32? = nil,
    +    pure: Bool = false,
    +    function: @escaping ([DatabaseValue]) throws -> DatabaseValueConvertible?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The function name.

    +
    +
    + + argumentCount + + +
    +

    The number of arguments of the function. If +omitted, or nil, the function accepts any number of arguments.

    +
    +
    + + pure + + +
    +

    Whether the function is “pure”, which means that its results +only depends on its inputs. When a function is pure, SQLite has +the opportunity to perform additional optimizations. Default value +is false.

    +
    +
    + + function + + +
    +

    A function that takes an array of DatabaseValue +arguments, and returns an optional DatabaseValueConvertible such +as Int, String, NSDate, etc. The array is guaranteed to have +exactly argumentCount elements, provided argumentCount is +not nil.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates an SQL aggregate function.

    + +

    For example:

    +
    struct MySum: DatabaseAggregate {
    +    var sum: Int = 0
    +
    +    mutating func step(_ dbValues: [DatabaseValue]) {
    +        if let int = Int.fromDatabaseValue(dbValues[0]) {
    +            sum += int
    +        }
    +    }
    +
    +    func finalize() -> DatabaseValueConvertible? {
    +        return sum
    +    }
    +}
    +
    +let dbQueue = DatabaseQueue()
    +let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
    +try dbQueue.write { db in
    +    db.add(function: fn)
    +    try db.execute(sql: "CREATE TABLE test(i)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (1)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (2)")
    +    try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Aggregate: DatabaseAggregate>(
    +    _ name: String,
    +    argumentCount: Int32? = nil,
    +    pure: Bool = false,
    +    aggregate: Aggregate.Type)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The function name.

    +
    +
    + + argumentCount + + +
    +

    The number of arguments of the aggregate. If +omitted, or nil, the aggregate accepts any number of arguments.

    +
    +
    + + pure + + +
    +

    Whether the aggregate is “pure”, which means that its +results only depends on its inputs. When an aggregate is pure, +SQLite has the opportunity to perform additional optimizations. +Default value is false.

    +
    +
    + + aggregate + + +
    +

    A type that implements the DatabaseAggregate protocol. +For each step of the aggregation, its step method is called with +an array of DatabaseValue arguments. The array is guaranteed to +have exactly argumentCount elements, provided argumentCount is +not nil.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + callAsFunction(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an SQL expression that applies the function.

    + +

    See https://github.com/groue/GRDB.swift/#sql-functions

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func callAsFunction(_ arguments: SQLExpressible...) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQL Functions +

+
+
+
    +
  • +
    + + + + capitalize + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in capitalized +String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +capitalized:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.capitalized)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let capitalize: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lowercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in lowercased +String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +lowercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.lowercased())
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let lowercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + uppercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in uppercased +String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +uppercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.uppercased())
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let uppercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedCapitalize + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in +localizedCapitalized String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +localizedCapitalized:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.localizedCapitalized)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.11, watchOS 3.0, *)
    +public static let localizedCapitalize: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedLowercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in +localizedLowercased String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +localizedLowercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.localizedLowercased)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.11, watchOS 3.0, *)
    +public static let localizedLowercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedUppercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in +localizedUppercased String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +localizedUppercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.localizedUppercased)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.11, watchOS 3.0, *)
    +public static let localizedUppercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabaseFuture.html b/docs/5.16/Classes/DatabaseFuture.html new file mode 100644 index 000000000..e0948222f --- /dev/null +++ b/docs/5.16/Classes/DatabaseFuture.html @@ -0,0 +1,1165 @@ + + + + DatabaseFuture Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseFuture

+
+
+ +
public class DatabaseFuture<Value>
+ +
+
+

A future database value, returned by the DatabaseWriter.concurrentRead(_:) +method.

+
let futureCount: Future<Int> = try writer.writeWithoutTransaction { db in
+    try Player(...).insert()
+
+    // Count players concurrently
+    return writer.concurrentRead { db in
+        return try Player.fetchCount()
+    }
+}
+
+let count: Int = try futureCount.wait()
+
+ + +
+
+
+
    +
  • +
    + + + + wait() + +
    +
    +
    +
    +
    +
    +

    Blocks the current thread until the value is available, and returns it.

    + +

    It is a programmer error to call this method several times.

    +
    +

    Throws

    + Any error that prevented the value from becoming available. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func wait() throws -> Value
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabasePool.html b/docs/5.16/Classes/DatabasePool.html new file mode 100644 index 000000000..d9c4849f0 --- /dev/null +++ b/docs/5.16/Classes/DatabasePool.html @@ -0,0 +1,2016 @@ + + + + DatabasePool Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabasePool

+
+
+ +
public final class DatabasePool : DatabaseWriter
+
extension DatabasePool: DatabaseReader
+ +
+
+

A DatabasePool grants concurrent accesses to an SQLite database.

+ + +
+
+
+
+ + +
+ +

Database Information +

+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + path + +
    +
    +
    +
    +
    +
    +

    The path to the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var path: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Initializer +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Opens the SQLite database at path path.

    +
    let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
    +
    + +

    Database connections get closed when the database pool gets deallocated.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(path: String, configuration: Configuration = Configuration()) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + path + + +
    +

    The path to the database file.

    +
    +
    + + configuration + + +
    +

    A configuration.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Memory management +

+
+
+
    +
  • +
    + + + + releaseMemory() + +
    +
    +
    +
    +
    +
    +

    Free as much memory as possible.

    + +

    This method blocks the current thread until all database accesses +are completed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func releaseMemory()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+
    +
  • +
    + + + + read(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func read<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + asyncRead(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unsafeRead(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + concurrentRead(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes a read-only function in a protected +dispatch queue.

    + +

    This method must be called from a writing dispatch queue, outside of any +transaction. You’ll get a fatal error otherwise.

    + +

    The value function is guaranteed to see the database in the last +committed state at the moment this method is called. Eventual +concurrent database updates are not visible from the function.

    + +

    This method returns as soon as the isolation guarantees described above +are established.

    + +

    In the example below, the number of players is fetched concurrently with +the player insertion. Yet the future is guaranteed to return zero:

    +
    try writer.asyncWriteWithoutTransaction { db in
    +    // Delete all players
    +    try Player.deleteAll()
    +
    +    // Count players concurrently
    +    writer.asyncConcurrentRead { dbResult in
    +        do {
    +            let db = try dbResult.get()
    +            // Guaranteed to be zero
    +            let count = try Player.fetchCount(db)
    +        } catch {
    +            // Handle error
    +        }
    +    }
    +
    +    // Insert a player
    +    try Player(...).insert(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Invalidates open read-only SQLite connections.

    + +

    After this method is called, read-only database access methods will use +new SQLite connections.

    + +

    Eventual concurrent read-only accesses are not invalidated: they will +proceed until completion.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func invalidateReadOnlyConnections()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Writing in Database +

+
+
+
    +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction, and returns the result.

    + +

    If the updates throws an error, the transaction is rollbacked and the +error is rethrown. If the updates return .rollback, the transaction is +also rollbacked, but no error is thrown.

    + +

    Eventual concurrent database updates are postponed until the transaction +has completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    This method is not reentrant.

    +
    try dbPool.writeInTransaction { db in
    +    db.execute(...)
    +    return .commit
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates, or by the +wrapping transaction. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func writeInTransaction(
    +    _ kind: Database.TransactionKind? = nil,
    +    _ updates: (Database) throws -> Database.TransactionCompletion)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the transaction +type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +outside of any transaction.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Snapshots +

+
+
+
    +
  • +
    + + + + makeSnapshot() + +
    +
    +
    +
    +
    +
    +

    Creates a database snapshot.

    + +

    The snapshot sees an unchanging database content, as it existed at the +moment it was created.

    + +

    When you want to control the latest committed changes seen by a +snapshot, create it from the pool’s writer protected dispatch queue:

    +
    let snapshot1 = try dbPool.write { db -> DatabaseSnapshot in
    +    try Player.deleteAll()
    +    return try dbPool.makeSnapshot()
    +}
    +// <- Other threads may modify the database here
    +let snapshot2 = try dbPool.makeSnapshot()
    +
    +try snapshot1.read { db in
    +    // Guaranteed to be zero
    +    try Player.fetchCount(db)
    +}
    +
    +try snapshot2.read { db in
    +    // Could be anything
    +    try Player.fetchCount(db)
    +}
    +
    + +

    It is forbidden to create a snapshot from the writer protected dispatch +queue when a transaction is opened, though, because it is likely a +programmer error:

    +
    try dbPool.write { db in
    +    try db.inTransaction {
    +        try Player.deleteAll()
    +        // fatal error: makeSnapshot() must not be called from inside a transaction
    +        let snapshot = try dbPool.makeSnapshot()
    +        return .commit
    +    }
    +}
    +
    + +

    To avoid this fatal error, create the snapshot before or after the +transaction:

    +
    try dbPool.writeWithoutTransaction { db in
    +    // OK
    +    let snapshot = try dbPool.makeSnapshot()
    +
    +    try db.inTransaction {
    +        try Player.deleteAll()
    +        return .commit
    +    }
    +
    +    // OK
    +    let snapshot = try dbPool.makeSnapshot()
    +}
    +
    + +

    You can create as many snapshots as you need, regardless of the maximum +number of reader connections in the pool.

    + +

    For more information, read about “snapshot isolation” at https://sqlite.org/isolation.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makeSnapshot() throws -> DatabaseSnapshot
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabaseQueue.html b/docs/5.16/Classes/DatabaseQueue.html new file mode 100644 index 000000000..704ea210c --- /dev/null +++ b/docs/5.16/Classes/DatabaseQueue.html @@ -0,0 +1,1904 @@ + + + + DatabaseQueue Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseQueue

+
+
+ +
public final class DatabaseQueue : DatabaseWriter
+ +
+
+

A DatabaseQueue serializes access to an SQLite database.

+ + +
+
+
+
+ + +
+ +

Configuration +

+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + path + +
    +
    +
    +
    +
    +
    +

    The path to the database file; it is “:memory:” for in-memory databases.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var path: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Initializers +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Opens the SQLite database at path path.

    +
    let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
    +
    + +

    Database connections get closed when the database queue gets deallocated.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(path: String, configuration: Configuration = Configuration()) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + path + + +
    +

    The path to the database file.

    +
    +
    + + configuration + + +
    +

    A configuration.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(configuration:) + +
    +
    +
    +
    +
    +
    +

    Opens an in-memory SQLite database.

    +
    let dbQueue = DatabaseQueue()
    +
    + +

    Database memory is released when the database queue gets deallocated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(configuration: Configuration = Configuration())
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + configuration + + +
    +

    A configuration.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Memory management +

+
+
+
    +
  • +
    + + + + releaseMemory() + +
    +
    +
    +
    +
    +
    +

    Free as much memory as possible.

    + +

    This method blocks the current thread until all database accesses are completed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func releaseMemory()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ + +
+ +

Writing in Database +

+
+
+
    +
  • +
    + + + + inTransaction(_:_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction, and returns the result.

    + +

    If the updates throws an error, the transaction is rollbacked and the +error is rethrown. If the updates return .rollback, the transaction is +also rollbacked, but no error is thrown.

    + +

    Eventual concurrent database accesses are postponed until the +transaction has completed.

    + +

    This method is not reentrant.

    +
    try dbQueue.writeInTransaction { db in
    +    db.execute(...)
    +    return .commit
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates, or by the +wrapping transaction. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inTransaction(
    +    _ kind: Database.TransactionKind? = nil,
    +    _ updates: (Database) throws -> Database.TransactionCompletion)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the transaction +type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + inDatabase(_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Eventual concurrent database updates are postponed until the updates +are completed.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +

    This method is not reentrant.

    +
    +

    Throws

    + The error thrown by the updates. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inDatabase<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabaseSnapshot.html b/docs/5.16/Classes/DatabaseSnapshot.html new file mode 100644 index 000000000..847e1126c --- /dev/null +++ b/docs/5.16/Classes/DatabaseSnapshot.html @@ -0,0 +1,1351 @@ + + + + DatabaseSnapshot Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseSnapshot

+
+
+ +
public class DatabaseSnapshot : DatabaseReader
+ +
+
+

A DatabaseSnapshot sees an unchanging database content, as it existed at the +moment it was created.

+ +

See DatabasePool.makeSnapshot()

+ +

For more information, read about “snapshot isolation” at https://sqlite.org/isolation.html

+ + +
+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/DatabaseValueCursor.html b/docs/5.16/Classes/DatabaseValueCursor.html new file mode 100644 index 000000000..a41d876c4 --- /dev/null +++ b/docs/5.16/Classes/DatabaseValueCursor.html @@ -0,0 +1,1153 @@ + + + + DatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseValueCursor

+
+
+ +
public final class DatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
+ +
+
+

A cursor of database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let urls: DatabaseValueCursor<URL> = try URL.fetchCursor(db, sql: "SELECT url FROM link")
+    while let url = urls.next() { // URL
+        print(url)
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Value?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FTS3TableDefinition.html b/docs/5.16/Classes/FTS3TableDefinition.html new file mode 100644 index 000000000..561893e23 --- /dev/null +++ b/docs/5.16/Classes/FTS3TableDefinition.html @@ -0,0 +1,1212 @@ + + + + FTS3TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3TableDefinition

+
+
+ +
public final class FTS3TableDefinition
+ +
+
+

The FTS3TableDefinition class lets you define columns of a FTS3 virtual table.

+ +

You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

+
try db.create(virtualTable: "document", using: FTS3()) { t in // t is FTS3TableDefinition
+    t.column("content")
+}
+
+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FTS4ColumnDefinition.html b/docs/5.16/Classes/FTS4ColumnDefinition.html new file mode 100644 index 000000000..40a3ee99a --- /dev/null +++ b/docs/5.16/Classes/FTS4ColumnDefinition.html @@ -0,0 +1,1209 @@ + + + + FTS4ColumnDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS4ColumnDefinition

+
+
+ +
public final class FTS4ColumnDefinition
+ +
+
+

The FTS4ColumnDefinition class lets you refine a column of an FTS4 +virtual table.

+ +

You get instances of this class when you create an FTS4 table:

+
try db.create(virtualTable: "document", using: FTS4()) { t in
+    t.column("content")      // FTS4ColumnDefinition
+}
+
+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+
    +
  • +
    + + + + notIndexed() + +
    +
    +
    +
    +
    +
    +

    Excludes the column from the full-text index.

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("a")
    +    t.column("b").notIndexed()
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#the_notindexed_option

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func notIndexed() -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + asLanguageId() + +
    +
    +
    +
    +
    +
    +

    Uses the column as the Int32 language id hidden column.

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("a")
    +    t.column("lid").asLanguageId()
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#the_languageid_option

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func asLanguageId() -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FTS4TableDefinition.html b/docs/5.16/Classes/FTS4TableDefinition.html new file mode 100644 index 000000000..53714df43 --- /dev/null +++ b/docs/5.16/Classes/FTS4TableDefinition.html @@ -0,0 +1,1425 @@ + + + + FTS4TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS4TableDefinition

+
+
+ +
public final class FTS4TableDefinition
+ +
+
+

The FTS4TableDefinition class lets you define columns of a FTS4 virtual table.

+ +

You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

+
try db.create(virtualTable: "document", using: FTS4()) { t in // t is FTS4TableDefinition
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FTS5ColumnDefinition.html b/docs/5.16/Classes/FTS5ColumnDefinition.html new file mode 100644 index 000000000..c0b37e9f4 --- /dev/null +++ b/docs/5.16/Classes/FTS5ColumnDefinition.html @@ -0,0 +1,1141 @@ + + + + FTS5ColumnDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5ColumnDefinition

+

The FTS5ColumnDefinition class lets you refine a column of an FTS5 +virtual table.

+ +

You get instances of this class when you create an FTS5 table:

+
try db.create(virtualTable: "document", using: FTS5()) { t in
+    t.column("content")      // FTS5ColumnDefinition
+}
+
+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FTS5TableDefinition.html b/docs/5.16/Classes/FTS5TableDefinition.html new file mode 100644 index 000000000..959554718 --- /dev/null +++ b/docs/5.16/Classes/FTS5TableDefinition.html @@ -0,0 +1,1308 @@ + + + + FTS5TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5TableDefinition

+

The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.

+ +

You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

+
try db.create(virtualTable: "document", using: FTS5()) { t in // t is FTS5TableDefinition
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FastDatabaseValueCursor.html b/docs/5.16/Classes/FastDatabaseValueCursor.html new file mode 100644 index 000000000..014010654 --- /dev/null +++ b/docs/5.16/Classes/FastDatabaseValueCursor.html @@ -0,0 +1,1154 @@ + + + + FastDatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FastDatabaseValueCursor

+
+
+ +
public final class FastDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible, Value : StatementColumnConvertible
+ +
+
+

A cursor of database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let names: ColumnCursor<String> = try String.fetchCursor(db, sql: "SELECT name FROM player")
+    while let name = names.next() { // String
+        print(name)
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public func next() throws -> Value?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/FastNullableDatabaseValueCursor.html b/docs/5.16/Classes/FastNullableDatabaseValueCursor.html new file mode 100644 index 000000000..e20558b2f --- /dev/null +++ b/docs/5.16/Classes/FastNullableDatabaseValueCursor.html @@ -0,0 +1,1156 @@ + + + + FastNullableDatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FastNullableDatabaseValueCursor

+
+
+ +
public final class FastNullableDatabaseValueCursor<Value>: Cursor
+where Value: DatabaseValueConvertible & StatementColumnConvertible
+ +
+
+

A cursor of optional database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let emails: FastNullableDatabaseValueCursor<String> =
+        try Optional<String>.fetchCursor(db, sql: "SELECT email FROM player")
+    while let email = emails.next() { // String?
+        print(email ?? "<NULL>")
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public func next() throws -> Value??
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/NullableDatabaseValueCursor.html b/docs/5.16/Classes/NullableDatabaseValueCursor.html new file mode 100644 index 000000000..95597d2de --- /dev/null +++ b/docs/5.16/Classes/NullableDatabaseValueCursor.html @@ -0,0 +1,1153 @@ + + + + NullableDatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NullableDatabaseValueCursor

+
+
+ +
public final class NullableDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
+ +
+
+

A cursor of optional database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let urls: NullableDatabaseValueCursor<URL> = try Optional<URL>.fetchCursor(db, sql: "SELECT url FROM link")
+    while let url = urls.next() { // URL?
+        print(url)
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Value??
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Record.html b/docs/5.16/Classes/Record.html new file mode 100644 index 000000000..a448dc67d --- /dev/null +++ b/docs/5.16/Classes/Record.html @@ -0,0 +1,1972 @@ + + + + Record Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Record

+
+
+ +
open class Record : FetchableRecord, TableRecord, PersistableRecord
+ +
+
+

Record is a class that wraps a table row, or the result of any query. It is +designed to be subclassed.

+ + +
+
+
+
+ + +
+ +

Initializers +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a Record.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(row:) + +
    +
    +
    +
    +
    +
    +

    Creates a Record from a row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public required init(row: Row)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Core methods +

+
+
+
    +
  • +
    + + + + databaseTableName + +
    +
    +
    +
    +
    +
    +

    The name of a database table.

    + +

    This table name is required by the insert, update, save, delete, +and exists methods.

    +
    class Player : Record {
    +    override class var databaseTableName: String {
    +        return "player"
    +    }
    +}
    +
    + +

    The implementation of the base class Record raises a fatal error.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class var databaseTableName: String { get }
    + +
    +
    +
    +

    Return Value

    +

    The name of a database table.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The policy that handles SQLite conflicts when records are inserted +or updated.

    + +

    This property is optional: its default value uses the ABORT policy +for both insertions and updates, and has GRDB generate regular +INSERT and UPDATE queries.

    + +

    If insertions are resolved with .ignore policy, the +didInsert(with:for:) method is not called upon successful insertion, +even if a row was actually inserted without any conflict.

    + +

    See https://www.sqlite.org/lang_conflict.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class var persistenceConflictPolicy: PersistenceConflictPolicy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseSelection + +
    +
    +
    +
    +
    +
    +

    The default request selection.

    + +

    Unless this method is overriden, requests select all columns:

    +
    // SELECT * FROM player
    +try Player.fetchAll(db)
    +
    + +

    You can override this property and provide an explicit list +of columns:

    +
    class RestrictedPlayer : Record {
    +    override static var databaseSelection: [SQLSelectable] {
    +        return [Column("id"), Column("name")]
    +    }
    +}
    +
    +// SELECT id, name FROM player
    +try RestrictedPlayer.fetchAll(db)
    +
    + +

    You can also add extra columns such as the rowid column:

    +
    class ExtendedPlayer : Player {
    +    override static var databaseSelection: [SQLSelectable] {
    +        return [AllColumns(), Column.rowID]
    +    }
    +}
    +
    +// SELECT *, rowid FROM player
    +try ExtendedPlayer.fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class var databaseSelection: [SQLSelectable] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + encode(to:) + +
    +
    +
    +
    +
    +
    +

    Defines the values persisted in the database.

    + +

    Store in the container argument all values that should be stored in +the columns of the database table (see Record.databaseTableName()).

    + +

    Primary key columns, if any, must be included.

    +
    class Player : Record {
    +    var id: Int64?
    +    var name: String?
    +
    +    override func encode(to container: inout PersistenceContainer) {
    +        container["id"] = id
    +        container["name"] = name
    +    }
    +}
    +
    + +

    The implementation of the base class Record does not store any value in +the container.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func encode(to container: inout PersistenceContainer)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + didInsert(with:for:) + +
    +
    +
    +
    +
    +
    +

    Notifies the record that it was successfully inserted.

    + +

    Do not call this method directly: it is called for you, in a protected +dispatch queue, with the inserted RowID and the eventual +INTEGER PRIMARY KEY column name.

    + +

    The implementation of the base Record class does nothing.

    +
    class Player : Record {
    +    var id: Int64?
    +    var name: String?
    +
    +    func didInsert(with rowID: Int64, for column: String?) {
    +        id = rowID
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func didInsert(with rowID: Int64, for column: String?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + rowID + + +
    +

    The inserted rowID.

    +
    +
    + + column + + +
    +

    The name of the eventual INTEGER PRIMARY KEY column.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Copy +

+
+
+
    +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns a copy of self, initialized from all values encoded in the +encode(to:) method.

    + +

    The eventual primary key is copied, as well as the +hasDatabaseChanges flag.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func copy() -> Self
    + +
    +
    +
    +

    Return Value

    +

    A copy of self.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Compare with Previous Versions +

+
+
+
    +
  • +
    + + + + hasDatabaseChanges + +
    +
    +
    +
    +
    +
    +

    A boolean that indicates whether the record has changes that have not +been saved.

    + +

    This flag is purely informative, and does not prevent insert(), +update(), and save() from performing their database queries.

    + +

    A record is edited if has been changed since last database +synchronization (fetch, update, insert). Comparison +is performed between values (values stored in the encode(to:) +method, and values loaded from the database). Property setters do not +trigger this flag.

    + +

    You can rely on the Record base class to compute this flag for you, or +you may set it to true or false when you know better. Setting it to +false does not prevent it from turning true on subsequent modifications +of the record.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var hasDatabaseChanges: Bool { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseChanges + +
    +
    +
    +
    +
    +
    +

    A dictionary of changes that have not been saved.

    + +

    Its keys are column names, and values the old values that have been +changed since last fetching or saving of the record.

    + +

    Unless the record has actually been fetched or saved, the old values +are nil.

    + +

    See hasDatabaseChanges for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseChanges: [String : DatabaseValue?] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

CRUD +

+
+
+
    +
  • +
    + + + + insert(_:) + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have inserted a row in the database if it +returns without error.

    + +

    Records whose primary key is declared as “INTEGER PRIMARY KEY” have +their id automatically set after successful insertion, if it was nil +before the insertion.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func insert(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + update(_:columns:) + +
    +
    +
    +
    +
    +
    +

    Executes an UPDATE statement.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have updated a row in the database if it +returns without error.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func update(_ db: Database, columns: Set<String>) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + updateChanges(_:) + +
    +
    +
    +
    +
    +
    +

    If the record has been changed, executes an UPDATE statement so that +those changes and only those changes are saved in the database.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have saved the eventual changes in the +database if it returns without error.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public final func updateChanges(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
  • +
    + + + + save(_:) + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    If the record has a non-nil primary key and a matching row in the +database, this method performs an update.

    + +

    Otherwise, performs an insert.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have inserted or updated a row in the +database if it returns without error.

    + +

    You can’t override this method. Instead, override insert(_:) +or update(_:columns:).

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs, or errors +thrown by update(). + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final func save(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete(_:) + +
    +
    +
    +
    +
    +
    +

    Executes a DELETE statement.

    + +

    On success, this method sets the hasDatabaseChanges flag to true.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +open func delete(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/RecordCursor.html b/docs/5.16/Classes/RecordCursor.html new file mode 100644 index 000000000..9721abc1e --- /dev/null +++ b/docs/5.16/Classes/RecordCursor.html @@ -0,0 +1,1150 @@ + + + + RecordCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RecordCursor

+
+
+ +
public final class RecordCursor<Record> : Cursor where Record : FetchableRecord
+ +
+
+

A cursor of records. For example:

+
struct Player : FetchableRecord { ... }
+try dbQueue.read { db in
+    let players: RecordCursor<Player> = try Player.fetchCursor(db, sql: "SELECT * FROM player")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Record?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Row.html b/docs/5.16/Classes/Row.html new file mode 100644 index 000000000..fef1cf046 --- /dev/null +++ b/docs/5.16/Classes/Row.html @@ -0,0 +1,4091 @@ + + + + Row Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Row

+
+
+ +
public final class Row: Equatable, Hashable, RandomAccessCollection,
+                        ExpressibleByDictionaryLiteral, CustomStringConvertible,
+                        CustomDebugStringConvertible
+ +
+
+

A database row.

+ + +
+
+
+
    +
  • +
    + + + + count + +
    +
    +
    +
    +
    +
    +

    The number of columns in the row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let count: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + prefetchedRows + +
    +
    +
    +
    +
    +
    +

    A view on the prefetched associated rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:1 name:"Herman Melville"]
    +
    +let bookRows = row.prefetchedRows["books"]
    +print(bookRows[0])
    +// Prints [id:42 title:"Moby-Dick"]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public internal(set) var prefetchedRows: Row.PrefetchedRowsView { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Building rows +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an empty row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a row from a dictionary of values.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(_ dictionary: [String : DatabaseValueConvertible?])
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a row from [AnyHashable: Any].

    + +

    The result is nil unless all dictionary keys are strings, and values +adopt DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init?(_ dictionary: [AnyHashable : Any])
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a row initialized with elements. Column order is preserved, and +duplicated columns names are allowed.

    +
    let row: Row = ["foo": 1, "foo": "bar", "baz": nil]
    +print(row)
    +// Prints [foo:1 foo:"bar" baz:NULL]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns an immutable copy of the row.

    + +

    For performance reasons, rows fetched from a cursor are reused during +the iteration of a query: make sure to make a copy of it whenever you +want to keep a specific one: row.copy().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func copy() -> Row
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Columns +

+
+
+
    +
  • +
    + + + + columnNames + +
    +
    +
    +
    +
    +
    +

    The names of columns in the row.

    + +

    Columns appear in the same order as they occur as the .0 member +of column-value pairs in self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var columnNames: LazyMapCollection<Row, String> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasColumn(_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if the row has that column.

    + +

    This method is case-insensitive.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasColumn(_ columnName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting Values +

+
+
+
    +
  • +
    + + + + containsNonNullValue + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if one column contains a non-null value, or if +the row was fetched with a row adapter that defines a scoped row that +contains a non-null value.

    + +

    For example:

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'foo', 1")!
    +row.containsNonNullValue // true
    +
    +let row = try Row.fetchOne(db, sql: "SELECT NULL, NULL")!
    +row.containsNonNullValue // false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var containsNonNullValue: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasNull(atIndex:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the row contains null at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    This method is equivalent to row[index] == nil, but may be preferred +in performance-critical code because it can avoid decoding database +values.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasNull(atIndex index: Int) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, Data or nil, depending on the value +stored at the given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(index: Int) -> DatabaseValueConvertible? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    If the SQLite value is NULL, the result is nil. Otherwise the SQLite +value is converted to the requested type Value. Should this conversion +fail, a fatal error is raised.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(index: Int) -> Value? where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    If the SQLite value is NULL, the result is nil. Otherwise the SQLite +value is converted to the requested type Value. Should this conversion +fail, a fatal error is raised.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public subscript<Value>(index: Int) -> Value? where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(index: Int) -> Value where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public subscript<Value>(index: Int) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, Data or nil, depending on the value +stored at the given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    The result is nil if the row does not contain the column.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(columnName: String) -> DatabaseValueConvertible? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value? where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value? where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, NSData or nil, depending on the value +stored at the given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    The result is nil if the row does not contain the column.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Column>(column: Column) -> DatabaseValueConvertible? where Column : ColumnExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(column: Column) -> Value? where Value : DatabaseValueConvertible, Column : ColumnExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(_ column: Column)
    +-> Value?
    +where
    +    Value: DatabaseValueConvertible & StatementColumnConvertible,
    +    Column: ColumnExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(column: Column) -> Value where Value : DatabaseValueConvertible, Column : ColumnExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(_ column: Column)
    +-> Value
    +where
    +    Value: DatabaseValueConvertible & StatementColumnConvertible,
    +    Column: ColumnExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + dataNoCopy(atIndex:) + +
    +
    +
    +
    +
    +
    +

    Returns the optional Data at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    If the SQLite value is NULL, the result is nil. If the SQLite value can +not be converted to Data, a fatal error is raised.

    + +

    The returned data does not owns its bytes: it must not be used longer +than the row’s lifetime.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dataNoCopy(atIndex index: Int) -> Data?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + dataNoCopy(named:) + +
    +
    +
    +
    +
    +
    +

    Returns the optional Data at given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. If the SQLite value can not be converted to Data, a fatal error +is raised.

    + +

    The returned data does not owns its bytes: it must not be used longer +than the row’s lifetime.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dataNoCopy(named columnName: String) -> Data?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + dataNoCopy(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the optional NSData at given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. If the SQLite value can not be converted to NSData, a fatal error +is raised.

    + +

    The returned data does not owns its bytes: it must not be used longer +than the row’s lifetime.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dataNoCopy<Column>(_ column: Column) -> Data? where Column : ColumnExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting DatabaseValue +

+
+
+
    +
  • +
    + + + + databaseValues + +
    +
    +
    +
    +
    +
    +

    The database values in the row.

    + +

    Values appear in the same order as they occur as the .1 member +of column-value pairs in self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValues: LazyMapCollection<Row, DatabaseValue> { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting Records +

+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the record associated with the given scope.

    + +

    For example:

    +
    let request = Book.including(required: Book.author)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let author: Author = row["author"]
    +print(author.name)
    +// Prints "Herman Melville"
    +
    + +

    Associated records stored in nested associations are available, too:

    +
    let request = Book.including(required: Book.author.including(required: Author.country))
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let country: Country = row["country"]
    +print(country.name)
    +// Prints "United States"
    +
    + +

    A fatal error is raised if the scope is not available, or contains only +null values.

    + +

    See https://github.com/groue/GRDB.swift/blob/master/README.md#joined-queries-support +for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Record>(scope: String) -> Record where Record : FetchableRecord { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the eventual record associated with the given scope.

    + +

    For example:

    +
    let request = Book.including(optional: Book.author)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let author: Author? = row["author"]
    +print(author.name)
    +// Prints "Herman Melville"
    +
    + +

    Associated records stored in nested associations are available, too:

    +
    let request = Book.including(optional: Book.author.including(optional: Author.country))
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let country: Country? = row["country"]
    +print(country.name)
    +// Prints "United States"
    +
    + +

    Nil is returned if the scope is not available, or contains only +null values.

    + +

    See https://github.com/groue/GRDB.swift/blob/master/README.md#joined-queries-support +for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Record>(scope: String) -> Record? where Record : FetchableRecord { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the records encoded in the given prefetched rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Author(row: row).name)
    +// Prints "Herman Melville"
    +
    +let books: [Book] = row["books"]
    +print(books[0].title)
    +// Prints "Moby-Dick"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Collection>(_ key: String)
    +-> Collection
    +where
    +    Collection: RangeReplaceableCollection,
    +    Collection.Element: FetchableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the set of records encoded in the given prefetched rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Author(row: row).name)
    +// Prints "Herman Melville"
    +
    +let books: Set<Book> = row["books"]
    +print(books.first!.title)
    +// Prints "Moby-Dick"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Record>(key: String) -> Set<Record> where Record : FetchableRecord, Record : Hashable { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Scopes +

+
+
+
    +
  • +
    + + + + scopes + +
    +
    +
    +
    +
    +
    +

    Returns a view on the scopes defined by row adapters.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopes.count  // 2
    +row.scopes.names  // ["foo", "bar"]
    +
    +row.scopes["foo"] // [foo:1]
    +row.scopes["bar"] // [bar:2]
    +row.scopes["baz"] // nil
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var scopes: ScopesView { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + scopesTree + +
    +
    +
    +
    +
    +
    +

    Returns a view on the scopes tree defined by row adapters.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopesTree.names  // ["foo", "bar", "baz"]
    +
    +row.scopesTree["foo"] // [foo:1]
    +row.scopesTree["bar"] // [bar:2]
    +row.scopesTree["baz"] // [baz:3]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var scopesTree: ScopesTreeView { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unscoped + +
    +
    +
    +
    +
    +
    +

    Returns a copy of the row, without any scopes.

    + +

    This property can turn out useful when you want to test the content of +adapted rows, such as rows fetched from joined requests.

    +
    let row = ...
    +// Failure because row equality tests for row scopes:
    +XCTAssertEqual(row, ["id": 1, "name": "foo"])
    +// Success:
    +XCTAssertEqual(row.unscoped, ["id": 1, "name": "foo"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var unscoped: Row { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unadapted + +
    +
    +
    +
    +
    +
    +

    Return the raw row fetched from the database.

    + +

    This property can turn out useful when you debug the consumption of +adapted rows, such as rows fetched from joined requests.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var unadapted: Row { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over rows fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let rows = try Row.fetchCursor(statement) // RowCursor
    +while let row = try rows.next() { // Row
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of rows fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let rows = try Row.fetchAll(statement)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a set of rows fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let rows = try Row.fetchSet(statement)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a single row fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let row = try Row.fetchOne(statement)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over rows fetched from an SQL query.

    +
    let rows = try Row.fetchCursor(db, sql: "SELECT id, name FROM player") // RowCursor
    +while let row = try rows.next() { // Row
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of rows fetched from an SQL query.

    +
    let rows = try Row.fetchAll(db, sql: "SELECT id, name FROM player") // [Row]
    +for row in rows {
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a set of rows fetched from an SQL query.

    +
    let rows = try Row.fetchSet(db, sql: "SELECT id, name FROM player") // Set<Row>
    +for row in rows {
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a single row fetched from an SQL query.

    +
    let row = try Row.fetchOne(db, sql: "SELECT id, name FROM player") // Row?
    +if let row = row {
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over rows fetched from a fetch request.

    +
    let request = Player.all()
    +let rows = try Row.fetchCursor(db, request) // RowCursor
    +while let row = try rows.next() { // Row
    +    let id: Int64 = row["id"]
    +    let name: String = row["name"]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R>(_ db: Database, _ request: R) throws -> RowCursor where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an array of rows fetched from a fetch request.

    +
    let request = Player.all()
    +let rows = try Row.fetchAll(db, request)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Row] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a set of rows fetched from a fetch request.

    +
    let request = Player.all()
    +let rows = try Row.fetchSet(db, request)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Row> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a single row fetched from a fetch request.

    +
    let request = Player.filter(key: 1)
    +let row = try Row.fetchOne(db, request)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Row? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row as a Collection of (ColumnName, DatabaseValue) Pairs +

+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Accesses the (ColumnName, DatabaseValue) pair at given index.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(position: RowIndex) -> (String, DatabaseValue) { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row.ScopesView +

+
+
+
    +
  • +
    + + + + ScopesView + +
    +
    +
    +
    +
    +
    +

    A view of the scopes defined by row adapters. It is a collection of +tuples made of a scope name and a scoped row, which behaves like a +dictionary.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopes.count  // 2
    +row.scopes.names  // ["foo", "bar"]
    +
    +row.scopes["foo"] // [foo:1]
    +row.scopes["bar"] // [bar:2]
    +row.scopes["baz"] // nil
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ScopesView : Collection
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row.ScopesTreeView +

+
+
+
    +
  • +
    + + + + ScopesTreeView + +
    +
    +
    +
    +
    +
    +

    A view on the scopes tree defined by row adapters.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopesTree.names  // ["foo", "bar", "baz"]
    +
    +row.scopesTree["foo"] // [foo:1]
    +row.scopesTree["bar"] // [bar:2]
    +row.scopesTree["baz"] // [baz:3]
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ScopesTreeView
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row.PrefetchedRowsView +

+
+
+
    +
  • +
    + + + + PrefetchedRowsView + +
    +
    +
    +
    +
    +
    +

    A view on the prefetched associated rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:1 name:"Herman Melville"]
    +
    +let bookRows = row.prefetchedRows["books"]
    +print(bookRows[0])
    +// Prints [id:42 title:"Moby-Dick"]
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PrefetchedRowsView : Equatable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Row/PrefetchedRowsView.html b/docs/5.16/Classes/Row/PrefetchedRowsView.html new file mode 100644 index 000000000..7794d79cb --- /dev/null +++ b/docs/5.16/Classes/Row/PrefetchedRowsView.html @@ -0,0 +1,1243 @@ + + + + PrefetchedRowsView Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PrefetchedRowsView

+
+
+ +
public struct PrefetchedRowsView : Equatable
+ +
+
+

A view on the prefetched associated rows.

+ +

For example:

+
let request = Author.including(all: Author.books)
+let row = try Row.fetchOne(db, request)!
+
+print(row)
+// Prints [id:1 name:"Herman Melville"]
+
+let bookRows = row.prefetchedRows["books"]
+print(bookRows[0])
+// Prints [id:42 title:"Moby-Dick"]
+
+ + +
+
+
+
    +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    True if there is no prefetched associated rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + keys + +
    +
    +
    +
    +
    +
    +

    The keys for available prefetched rows

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row.prefetchedRows.keys)
    +// Prints ["books"]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var keys: Set<String> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the prefetched rows associated with the given key.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:1 name:"Herman Melville"]
    +
    +let bookRows = row.prefetchedRows["books"]
    +print(bookRows[0])
    +// Prints [id:42 title:"Moby-Dick"]
    +
    + +

    Prefetched rows stored in nested “to-one” associations are +available, too.

    + +

    Nil is returned if the key is not available.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(key: String) -> [Row]? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Row/ScopesTreeView.html b/docs/5.16/Classes/Row/ScopesTreeView.html new file mode 100644 index 000000000..ecaa91dc5 --- /dev/null +++ b/docs/5.16/Classes/Row/ScopesTreeView.html @@ -0,0 +1,1220 @@ + + + + ScopesTreeView Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ScopesTreeView

+
+
+ +
public struct ScopesTreeView
+ +
+
+

A view on the scopes tree defined by row adapters.

+ +

For example:

+
// Define a tree of nested scopes
+let adapter = ScopeAdapter([
+    "foo": RangeRowAdapter(0..<1),
+    "bar": RangeRowAdapter(1..<2).addingScopes([
+        "baz" : RangeRowAdapter(2..<3)])])
+
+// Fetch
+let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
+let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+
+row.scopesTree.names  // ["foo", "bar", "baz"]
+
+row.scopesTree["foo"] // [foo:1]
+row.scopesTree["bar"] // [bar:2]
+row.scopesTree["baz"] // [baz:3]
+
+ + +
+
+
+
    +
  • +
    + + + + names + +
    +
    +
    +
    +
    +
    +

    The scopes defined on this row, recursively.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var names: Set<String> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the row associated with the given scope.

    + +

    For example:

    +
    let request = Book.including(required: Book.author)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:42 title:"Moby-Dick"]
    +
    +let authorRow = row.scopesTree["author"]
    +print(authorRow)
    +// Prints [id:1 name:"Herman Melville"]
    +
    + +

    Associated rows stored in nested associations are available, too:

    +
    let request = Book.including(required: Book.author.including(required: Author.country))
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:42 title:"Moby-Dick"]
    +
    +let countryRow = row.scopesTree["country"]
    +print(countryRow)
    +// Prints [code:"US" name:"United States"]
    +
    + +

    Nil is returned if the scope is not available.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(name: String) -> Row? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Row/ScopesView.html b/docs/5.16/Classes/Row/ScopesView.html new file mode 100644 index 000000000..858f211f9 --- /dev/null +++ b/docs/5.16/Classes/Row/ScopesView.html @@ -0,0 +1,1227 @@ + + + + ScopesView Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ScopesView

+
+
+ +
public struct ScopesView : Collection
+ +
+
+

A view of the scopes defined by row adapters. It is a collection of +tuples made of a scope name and a scoped row, which behaves like a +dictionary.

+ +

For example:

+
// Define a tree of nested scopes
+let adapter = ScopeAdapter([
+    "foo": RangeRowAdapter(0..<1),
+    "bar": RangeRowAdapter(1..<2).addingScopes([
+        "baz" : RangeRowAdapter(2..<3)])])
+
+// Fetch
+let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
+let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+
+row.scopes.count  // 2
+row.scopes.names  // ["foo", "bar"]
+
+row.scopes["foo"] // [foo:1]
+row.scopes["bar"] // [bar:2]
+row.scopes["baz"] // nil
+
+ + +
+
+
+
    +
  • +
    + + + + Index + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias Index = Dictionary<String, _LayoutedRowAdapter>.Index
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + names + +
    +
    +
    +
    +
    +
    +

    The scopes defined on this row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var names: Dictionary<String, _LayoutedRowAdapter>.Keys { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the row associated with the given scope, or nil if the +scope is not defined.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(name: String) -> Row? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/RowCursor.html b/docs/5.16/Classes/RowCursor.html new file mode 100644 index 000000000..6ee3db231 --- /dev/null +++ b/docs/5.16/Classes/RowCursor.html @@ -0,0 +1,1179 @@ + + + + RowCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RowCursor

+
+
+ +
public final class RowCursor : Cursor
+ +
+
+

A cursor of database rows. For example:

+
try dbQueue.read { db in
+    let rows: RowCursor = try Row.fetchCursor(db, sql: "SELECT * FROM player")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + statement + +
    +
    +
    +
    +
    +
    +

    The statement iterated by this cursor

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let statement: Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Row?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/SQLStatementCursor.html b/docs/5.16/Classes/SQLStatementCursor.html new file mode 100644 index 000000000..08f6c7519 --- /dev/null +++ b/docs/5.16/Classes/SQLStatementCursor.html @@ -0,0 +1,1145 @@ + + + + SQLStatementCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLStatementCursor

+
+
+ +
public class SQLStatementCursor : Cursor
+ +
+
+

Undocumented

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/SharedValueObservation.html b/docs/5.16/Classes/SharedValueObservation.html new file mode 100644 index 000000000..1df3f12ab --- /dev/null +++ b/docs/5.16/Classes/SharedValueObservation.html @@ -0,0 +1,1275 @@ + + + + SharedValueObservation Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SharedValueObservation

+
+
+ +
public final class SharedValueObservation<Element>
+ +
+
+

Experimental

+ +

A shared value observation that shares a single underlying database +observation for all subscriptions, and thus spares database resources.

+ +

For example:

+
let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue)
+
+let cancellable = try sharedObservation.start(
+    onError: { error in ... },
+    onChange: { players: [Player] in
+        print("Players have changed.")
+    })
+
+ +

The sharing only applies if you start observing the database from the +same SharedValueObservation instance:

+
// NOT shared
+let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+
+// Shared
+let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
+let cancellable1 = sharedObservation.start(...)
+let cancellable2 = sharedObservation.start(...)
+
+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Starts observing the database.

    + +

    The observation lasts until the returned cancellable is cancelled +or deallocated.

    + +

    For example:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +
    +let cancellable = try sharedObservation.start(
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func start(
    +    onError: @escaping (Error) -> Void,
    +    onChange: @escaping (Element) -> Void)
    +-> DatabaseCancellable
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + onError + + +
    +

    A closure that is provided eventual errors that +happen during observation

    +
    +
    + + onChange + + +
    +

    A closure that is provided fresh values

    +
    +
    +
    +
    +

    Return Value

    +

    a DatabaseCancellable

    +
    + +
    +
    +
  • +
  • +
    + + + + publisher() + +
    +
    +
    +
    +
    +
    +

    Creates a publisher which tracks changes in database values.

    + +

    For example:

    +
    let publisher = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +    .publisher()
    +
    +let cancellable = publisher.sink(
    +    receiveCompletion: { completion in ... },
    +    receiveValue: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func publisher() -> DatabasePublishers.Value<Element>
    + +
    +
    +
    +

    Return Value

    +

    A Combine publisher

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/Statement.html b/docs/5.16/Classes/Statement.html new file mode 100644 index 000000000..7bb14fe31 --- /dev/null +++ b/docs/5.16/Classes/Statement.html @@ -0,0 +1,1622 @@ + + + + Statement Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Statement

+
+
+ +
public final class Statement
+
extension Statement: _RowLayout
+
extension Statement: CustomStringConvertible
+ +
+
+

A statement represents an SQL query.

+ + +
+
+
+
    +
  • +
    + + + + sqliteStatement + +
    +
    +
    +
    +
    +
    +

    The raw SQLite statement, suitable for the SQLite C API.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let sqliteStatement: SQLiteStatement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sql + +
    +
    +
    +
    +
    +
    +

    The SQL query

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sql: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + columnNames + +
    +
    +
    +
    +
    +
    +

    The column names, ordered from left to right.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public lazy var columnNames: [String] { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseRegion + +
    +
    +
    +
    +
    +
    +

    The database region that the statement looks into.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public internal(set) var databaseRegion: DatabaseRegion { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isReadonly + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if the prepared statement makes no direct +changes to the content of the database file.

    + +

    See https://www.sqlite.org/c3ref/stmt_readonly.html.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isReadonly: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Arguments +

+
+
+
    +
  • +
    + + + + arguments + +
    +
    +
    +
    +
    +
    +

    The statement arguments.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var arguments: StatementArguments { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + validateArguments(_:) + +
    +
    +
    +
    +
    +
    +

    Throws a DatabaseError of code SQLITE_ERROR if arguments don’t fill all +statement arguments.

    + +

    For example:

    +
    let statement = try db.makeUpdateArgument(sql: """
    +    INSERT INTO player (id, name) VALUES (?, ?)
    +    """)
    +
    +// OK
    +statement.validateArguments([1, "Arthur"])
    +
    +// Throws
    +statement.validateArguments([1])
    +
    + +

    See also setArguments(_:)

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func validateArguments(_ arguments: StatementArguments) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Set arguments without any validation. Trades safety for performance.

    + +

    Only call this method if you are sure input arguments match all expected +arguments of the statement.

    + +

    For example:

    +
    let statement = try db.makeUpdateArgument(sql: """
    +    INSERT INTO player (id, name) VALUES (?, ?)
    +    """)
    +
    +// OK
    +statement.setUncheckedArguments([1, "Arthur"])
    +
    +// OK
    +let arguments: StatementArguments = ... // some untrusted arguments
    +try statement.validateArguments(arguments)
    +statement.setUncheckedArguments(arguments)
    +
    +// NOT OK
    +statement.setUncheckedArguments([1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func setUncheckedArguments(_ arguments: StatementArguments)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + setArguments(_:) + +
    +
    +
    +
    +
    +
    +

    Set the statement arguments, or throws a DatabaseError of code +SQLITE_ERROR if arguments don’t fill all statement arguments.

    + +

    For example:

    +
    let statement = try db.makeUpdateArgument(sql: """
    +    INSERT INTO player (id, name) VALUES (?, ?)
    +    """)
    +
    +// OK
    +try statement.setArguments([1, "Arthur"])
    +
    +// Throws an error
    +try statement.setArguments([1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func setArguments(_ arguments: StatementArguments) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + description + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var description: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Select Statements +

+
+
+
    +
  • +
    + + + + columnCount + +
    +
    +
    +
    +
    +
    +

    The number of columns in the resulting rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var columnCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + index(ofColumn:) + +
    +
    +
    +
    +
    +
    +

    Returns the index of the leftmost column named name, in a +case-insensitive way.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func index(ofColumn name: String) -> Int?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Update Statements +

+
+
+
    +
  • +
    + + + + execute(arguments:) + +
    +
    +
    +
    +
    +
    +

    Executes the prepared statement.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func execute(arguments: StatementArguments? = nil) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/TableAlias.html b/docs/5.16/Classes/TableAlias.html new file mode 100644 index 000000000..8c45814c9 --- /dev/null +++ b/docs/5.16/Classes/TableAlias.html @@ -0,0 +1,1341 @@ + + + + TableAlias Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableAlias

+
+
+ +
public class TableAlias : Hashable
+ +
+
+

Experimental

+ +

A TableAlias identifies a table in a request.

+ + +
+
+
+
    +
  • +
    + + + + init(name:) + +
    +
    +
    +
    +
    +
    +

    Creates a TableAlias, suitable for qualifying requests or associations.

    + +

    For example:

    +
    // The request for all books published after their author has died
    +//
    +// SELECT book.*
    +// FROM book
    +// JOIN author ON author.id = book.authorId
    +// WHERE book.publishDate >= author.deathDate
    +let authorAlias = TableAlias()
    +let request = Book
    +    .joining(required: Book.author.aliased(authorAlias))
    +    .filter(Column("publishDate") >= authorAlias[Column("deathDate")])
    +
    + +

    When the alias is given a name, this name is guaranteed to be used as +the table alias in the SQL query:

    +
    // SELECT book.*
    +// FROM book
    +// JOIN author a ON a.id = book.authorId
    +// WHERE book.publishDate >= a.deathDate
    +let authorAlias = TableAlias(name: "a")
    +let request = Book
    +    .joining(required: Book.author.aliased(authorAlias))
    +    .filter(Column("publishDate") >= authorAlias[Column("deathDate")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(name: String? = nil)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified value that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(selectable: SQLSelectable) -> SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified expression that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(expression: SQLSpecificExpressible & SQLSelectable & SQLOrderingTerm) -> SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified ordering that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(ordering: SQLOrderingTerm) -> SQLOrdering { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified columnn that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(column: String) -> SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + exists + +
    +
    +
    +
    +
    +
    +

    Experimental

    + +

    An expression that evaluates to true if the record refered by this +TableAlias exists.

    + +

    For example, here is how filter books and only keep those that are not +associated to any author:

    +
    let books: [Book] = try dbQueue.read { db in
    +    let authorAlias = TableAlias()
    +    let request = Book
    +        .joining(optional: Book.author.aliased(authorAlias))
    +        .filter(!authorAlias.exists)
    +    return try request.fetchAll(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var exists: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/TableAlteration.html b/docs/5.16/Classes/TableAlteration.html new file mode 100644 index 000000000..bbec2f4ec --- /dev/null +++ b/docs/5.16/Classes/TableAlteration.html @@ -0,0 +1,1365 @@ + + + + TableAlteration Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableAlteration

+
+
+ +
public final class TableAlteration
+ +
+
+

The TableAlteration class lets you alter database tables.

+ +

You don’t create instances of this class. Instead, you use the Database +alter(table:) method:

+
try db.alter(table: "player") { t in // t is TableAlteration
+    t.add(column: ...)
+}
+
+ +

See https://www.sqlite.org/lang_altertable.html

+ + +
+
+
+
    +
  • +
    + + + + add(column:_:) + +
    +
    +
    +
    +
    +
    +

    Appends a column to the table.

    +
    try db.alter(table: "player") { t in
    +    t.add(column: "url", .text)
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func add(column name: String, _ type: Database.ColumnType? = nil) -> ColumnDefinition
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    the column name.

    +
    +
    + + type + + +
    +

    the column type.

    +
    +
    +
    +
    +

    Return Value

    +

    An ColumnDefinition that allows you to refine the +column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + addColumn(sql:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with raw SQL.

    +
    // ALTER TABLE player ADD COLUMN name TEXT
    +try db.alter(table: "player") { t in
    +    t.addColumn(sql: "name TEXT")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func addColumn(sql: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + addColumn(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // ALTER TABLE player ADD COLUMN name TEXT DEFAULT 'Anonymous'
    +let defaultName = "Anonymous"
    +try db.alter(table: "player") { t in
    +    t.addColumn(literal: "name TEXT DEFAULT \(defaultName)")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func addColumn(literal: SQL)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rename(column:to:) + +
    +
    +
    +
    +
    +
    +

    Renames a column in a table.

    +
    try db.alter(table: "player") { t in
    +    t.rename(column: "url", to: "homeURL")
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + +
    +
    +
    +
  • +
  • +
    + + + + rename(column:to:) + +
    +
    +
    +
    +
    +
    +

    Renames a column in a table.

    +
    try db.alter(table: "player") { t in
    +    t.rename(column: "url", to: "homeURL")
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    +public func rename(column name: String, to newName: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    the column name to rename.

    +
    +
    + + newName + + +
    +

    the new name of the column.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/TableDefinition.html b/docs/5.16/Classes/TableDefinition.html new file mode 100644 index 000000000..22ce124b0 --- /dev/null +++ b/docs/5.16/Classes/TableDefinition.html @@ -0,0 +1,1819 @@ + + + + TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableDefinition

+
+
+ +
public final class TableDefinition
+ +
+
+

The TableDefinition class lets you define table columns and constraints.

+ +

You don’t create instances of this class. Instead, you use the Database +create(table:) method:

+
try db.create(table: "player") { t in // t is TableDefinition
+    t.column(...)
+}
+
+ +

See https://www.sqlite.org/lang_createtable.html

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Defines the auto-incremented primary key.

    +
    try db.create(table: "player") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +}
    +
    + +

    The auto-incremented primary key is an integer primary key that +automatically generates unused values when you do not explicitly +provide one, and prevents the reuse of ids over the lifetime of +the database.

    + +

    It is the preferred way to define a numeric primary key.

    + +

    The fact that an auto-incremented primary key prevents the reuse of +ids is an excellent guard against data races that could happen when your +application processes ids in an asynchronous way. The auto-incremented +primary key provides the guarantee that a given id can’t reference a row +that is different from the one it used to be at the beginning of the +asynchronous process, even if this row gets deleted and a new one is +inserted in between.

    + +

    See https://www.sqlite.org/lang_createtable.html#primkeyconst and +https://www.sqlite.org/lang_createtable.html#rowid

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func autoIncrementedPrimaryKey(
    +    _ name: String,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil)
    +-> ColumnDefinition
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + column(_:_:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text)
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#tablecoldef

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func column(_ name: String, _ type: Database.ColumnType? = nil) -> ColumnDefinition
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    the column name.

    +
    +
    + + type + + +
    +

    the eventual column type.

    +
    +
    +
    +
    +

    Return Value

    +

    An ColumnDefinition that allows you to refine the +column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + column(sql:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with raw SQL.

    +
    try db.create(table: "player") { t in
    +    t.column(sql: "name TEXT")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func column(sql: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + column(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // CREATE TABLE player (
    +//   name TEXT DEFAULT 'Anonymous'
    +// )
    +let defaultName = "Anonymous"
    +try db.create(table: "player") { t in
    +    t.column(literal: "name TEXT DEFAULT \(defaultName)")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func column(literal: SQL)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Defines the table primary key.

    +
    try db.create(table: "citizenship") { t in
    +    t.column("citizenID", .integer)
    +    t.column("countryCode", .text)
    +    t.primaryKey(["citizenID", "countryCode"])
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#primkeyconst and +https://www.sqlite.org/lang_createtable.html#rowid

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func primaryKey(_ columns: [String], onConflict conflictResolution: Database.ConflictResolution? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + columns + + +
    +

    The primary key columns.

    +
    +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Adds a unique key.

    +
    try db.create(table: "place") { t in
    +    t.column("latitude", .double)
    +    t.column("longitude", .double)
    +    t.uniqueKey(["latitude", "longitude"])
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#uniqueconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func uniqueKey(_ columns: [String], onConflict conflictResolution: Database.ConflictResolution? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + columns + + +
    +

    The unique key columns.

    +
    +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Adds a foreign key.

    +
    try db.create(table: "passport") { t in
    +    t.column("issueDate", .date)
    +    t.column("citizenID", .integer)
    +    t.column("countryCode", .text)
    +    t.foreignKey(["citizenID", "countryCode"], references: "citizenship", onDelete: .cascade)
    +}
    +
    + +

    See https://www.sqlite.org/foreignkeys.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKey(
    +    _ columns: [String],
    +    references table: String,
    +    columns destinationColumns: [String]? = nil,
    +    onDelete deleteAction: Database.ForeignKeyAction? = nil,
    +    onUpdate updateAction: Database.ForeignKeyAction? = nil,
    +    deferred: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + columns + + +
    +

    The foreign key columns.

    +
    +
    + + table + + +
    +

    The referenced table.

    +
    +
    + + destinationColumns + + +
    +

    The columns in the referenced table. If not +specified, the columns of the primary key of the referenced table +are used.

    +
    +
    + + deleteAction + + +
    +

    Optional action when the referenced row is deleted.

    +
    +
    + + updateAction + + +
    +

    Optional action when the referenced row is updated.

    +
    +
    + + deferred + + +
    +

    If true, defines a deferred foreign key constraint. +See https://www.sqlite.org/foreignkeys.html#fk_deferred.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + check(_:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint.

    +
    try db.create(table: "player") { t in
    +    t.column("personalPhone", .text)
    +    t.column("workPhone", .text)
    +    let personalPhone = Column("personalPhone")
    +    let workPhone = Column("workPhone")
    +    t.check(personalPhone != nil || workPhone != nil)
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func check(_ condition: SQLExpressible)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + condition + + +
    +

    The checked condition

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + check(sql:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint.

    +
    try db.create(table: "player") { t in
    +    t.column("personalPhone", .text)
    +    t.column("workPhone", .text)
    +    t.check(sql: "personalPhone IS NOT NULL OR workPhone IS NOT NULL")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func check(sql: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL snippet

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + constraint(sql:) + +
    +
    +
    +
    +
    +
    +

    Appends a table constraint defined with raw SQL.

    +
    // CREATE TABLE player (
    +//   ...
    +//   CHECK (score >= 0)
    +// )
    +try db.create(table: "player") { t in
    +    ...
    +    t.constraint(sql: "CHECK (score >= 0)")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func constraint(sql: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + constraint(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends a table constraint defined with an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // CREATE TABLE player (
    +//   ...
    +//   CHECK (score >= 0)
    +// )
    +let minScore = 0
    +try db.create(table: "player") { t in
    +    ...
    +    t.constraint(literal: "CHECK (score >= \(minScore))")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func constraint(literal: SQL)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Classes/ValueObservationScheduler.html b/docs/5.16/Classes/ValueObservationScheduler.html new file mode 100644 index 000000000..e85752437 --- /dev/null +++ b/docs/5.16/Classes/ValueObservationScheduler.html @@ -0,0 +1,1214 @@ + + + + ValueObservationScheduler Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ValueObservationScheduler

+
+
+ +
public class ValueObservationScheduler
+ +
+
+

ValueObservationScheduler determines how ValueObservation notifies its +fresh values.

+ + +
+
+
+
    +
  • +
    + + + + async(onQueue:) + +
    +
    +
    +
    +
    +
    +

    A scheduler which asynchronously notifies fresh value of the +given DispatchQueue.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    scheduling: .async(onQueue: .main),
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func async(onQueue queue: DispatchQueue) -> ValueObservationScheduler
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + immediate + +
    +
    +
    +
    +
    +
    +

    A scheduler which notifies all values on the main queue. The first one +is immediately notified when the start() method is called.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    scheduling: .immediate,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +// <- here "fresh players" is already printed.
    +
    +
    +

    Important

    + this scheduler requires that the observation is started +from the main queue. A fatal error is raised otherwise. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let immediate: ValueObservationScheduler
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums.html b/docs/5.16/Enums.html new file mode 100644 index 000000000..8e885dbde --- /dev/null +++ b/docs/5.16/Enums.html @@ -0,0 +1,1598 @@ + + + + Enumerations Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Enumerations

+

The following enumerations are available globally.

+ +
+
+
+
    +
  • +
    + + + + DatabasePublishers + +
    +
    +
    +
    +
    +
    +

    A namespace for database Combine publishers.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public enum DatabasePublishers
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database events +

+
+
+ +
+
+
+ + +
+ +

Date functions +

+
+
+ +
+
+
+ + +
+ +

DatabaseDateEncodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseDateEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their Date properties.

    + +

    For example:

    +
    struct Player: EncodableRecord, Encodable {
    +    static let databaseDateEncodingStrategy = DatabaseDateEncodingStrategy.timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // encoded as an epoch timestamp
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseDateEncodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseUUIDEncodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their UUID properties.

    + +

    For example:

    +
    struct Player: EncodableProtocol, Encodable {
    +    static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
    +
    +    // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
    +    var uuid: UUID
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseUUIDEncodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseColumnEncodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseColumnEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their coding keys into +database columns.

    + +

    For example:

    +
    struct Player: EncodableProtocol, Encodable {
    +    static let databaseColumnEncodingStrategy = DatabaseColumnEncodingStrategy.convertToSnakeCase
    +
    +    // Encoded in the player_id column
    +    var playerID: String
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseColumnEncodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseDateDecodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseDateDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol decode their +Date properties.

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseDateDecodingStrategy = DatabaseDateDecodingStrategy.timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // decoded from epoch timestamp
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseDateDecodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseColumnDecodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseColumnDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol look for the database colums +that match their coding keys.

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase
    +
    +    // Decoded from the player_id column
    +    var playerID: Int
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseColumnDecodingStrategy
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + PersistenceError + +
    +
    +
    +
    +
    +
    +

    An error thrown by a type that adopts MutablePersistableRecord.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum PersistenceError : Error, CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Controls the extent of the shared database observation +of SharedValueObservation.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum SharedValueObservationExtent
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ValueReducers + +
    +
    +
    +
    +
    +
    +

    A namespace for types related to the ValueReducer protocol.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum ValueReducers
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabaseColumnDecodingStrategy.html b/docs/5.16/Enums/DatabaseColumnDecodingStrategy.html new file mode 100644 index 000000000..cf7ce3a9f --- /dev/null +++ b/docs/5.16/Enums/DatabaseColumnDecodingStrategy.html @@ -0,0 +1,1217 @@ + + + + DatabaseColumnDecodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseColumnDecodingStrategy

+
+
+ +
public enum DatabaseColumnDecodingStrategy
+ +
+
+

DatabaseColumnDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol look for the database colums +that match their coding keys.

+ +

For example:

+
struct Player: FetchableRecord, Decodable {
+    static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase
+
+    // Decoded from the player_id column
+    var playerID: Int
+}
+
+ + +
+
+
+
    +
  • +
    + + + + useDefaultKeys + +
    +
    +
    +
    +
    +
    +

    A key decoding strategy that doesn’t change key names during decoding.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case useDefaultKeys
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + convertFromSnakeCase + +
    +
    +
    +
    +
    +
    +

    A key decoding strategy that converts snake-case keys to camel-case keys.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case convertFromSnakeCase
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    A key decoding strategy defined by the closure you supply.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((String) -> CodingKey)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabaseColumnEncodingStrategy.html b/docs/5.16/Enums/DatabaseColumnEncodingStrategy.html new file mode 100644 index 000000000..827261977 --- /dev/null +++ b/docs/5.16/Enums/DatabaseColumnEncodingStrategy.html @@ -0,0 +1,1217 @@ + + + + DatabaseColumnEncodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseColumnEncodingStrategy

+
+
+ +
public enum DatabaseColumnEncodingStrategy
+ +
+
+

DatabaseColumnEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their coding keys into +database columns.

+ +

For example:

+
struct Player: EncodableProtocol, Encodable {
+    static let databaseColumnEncodingStrategy = DatabaseColumnEncodingStrategy.convertToSnakeCase
+
+    // Encoded in the player_id column
+    var playerID: String
+}
+
+ + +
+
+
+
    +
  • +
    + + + + useDefaultKeys + +
    +
    +
    +
    +
    +
    +

    A key encoding strategy that doesn’t change key names during encoding.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case useDefaultKeys
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + convertToSnakeCase + +
    +
    +
    +
    +
    +
    +

    A key encoding strategy that converts camel-case keys to snake-case keys.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case convertToSnakeCase
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    A key encoding strategy defined by the closure you supply.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((CodingKey) -> String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabaseDateDecodingStrategy.html b/docs/5.16/Enums/DatabaseDateDecodingStrategy.html new file mode 100644 index 000000000..72fa4d50e --- /dev/null +++ b/docs/5.16/Enums/DatabaseDateDecodingStrategy.html @@ -0,0 +1,1360 @@ + + + + DatabaseDateDecodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseDateDecodingStrategy

+
+
+ +
public enum DatabaseDateDecodingStrategy
+ +
+
+

DatabaseDateDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol decode their +Date properties.

+ +

For example:

+
struct Player: FetchableRecord, Decodable {
+    static let databaseDateDecodingStrategy = DatabaseDateDecodingStrategy.timeIntervalSince1970
+
+    var name: String
+    var registrationDate: Date // decoded from epoch timestamp
+}
+
+ + +
+
+
+
    +
  • +
    + + + + deferredToDate + +
    +
    +
    +
    +
    +
    +

    The strategy that uses formatting from the Date structure.

    + +

    It decodes numeric values as a number of seconds since Epoch +(midnight UTC on January 1st, 1970).

    + +

    It decodes strings in the following formats, assuming UTC time zone. +Missing components are assumed to be zero:

    + +
      +
    • YYYY-MM-DD
    • +
    • YYYY-MM-DD HH:MM
    • +
    • YYYY-MM-DD HH:MM:SS
    • +
    • YYYY-MM-DD HH:MM:SS.SSS
    • +
    • YYYY-MM-DDTHH:MM
    • +
    • YYYY-MM-DDTHH:MM:SS
    • +
    • YYYY-MM-DDTHH:MM:SS.SSS
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferredToDate
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Decodes numeric values as a number of seconds between the date and +midnight UTC on 1 January 2001

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSinceReferenceDate
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + timeIntervalSince1970 + +
    +
    +
    +
    +
    +
    +

    Decodes numeric values as a number of seconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + millisecondsSince1970 + +
    +
    +
    +
    +
    +
    +

    Decodes numeric values as a number of milliseconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case millisecondsSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + iso8601 + +
    +
    +
    +
    +
    +
    +

    Decodes dates according to the ISO 8601 standards

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case iso8601
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + formatted(_:) + +
    +
    +
    +
    +
    +
    +

    Decodes a String, according to the provided formatter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case formatted(DateFormatter)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    Decodes according to the user-provided function.

    + +

    If the database value does not contain a suitable value, the function +must return nil (GRDB will interpret this nil result as a conversion +error, and react accordingly).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((DatabaseValue) -> Date?)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabaseDateEncodingStrategy.html b/docs/5.16/Enums/DatabaseDateEncodingStrategy.html new file mode 100644 index 000000000..9da9bf0c6 --- /dev/null +++ b/docs/5.16/Enums/DatabaseDateEncodingStrategy.html @@ -0,0 +1,1373 @@ + + + + DatabaseDateEncodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseDateEncodingStrategy

+
+
+ +
public enum DatabaseDateEncodingStrategy
+ +
+
+

DatabaseDateEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their Date properties.

+ +

For example:

+
struct Player: EncodableRecord, Encodable {
+    static let databaseDateEncodingStrategy = DatabaseDateEncodingStrategy.timeIntervalSince1970
+
+    var name: String
+    var registrationDate: Date // encoded as an epoch timestamp
+}
+
+ + +
+
+
+
    +
  • +
    + + + + deferredToDate + +
    +
    +
    +
    +
    +
    +

    The strategy that uses formatting from the Date structure.

    + +

    It encodes dates using the format “YYYY-MM-DD HH:MM:SS.SSS” in the +UTC time zone.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferredToDate
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Encodes a Double: the number of seconds between the date and +midnight UTC on 1 January 2001

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSinceReferenceDate
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + timeIntervalSince1970 + +
    +
    +
    +
    +
    +
    +

    Encodes a Double: the number of seconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + secondsSince1970 + +
    +
    +
    +
    +
    +
    +

    Encodes an Int64: the number of seconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case secondsSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + millisecondsSince1970 + +
    +
    +
    +
    +
    +
    +

    Encodes an Int64: the number of milliseconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case millisecondsSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + iso8601 + +
    +
    +
    +
    +
    +
    +

    Encodes dates according to the ISO 8601 and RFC 3339 standards

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case iso8601
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + formatted(_:) + +
    +
    +
    +
    +
    +
    +

    Encodes a String, according to the provided formatter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case formatted(DateFormatter)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    Encodes the result of the user-provided function

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((Date) -> DatabaseValueConvertible?)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabaseEventKind.html b/docs/5.16/Enums/DatabaseEventKind.html new file mode 100644 index 000000000..3e4c34161 --- /dev/null +++ b/docs/5.16/Enums/DatabaseEventKind.html @@ -0,0 +1,1251 @@ + + + + DatabaseEventKind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseEventKind

+
+
+ +
@frozen
+public enum DatabaseEventKind
+ +
+
+

A kind of database event. See the TransactionObserver protocol for +more information.

+ + +
+
+
+
    +
  • +
    + + + + insert(tableName:) + +
    +
    +
    +
    +
    +
    +

    The insertion of a row in a database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case insert(tableName: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete(tableName:) + +
    +
    +
    +
    +
    +
    +

    The deletion of a row in a database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case delete(tableName: String)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The update of a set of columns in a database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case update(tableName: String, columnNames: Set<String>)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database events +

+
+
+
    +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The impacted database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabasePublishers.html b/docs/5.16/Enums/DatabasePublishers.html new file mode 100644 index 000000000..f6517be55 --- /dev/null +++ b/docs/5.16/Enums/DatabasePublishers.html @@ -0,0 +1,1297 @@ + + + + DatabasePublishers Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabasePublishers

+
+
+ +
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
+public enum DatabasePublishers
+ +
+
+

A namespace for database Combine publishers.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabasePublishers/DatabaseRegion.html b/docs/5.16/Enums/DatabasePublishers/DatabaseRegion.html new file mode 100644 index 000000000..e20e9770e --- /dev/null +++ b/docs/5.16/Enums/DatabasePublishers/DatabaseRegion.html @@ -0,0 +1,1176 @@ + + + + DatabaseRegion Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegion

+
+
+ +
public struct DatabaseRegion : Publisher
+ +
+
+

A publisher that tracks changes in a database region.

+ +

See DatabaseRegionObservation.publisher(in:).

+ + +
+
+
+
    +
  • +
    + + + + Output + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias Output = Database
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Failure + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias Failure = Error
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabasePublishers/Migrate.html b/docs/5.16/Enums/DatabasePublishers/Migrate.html new file mode 100644 index 000000000..bbaf8ae60 --- /dev/null +++ b/docs/5.16/Enums/DatabasePublishers/Migrate.html @@ -0,0 +1,1206 @@ + + + + Migrate Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Migrate

+
+
+ +
public struct Migrate : Publisher
+ +
+
+

A publisher that migrates a database. It publishes exactly +one element, or an error.

+ +

See DatabaseMigrator.migratePublisher(_:receiveOn:).

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabasePublishers/Read.html b/docs/5.16/Enums/DatabasePublishers/Read.html new file mode 100644 index 000000000..1120041b6 --- /dev/null +++ b/docs/5.16/Enums/DatabasePublishers/Read.html @@ -0,0 +1,1211 @@ + + + + Read Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Read

+
+
+ +
public struct Read<Output> : Publisher
+ +
+
+

A publisher that reads a value from the database. It publishes exactly +one element, or an error.

+ +

See:

+ + + + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabasePublishers/Value.html b/docs/5.16/Enums/DatabasePublishers/Value.html new file mode 100644 index 000000000..a49861542 --- /dev/null +++ b/docs/5.16/Enums/DatabasePublishers/Value.html @@ -0,0 +1,1176 @@ + + + + Value Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Value

+
+
+ +
public struct Value<Output> : Publisher
+ +
+
+

A publisher that tracks changes in the database.

+ +

See ValueObservation.publisher(in:scheduling:).

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabasePublishers/Write.html b/docs/5.16/Enums/DatabasePublishers/Write.html new file mode 100644 index 000000000..c8e663ee4 --- /dev/null +++ b/docs/5.16/Enums/DatabasePublishers/Write.html @@ -0,0 +1,1213 @@ + + + + Write Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Write

+
+
+ +
public struct Write<Output> : Publisher
+ +
+
+

A publisher that writes into the database. It publishes exactly +one element, or an error.

+ +

See:

+ + + + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/DatabaseUUIDEncodingStrategy.html b/docs/5.16/Enums/DatabaseUUIDEncodingStrategy.html new file mode 100644 index 000000000..1168d9191 --- /dev/null +++ b/docs/5.16/Enums/DatabaseUUIDEncodingStrategy.html @@ -0,0 +1,1249 @@ + + + + DatabaseUUIDEncodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseUUIDEncodingStrategy

+
+
+ +
public enum DatabaseUUIDEncodingStrategy
+ +
+
+

DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their UUID properties.

+ +

For example:

+
struct Player: EncodableProtocol, Encodable {
+    static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
+
+    // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
+    var uuid: UUID
+}
+
+ + +
+
+
+
    +
  • +
    + + + + deferredToUUID + +
    +
    +
    +
    +
    +
    +

    The strategy that uses formatting from the UUID type.

    + +

    It encodes UUIDs as 16-bytes data blobs.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferredToUUID
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + uppercaseString + +
    +
    +
    +
    +
    +
    +

    Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case uppercaseString
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lowercaseString + +
    +
    +
    +
    +
    +
    +

    Encodes UUIDs as lowercased strings such as “e621e1f8-c36c-495a-93fc-0c247a3e6e5f”

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case lowercaseString
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + string + +
    +
    +
    +
    +
    +
    +

    Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "uppercaseString")
    +public static var string: `Self` { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/PersistenceError.html b/docs/5.16/Enums/PersistenceError.html new file mode 100644 index 000000000..3b6b3af41 --- /dev/null +++ b/docs/5.16/Enums/PersistenceError.html @@ -0,0 +1,1152 @@ + + + + PersistenceError Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistenceError

+
+
+ +
public enum PersistenceError : Error, CustomStringConvertible
+ +
+
+

An error thrown by a type that adopts MutablePersistableRecord.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/SQLDateModifier.html b/docs/5.16/Enums/SQLDateModifier.html new file mode 100644 index 000000000..efaaa47f1 --- /dev/null +++ b/docs/5.16/Enums/SQLDateModifier.html @@ -0,0 +1,1538 @@ + + + + SQLDateModifier Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLDateModifier

+
+
+ +
public enum SQLDateModifier : SQLSpecificExpressible
+ +
+
+

A date modifier for SQLite date functions such as julianDay(_:_:) and +dateTime(_:_:).

+ +

For more information, see https://www.sqlite.org/lang_datefunc.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/SharedValueObservationExtent.html b/docs/5.16/Enums/SharedValueObservationExtent.html new file mode 100644 index 000000000..76cc790f5 --- /dev/null +++ b/docs/5.16/Enums/SharedValueObservationExtent.html @@ -0,0 +1,1188 @@ + + + + SharedValueObservationExtent Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SharedValueObservationExtent

+
+
+ +
public enum SharedValueObservationExtent
+ +
+
+

Controls the extent of the shared database observation +of SharedValueObservation.

+ + +
+
+
+
    +
  • +
    + + + + observationLifetime + +
    +
    +
    +
    +
    +
    +

    The SharedValueObservation starts a single database observation, which +ends when the SharedValueObservation is deallocated and all +subscriptions terminated.

    + +

    This extent prevents the shared observation from recovering from +database errors. To recover from database errors, create a new shared +SharedValueObservation instance.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case observationLifetime
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + whileObserved + +
    +
    +
    +
    +
    +
    +

    The SharedValueObservation ends database observation when the number +of subscriptions drops down to zero. The database observation restarts +on the next subscription.

    + +

    Database errors can be recovered by resubscribing to the +shared observation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case whileObserved
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Enums/ValueReducers.html b/docs/5.16/Enums/ValueReducers.html new file mode 100644 index 000000000..0aa00f483 --- /dev/null +++ b/docs/5.16/Enums/ValueReducers.html @@ -0,0 +1,1239 @@ + + + + ValueReducers Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ValueReducers

+
+
+ +
public enum ValueReducers
+ +
+
+

A namespace for types related to the ValueReducer protocol.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions.html b/docs/5.16/Extensions.html new file mode 100644 index 000000000..a33250761 --- /dev/null +++ b/docs/5.16/Extensions.html @@ -0,0 +1,2298 @@ + + + + Extensions Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Extensions

+

The following extensions are available globally.

+ +
+
+
+
+ + +
+ +

RangeReplaceableCollection, Sequence, Dictionary, Set extensions +

+
+
+ +
+
+
+ + +
+ +

Cursors +

+
+
+ +
+
+
+ + +
+ +

Value Types +

+
+
+ +
+
+
+ + +
+ +

Inclusion Operators (BETWEEN, IN) +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Bool.html b/docs/5.16/Extensions/Bool.html new file mode 100644 index 000000000..2bbf02aa6 --- /dev/null +++ b/docs/5.16/Extensions/Bool.html @@ -0,0 +1,1263 @@ + + + + Bool Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Bool

+ +

Bool adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Bool initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Bool?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/CGFloat.html b/docs/5.16/Extensions/CGFloat.html new file mode 100644 index 000000000..ab1a884c5 --- /dev/null +++ b/docs/5.16/Extensions/CGFloat.html @@ -0,0 +1,1173 @@ + + + + CGFloat Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CGFloat

+
+
+ +
extension CGFloat: DatabaseValueConvertible
+ +
+
+

CGFloat adopts DatabaseValueConvertible

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a CGFloat initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> CGFloat?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/ClosedRange.html b/docs/5.16/Extensions/ClosedRange.html new file mode 100644 index 000000000..1a654a51b --- /dev/null +++ b/docs/5.16/Extensions/ClosedRange.html @@ -0,0 +1,1154 @@ + + + + ClosedRange Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ClosedRange

+
+
+ +
extension ClosedRange where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // email BETWEEN 'A' AND 'B'
    +("A"..."B").contains(Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Collection.html b/docs/5.16/Extensions/Collection.html new file mode 100644 index 000000000..718a32d8c --- /dev/null +++ b/docs/5.16/Extensions/Collection.html @@ -0,0 +1,1159 @@ + + + + Collection Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Collection

+
+
+ +
extension Collection where Element == SQL
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Element == SQL +

+
+
+
    +
  • +
    + + + + joined(separator:) + +
    +
    +
    +
    +
    +
    +

    Returns the concatenated SQL literal of this collection of literals, +inserting the given SQL separator between each element.

    +
    let components: [SQL] = [
    +    "UPDATE player",
    +    "SET name = \(name)",
    +    "WHERE id = \(id)"
    +]
    +let query = components.joined(separator: " ")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(separator: String = "") -> SQL
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Column.html b/docs/5.16/Extensions/Column.html new file mode 100644 index 000000000..49dce75c7 --- /dev/null +++ b/docs/5.16/Extensions/Column.html @@ -0,0 +1,1124 @@ + + + + Column Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Column

+ +
+
+
+
    +
  • +
    + + + + rank + +
    +
    +
    +
    +
    +
    +

    The FTS5 rank column

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/ColumnExpression.html b/docs/5.16/Extensions/ColumnExpression.html new file mode 100644 index 000000000..6075f8853 --- /dev/null +++ b/docs/5.16/Extensions/ColumnExpression.html @@ -0,0 +1,1127 @@ + + + + ColumnExpression Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnExpression

+ +
+
+
+
    +
  • +
    + + + + match(_:) + +
    +
    +
    +
    +
    +
    +

    A matching SQL expression with the MATCH SQL operator.

    +
    // content MATCH '...'
    +Column("content").match(pattern)
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/CountableClosedRange.html b/docs/5.16/Extensions/CountableClosedRange.html new file mode 100644 index 000000000..a990aad99 --- /dev/null +++ b/docs/5.16/Extensions/CountableClosedRange.html @@ -0,0 +1,1154 @@ + + + + CountableClosedRange Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CountableClosedRange

+
+
+ +
extension CountableClosedRange where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // id BETWEEN 1 AND 10
    +(1...10).contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/CountableRange.html b/docs/5.16/Extensions/CountableRange.html new file mode 100644 index 000000000..e9a83fcdb --- /dev/null +++ b/docs/5.16/Extensions/CountableRange.html @@ -0,0 +1,1154 @@ + + + + CountableRange Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CountableRange

+
+
+ +
extension CountableRange where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // id BETWEEN 1 AND 9
    +(1..<10).contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Data.html b/docs/5.16/Extensions/Data.html new file mode 100644 index 000000000..15cfc07e8 --- /dev/null +++ b/docs/5.16/Extensions/Data.html @@ -0,0 +1,1232 @@ + + + + Data Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Data

+ +

Data is convertible to and from DatabaseValue.

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Database.html b/docs/5.16/Extensions/Database.html new file mode 100644 index 000000000..32c31f056 --- /dev/null +++ b/docs/5.16/Extensions/Database.html @@ -0,0 +1,1273 @@ + + + + Database Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Database

+ +
+
+
+
+ + +
+ +

Encryption +

+
+
+
    +
  • +
    + + + + usePassphrase(_:) + +
    +
    +
    +
    +
    +
    +

    Sets the passphrase used to crypt and decrypt an SQLCipher database.

    + +

    Call this method from Configuration.prepareDatabase, +as in the example below:

    +
    var config = Configuration()
    +config.prepareDatabase { db in
    +    try db.usePassphrase("secret")
    +}
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + changePassphrase(_:) + +
    +
    +
    +
    +
    +
    +

    Changes the passphrase used by an SQLCipher encrypted database.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Deletes the synchronization triggers for a synchronized FTS5 table

    + +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

FTS5 +

+
+
+
    +
  • +
    + + + + add(tokenizer:) + +
    +
    +
    +
    +
    +
    +

    Add a custom FTS5 tokenizer.

    +
    class MyTokenizer : FTS5CustomTokenizer { ... }
    +db.add(tokenizer: MyTokenizer.self)
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern from a raw pattern string; throws DatabaseError on +invalid syntax.

    + +

    The pattern syntax is documented at https://www.sqlite.org/fts5.html#full_text_query_syntax

    +
    try db.makeFTS5Pattern(rawPattern: "and", forTable: "document") // OK
    +try db.makeFTS5Pattern(rawPattern: "AND", forTable: "document") // malformed MATCH expression: [AND]
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + makeTokenizer(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an FTS5 tokenizer, given its descriptor.

    +
    let unicode61 = try db.makeTokenizer(.unicode61())
    +
    + +

    It is a programmer error to use the tokenizer outside of a protected +database queue, or after the database has been closed.

    + +

    Use this method when you implement a custom wrapper tokenizer:

    +
    final class MyTokenizer : FTS5WrapperTokenizer {
    +    var wrappedTokenizer: FTS5Tokenizer
    +
    +    init(db: Database, arguments: [String]) throws {
    +        wrappedTokenizer = try db.makeTokenizer(.unicode61())
    +    }
    +}
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Date.html b/docs/5.16/Extensions/Date.html new file mode 100644 index 000000000..7905b019a --- /dev/null +++ b/docs/5.16/Extensions/Date.html @@ -0,0 +1,1278 @@ + + + + Date Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Date

+
+
+ +
extension Date: DatabaseValueConvertible
+
extension Date: StatementColumnConvertible
+ +
+
+

Date is stored in the database using the format +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a database value that contains the date encoded as +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a date initialized from dbValue, if possible.

    + +

    If database value contains a number, that number is interpreted as a +timeinterval since 00:00:00 UTC on 1 January 1970.

    + +

    If database value contains a string, that string is interpreted as a +SQLite date in the UTC time +zone. Nil is returned if the date string does not contain at least the +year, month and day components. Other components (minutes, etc.) +are set to zero if missing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Date?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(julianDay:) + +
    +
    +
    +
    +
    +
    +

    Creates a date from a Julian Day.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(julianDay: Double)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Decimal.html b/docs/5.16/Extensions/Decimal.html new file mode 100644 index 000000000..e4216e69d --- /dev/null +++ b/docs/5.16/Extensions/Decimal.html @@ -0,0 +1,1203 @@ + + + + Decimal Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Decimal

+
+
+ +
extension Decimal: DatabaseValueConvertible
+
extension Decimal: StatementColumnConvertible
+ +
+
+

Decimal adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Dictionary.html b/docs/5.16/Extensions/Dictionary.html new file mode 100644 index 000000000..51c3e60b3 --- /dev/null +++ b/docs/5.16/Extensions/Dictionary.html @@ -0,0 +1,1411 @@ + + + + Dictionary Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Dictionary

+
+
+ +
extension Dictionary
+ +
+
+ +
+
+
+
    +
  • +
    + + + + init(grouping:by:) + +
    +
    +
    +
    +
    +
    +

    Creates a new dictionary whose keys are the groupings returned by the +given closure and whose values are arrays of the elements that returned +each key.

    +
    // [Int64: [Player]]
    +let cursor = try Player.fetchCursor(db)
    +let dictionary = try Dictionary(grouping: cursor, by: { $0.teamID })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(grouping cursor: C, by keyForValue: (C.Element) throws -> Key)
    +throws where Value == [C.Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + cursor + + +
    +

    A cursor of values to group into a dictionary.

    +
    +
    + + keyForValue + + +
    +

    A closure that returns a key for each element +in the cursor.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a new dictionary whose keys are the groupings returned by the +given closure and whose values are arrays of the elements that returned +each key.

    +
    // [Int64: [Player]]
    +let cursor = try Player.fetchCursor(db)
    +let dictionary = try Dictionary(
    +    minimumCapacity: 100,
    +    grouping: cursor,
    +    by: { $0.teamID })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(minimumCapacity: Int, grouping cursor: C, by keyForValue: (C.Element) throws -> Key)
    +throws where Value == [C.Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + minimumCapacity + + +
    +

    The minimum number of key-value pairs that +the newly created dictionary should be able to store without +reallocating its storage buffer.

    +
    +
    + + cursor + + +
    +

    A cursor of values to group into a dictionary.

    +
    +
    + + keyForValue + + +
    +

    A closure that returns a key for each element +in the cursor.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a new dictionary from the key-value pairs in the given cursor.

    + +

    You use this initializer to create a dictionary when you have a cursor +of key-value tuples with unique keys. Passing a cursor with duplicate +keys to this initializer results in a fatal error.

    +
    // [Int64: Player]
    +let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
    +let playerByID = try Dictionary(uniqueKeysWithValues: cursor)
    +
    +
    +

    Precondition

    + The cursor must not have duplicate keys. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(uniqueKeysWithValues keysAndValues: C)
    +throws where C.Element == (Key, Value)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + keysAndValues + + +
    +

    A cursor of key-value pairs to use for the +new dictionary. Every key in keysAndValues must be unique.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a new dictionary from the key-value pairs in the given cursor.

    + +

    You use this initializer to create a dictionary when you have a cursor +of key-value tuples with unique keys. Passing a cursor with duplicate +keys to this initializer results in a fatal error.

    +
    // [Int64: Player]
    +let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
    +let playerByID = try Dictionary(
    +    minimumCapacity: 100,
    +    uniqueKeysWithValues: cursor)
    +
    +
    +

    Precondition

    + The cursor must not have duplicate keys. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(minimumCapacity: Int, uniqueKeysWithValues keysAndValues: C)
    +throws where C.Element == (Key, Value)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + minimumCapacity + + +
    +

    The minimum number of key-value pairs that +the newly created dictionary should be able to store without +reallocating its storage buffer.

    +
    +
    + + keysAndValues + + +
    +

    A cursor of key-value pairs to use for the +new dictionary. Every key in keysAndValues must be unique.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Double.html b/docs/5.16/Extensions/Double.html new file mode 100644 index 000000000..60ceecdac --- /dev/null +++ b/docs/5.16/Extensions/Double.html @@ -0,0 +1,1263 @@ + + + + Double Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Double

+
+ +
+

Double adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Double initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Double?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Float.html b/docs/5.16/Extensions/Float.html new file mode 100644 index 000000000..3ee1d1a12 --- /dev/null +++ b/docs/5.16/Extensions/Float.html @@ -0,0 +1,1263 @@ + + + + Float Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Float

+ +

Float adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Float initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Float?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Int.html b/docs/5.16/Extensions/Int.html new file mode 100644 index 000000000..722b30913 --- /dev/null +++ b/docs/5.16/Extensions/Int.html @@ -0,0 +1,1265 @@ + + + + Int Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int

+ +

Int adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Int16.html b/docs/5.16/Extensions/Int16.html new file mode 100644 index 000000000..329f782cf --- /dev/null +++ b/docs/5.16/Extensions/Int16.html @@ -0,0 +1,1265 @@ + + + + Int16 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int16

+ +

Int16 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int16 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int16?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Int32.html b/docs/5.16/Extensions/Int32.html new file mode 100644 index 000000000..92de52ae3 --- /dev/null +++ b/docs/5.16/Extensions/Int32.html @@ -0,0 +1,1265 @@ + + + + Int32 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int32

+ +

Int32 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int32 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int32?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Int64.html b/docs/5.16/Extensions/Int64.html new file mode 100644 index 000000000..c1bd661b3 --- /dev/null +++ b/docs/5.16/Extensions/Int64.html @@ -0,0 +1,1263 @@ + + + + Int64 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int64

+ +

Int64 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int64 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int64?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Int8.html b/docs/5.16/Extensions/Int8.html new file mode 100644 index 000000000..7897078ec --- /dev/null +++ b/docs/5.16/Extensions/Int8.html @@ -0,0 +1,1265 @@ + + + + Int8 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int8

+ +

Int8 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int8 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int8?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSData.html b/docs/5.16/Extensions/NSData.html new file mode 100644 index 000000000..87a499e78 --- /dev/null +++ b/docs/5.16/Extensions/NSData.html @@ -0,0 +1,1174 @@ + + + + NSData Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSData

+
+
+ +
extension NSData: DatabaseValueConvertible
+ +
+
+

NSData is convertible to and from DatabaseValue.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSData initialized from dbValue, if it contains +a Blob.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSDate.html b/docs/5.16/Extensions/NSDate.html new file mode 100644 index 000000000..0f887ea07 --- /dev/null +++ b/docs/5.16/Extensions/NSDate.html @@ -0,0 +1,1184 @@ + + + + NSDate Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSDate

+
+
+ +
extension NSDate: DatabaseValueConvertible
+ +
+
+

NSDate is stored in the database using the format +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a database value that contains the date encoded as +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a date initialized from dbValue, if possible.

    + +

    If database value contains a number, that number is interpreted as a +timeinterval since 00:00:00 UTC on 1 January 1970.

    + +

    If database value contains a string, that string is interpreted as a +SQLite date in the UTC time +zone. Nil is returned if the date string does not contain at least the +year, month and day components. Other components (minutes, etc.) +are set to zero if missing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSNull.html b/docs/5.16/Extensions/NSNull.html new file mode 100644 index 000000000..024d87477 --- /dev/null +++ b/docs/5.16/Extensions/NSNull.html @@ -0,0 +1,1173 @@ + + + + NSNull Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSNull

+
+
+ +
extension NSNull: DatabaseValueConvertible
+ +
+
+

NSNull adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSNumber.html b/docs/5.16/Extensions/NSNumber.html new file mode 100644 index 000000000..43fc4be93 --- /dev/null +++ b/docs/5.16/Extensions/NSNumber.html @@ -0,0 +1,1173 @@ + + + + NSNumber Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSNumber

+
+
+ +
extension NSNumber: DatabaseValueConvertible
+ +
+
+

NSNumber adopts DatabaseValueConvertible

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSNumber initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSString.html b/docs/5.16/Extensions/NSString.html new file mode 100644 index 000000000..8b7a1aa17 --- /dev/null +++ b/docs/5.16/Extensions/NSString.html @@ -0,0 +1,1173 @@ + + + + NSString Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSString

+
+
+ +
extension NSString: DatabaseValueConvertible
+ +
+
+

NSString adopts DatabaseValueConvertible

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSString initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSURL.html b/docs/5.16/Extensions/NSURL.html new file mode 100644 index 000000000..903ca7978 --- /dev/null +++ b/docs/5.16/Extensions/NSURL.html @@ -0,0 +1,1174 @@ + + + + NSURL Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSURL

+
+
+ +
extension NSURL: DatabaseValueConvertible
+ +
+
+

NSURL stores its absoluteString in the database.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database. +(the URL’s absoluteString).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSURL initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/NSUUID.html b/docs/5.16/Extensions/NSUUID.html new file mode 100644 index 000000000..73f724d2a --- /dev/null +++ b/docs/5.16/Extensions/NSUUID.html @@ -0,0 +1,1171 @@ + + + + NSUUID Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSUUID

+
+
+ +
extension NSUUID: DatabaseValueConvertible
+ +
+
+

NSUUID adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Optional.html b/docs/5.16/Extensions/Optional.html new file mode 100644 index 000000000..80e78d1bf --- /dev/null +++ b/docs/5.16/Extensions/Optional.html @@ -0,0 +1,2906 @@ + + + + Optional Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Optional

+
+
+ +
extension Optional where Wrapped: DatabaseValueConvertible
+
extension Optional where Wrapped: DatabaseValueConvertible & Hashable
+
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible
+
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable
+ +
+
+

Swift’s Optional comes with built-in methods that allow to fetch cursors +and arrays of optional DatabaseValueConvertible:

+
try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String?
+try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String?]
+
+let statement = try db.makeStatement(sql: "SELECT name FROM ...")
+try Optional<String>.fetchCursor(statement, arguments:...) // Cursor of String?
+try Optional<String>.fetchAll(statement, arguments:...)    // [String?]
+
+ +

DatabaseValueConvertible is adopted by Bool, Int, String, etc.

+ +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> NullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchAll(statement)  // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchSet(statement)  // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> NullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from an SQL query.

    +
    let names = try String.fetchAll(db, sql: "SELECT name FROM ...") // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from an SQL query.

    +
    let names = try String.fetchSet(db, sql: "SELECT name FROM ...") // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchCursor(db, request) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R: FetchRequest>(_ db: Database, _ request: R)
    +throws -> NullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchAll(db, request) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Wrapped?] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchSet(db, request) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Wrapped?> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> FastNullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchAll(statement)  // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchSet(statement)  // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> FastNullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...") // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchSet(db, sql: "SELECT name FROM ...") // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchCursor(db, request) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R: FetchRequest>(_ db: Database, _ request: R)
    +throws -> FastNullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchAll(db, request) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Wrapped?] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchSet(db, request) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Wrapped?> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Range.html b/docs/5.16/Extensions/Range.html new file mode 100644 index 000000000..09801a900 --- /dev/null +++ b/docs/5.16/Extensions/Range.html @@ -0,0 +1,1154 @@ + + + + Range Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Range

+
+
+ +
extension Range where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // email >= 'A' AND email < 'B'
    +("A"..<"B").contains(Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/RangeReplaceableCollection.html b/docs/5.16/Extensions/RangeReplaceableCollection.html new file mode 100644 index 000000000..ac38702cc --- /dev/null +++ b/docs/5.16/Extensions/RangeReplaceableCollection.html @@ -0,0 +1,1231 @@ + + + + RangeReplaceableCollection Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RangeReplaceableCollection

+
+
+ +
extension RangeReplaceableCollection
+ +
+
+ +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a collection containing the elements of a cursor.

    +
    // [String]
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Array(cursor)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C) throws where C : Cursor, Self.Element == C.Element
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cursor + + +
    +

    The cursor whose elements feed the collection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a collection containing the elements of a cursor.

    +
    // [String]
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Array(cursor, minimumCapacity: 100)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C, minimumCapacity: Int) throws where C : Cursor, Self.Element == C.Element
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + cursor + + +
    +

    The cursor whose elements feed the collection.

    +
    +
    + + minimumCapacity + + +
    +

    Prepares the returned collection to store +the specified number of elements.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Sequence.html b/docs/5.16/Extensions/Sequence.html new file mode 100644 index 000000000..606799360 --- /dev/null +++ b/docs/5.16/Extensions/Sequence.html @@ -0,0 +1,1415 @@ + + + + Sequence Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Sequence

+
+
+ +
extension Sequence
+
extension Sequence where Element == SQL
+
extension Sequence where Element: SQLSpecificExpressible
+
extension Sequence where Element == SQLSpecificExpressible
+
extension Sequence where Self.Iterator.Element: SQLExpressible
+
extension Sequence where Self.Iterator.Element == SQLExpressible
+ +
+
+ +
+
+
+
    +
  • +
    + + + + flatMap(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated results of mapping transform +over self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func flatMap<SegmentOfResult: Cursor>(
    +    _ transform: @escaping (Iterator.Element) throws -> SegmentOfResult)
    +-> FlattenCursor<MapCursor<AnyCursor<Iterator.Element>, SegmentOfResult>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element == SQL +

+
+
+
    +
  • +
    + + + + joined(separator:) + +
    +
    +
    +
    +
    +
    +

    Returns the concatenated SQL literal of this sequence of literals, +inserting the given separator between each element.

    +
    let components: [SQL] = [
    +    "UPDATE player",
    +    "SET name = \(name)",
    +    "WHERE id = \(id)"
    +]
    +let query = components.joined(separator: " ")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(separator: String = "") -> SQL
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: SQLSpecificExpressible +

+
+
+
    +
  • +
    + + + + joined(operator:) + +
    +
    +
    +
    +
    +
    +

    Returns an expression by joining all elements with an associative SQL +binary operator.

    + +

    For example:

    +
    // SELECT * FROM player
    +// WHERE (registered
    +//        AND (score >= 1000)
    +//        AND (name IS NOT NULL))
    +let conditions = [
    +    Column("registered"),
    +    Column("score") >= 1000,
    +    Column("name") != nil]
    +Player.filter(conditions.joined(operator: .and))
    +
    + +

    When the sequence is empty, joined(operator:) returns the neutral +value of the operator. It is 0 (zero) for .add, 1 for ‘.multiply, +false for.or, and true for.and`.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(operator: SQLExpression.AssociativeBinaryOperator) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element == SQLSpecificExpressible +

+
+
+
    +
  • +
    + + + + joined(operator:) + +
    +
    +
    +
    +
    +
    +

    Returns an expression by joining all elements with an associative SQL +binary operator.

    + +

    For example:

    +
    // SELECT * FROM player
    +// WHERE (registered
    +//        AND (score >= 1000)
    +//        AND (name IS NOT NULL))
    +let conditions = [
    +    Column("registered"),
    +    Column("score") >= 1000,
    +    Column("name") != nil]
    +Player.filter(conditions.joined(operator: .and))
    +
    + +

    When the sequence is empty, joined(operator:) returns the neutral +value of the operator. It is 0 (zero) for .add, 1 for ‘.multiply, +false for.or, and true for.and`.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(operator: SQLExpression.AssociativeBinaryOperator) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self.Iterator.Element: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in +a sequence.

    +
    // id IN (1,2,3)
    +[1, 2, 3].contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self.Iterator.Element == SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in +a sequence.

    +
    // id IN (1,2,3)
    +[1, 2, 3].contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/Set.html b/docs/5.16/Extensions/Set.html new file mode 100644 index 000000000..ff605eefe --- /dev/null +++ b/docs/5.16/Extensions/Set.html @@ -0,0 +1,1232 @@ + + + + Set Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Set

+
+
+ +
extension Set
+ +
+
+ +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a set containing the elements of a cursor.

    +
    // Set<String>
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Set(cursor)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C) throws where Element == C.Element, C : Cursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cursor + + +
    +

    A cursor of values to gather into a set.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a set containing the elements of a cursor.

    +
    // Set<String>
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Set(cursor, minimumCapacity: 100)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C, minimumCapacity: Int) throws where Element == C.Element, C : Cursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + cursor + + +
    +

    A cursor of values to gather into a set.

    +
    +
    + + minimumCapacity + + +
    +

    The minimum number of elements that the +newly created set should be able to store without reallocating its +storage buffer.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/String.html b/docs/5.16/Extensions/String.html new file mode 100644 index 000000000..4e015fc01 --- /dev/null +++ b/docs/5.16/Extensions/String.html @@ -0,0 +1,1309 @@ + + + + String Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

String

+
+ +
+

String adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a String initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> String?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Public +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns the receiver, quoted for safe insertion as an identifier in an +SQL query.

    +
    db.execute(sql: "SELECT * FROM \(tableName.quotedDatabaseIdentifier)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var quotedDatabaseIdentifier: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/TableRecord.html b/docs/5.16/Extensions/TableRecord.html new file mode 100644 index 000000000..171ef381f --- /dev/null +++ b/docs/5.16/Extensions/TableRecord.html @@ -0,0 +1,1139 @@ + + + + TableRecord Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRecord

+ +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a QueryInterfaceRequest with a matching predicate.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/TableRequest.html b/docs/5.16/Extensions/TableRequest.html new file mode 100644 index 000000000..d26215c8e --- /dev/null +++ b/docs/5.16/Extensions/TableRequest.html @@ -0,0 +1,1145 @@ + + + + TableRequest Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRequest

+ +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with a full-text predicate added to the eventual +set of already applied predicates.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.all()
    +request = request.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/UInt.html b/docs/5.16/Extensions/UInt.html new file mode 100644 index 000000000..8f6c4bced --- /dev/null +++ b/docs/5.16/Extensions/UInt.html @@ -0,0 +1,1265 @@ + + + + UInt Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt

+ +

UInt adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/UInt16.html b/docs/5.16/Extensions/UInt16.html new file mode 100644 index 000000000..64618018d --- /dev/null +++ b/docs/5.16/Extensions/UInt16.html @@ -0,0 +1,1265 @@ + + + + UInt16 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt16

+
+ +
+

UInt16 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt16 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt16?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/UInt32.html b/docs/5.16/Extensions/UInt32.html new file mode 100644 index 000000000..9da41def9 --- /dev/null +++ b/docs/5.16/Extensions/UInt32.html @@ -0,0 +1,1265 @@ + + + + UInt32 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt32

+
+ +
+

UInt32 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt32 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt32?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/UInt64.html b/docs/5.16/Extensions/UInt64.html new file mode 100644 index 000000000..0ce8a2c03 --- /dev/null +++ b/docs/5.16/Extensions/UInt64.html @@ -0,0 +1,1265 @@ + + + + UInt64 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt64

+
+ +
+

UInt64 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt64 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt64?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/UInt8.html b/docs/5.16/Extensions/UInt8.html new file mode 100644 index 000000000..dd4e699f2 --- /dev/null +++ b/docs/5.16/Extensions/UInt8.html @@ -0,0 +1,1265 @@ + + + + UInt8 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt8

+ +

UInt8 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt8 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt8?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Extensions/UUID.html b/docs/5.16/Extensions/UUID.html new file mode 100644 index 000000000..d13665d92 --- /dev/null +++ b/docs/5.16/Extensions/UUID.html @@ -0,0 +1,1203 @@ + + + + UUID Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UUID

+
+
+ +
extension UUID: DatabaseValueConvertible
+
extension UUID: StatementColumnConvertible
+ +
+
+

UUID adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Functions.html b/docs/5.16/Functions.html new file mode 100644 index 000000000..16bdf725b --- /dev/null +++ b/docs/5.16/Functions.html @@ -0,0 +1,5270 @@ + + + + Functions Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Functions

+

The following functions are available globally.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns an array of row adapters that split a row according to the input +number of columns.

    + +

    For example:

    +
    let sql = "SELECT 1, 2,3,4, 5,6, 7,8"
    +//               <.><. . .><. .><. .>
    +let adapters = splittingRowAdapters([1, 3, 2])
    +let adapter = ScopeAdapter([
    +    "a": adapters[0],
    +    "b": adapters[1],
    +    "c": adapters[2],
    +    "d": adapters[3]])
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)
    +row.scopes["a"] // [1]
    +row.scopes["b"] // [2, 3, 4]
    +row.scopes["c"] // [5, 6]
    +row.scopes["d"] // [7, 8]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func splittingRowAdapters(columnCounts: [Int]) -> [RowAdapter]
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Logical Operators (AND, OR, NOT) +

+
+
+ +
+
+
+ + +
+ +

Egality and Identity Operators (=, <>, IS, IS NOT) +

+
+
+
    +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the = SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count == Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the = SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count == 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the = SQL operator.

    + +

    For example:

    + +

    Author.having(3 == Author.books.count)

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(Author.books.isEmpty == false)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(false == Author.books.isEmpty)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(lhs: Bool, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the <> SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count != Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the <> SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count != 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the <> SQL operator.

    + +

    For example:

    +
    Author.having(3 != Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(Author.books.isEmpty != true)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(true != Author.books.isEmpty)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(lhs: Bool, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the IS SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count === Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count === 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS SQL operator.

    + +

    For example:

    +
    Author.having(3 === Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the IS NOT SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count !== Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count !== 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

    + +

    For example:

    +
    Author.having(3 !== Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Comparison Operators (<, >, <=, >=) +

+
+
+ +
+
+
+ + +
+ +

Arithmetic Operators (+, -, *, /) +

+
+
+
    +
  • +
    + + + + -(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an arithmetically negated aggregate.

    + +

    For example:

    +
    Author.annotated(with: -Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public prefix func - <RowDecoder>(aggregate: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that sums two aggregates with the + SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count + Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func + <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that sums an aggregate with the + SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count + 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func + <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that sums an aggregate with the + SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 1 + Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func + <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts two aggregates with the - SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count - Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func - <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the - SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count - 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func - <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the - SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 1 - Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func - <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that multiplies two aggregates with the * SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count * Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func * <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the * SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count * 2)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func * <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the * SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 2 * Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func * <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that multiplies two aggregates with the / SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count / Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func / <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the / SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count / 2)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func / <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the / SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 2 / Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func / <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

IFNULL(…) +

+
+
+ +
+
+
+ + +
+ +

ColumnAssignment +

+
+
+
    +
  • +
    + + + + +=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that adds a value

    +
    Column("score") += 1
    +Column("score") += Column("bonus")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score + 1
    +    try Player.updateAll(db, Column("score") += 1)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func += (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that subtracts a value

    +
    Column("score") -= 1
    +Column("score") -= Column("bonus")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score - 1
    +    try Player.updateAll(db, Column("score") -= 1)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func -= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that multiplies by a value

    +
    Column("score") *= 2
    +Column("score") *= Column("factor")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score * 2
    +    try Player.updateAll(db, Column("score") *= 2)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func *= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that divides by a value

    +
    Column("score") /= 2
    +Column("score") /= Column("factor")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score / 2
    +    try Player.updateAll(db, Column("score") /= 2)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func /= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ABS(…) +

+
+
+ +
+
+
+ + +
+ +

AVG(…) +

+
+
+ +
+
+
+ + +
+ +

COUNT(…) +

+
+
+ +
+
+
+ + +
+ +

COUNT(DISTINCT …) +

+
+
+ +
+
+
+ + +
+ +

IFNULL(…) +

+
+
+ +
+
+
+ + +
+ +

LENGTH(…) +

+
+
+ +
+
+
+ + +
+ +

MAX(…) +

+
+
+ +
+
+
+ + +
+ +

MIN(…) +

+
+
+ +
+
+
+ + +
+ +

SUM(…) +

+
+
+ +
+
+
+ + +
+ +

JULIANDAY(…) +

+
+
+ +
+
+
+ + +
+ +

DATETIME(…) +

+
+
+ +
+
+
+ + +
+ +

Egality and Identity Operators (=, <>, IS, IS NOT) +

+
+
+
    +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the = SQL operator.

    +
    // name = 'Arthur'
    +Column("name") == "Arthur"
    +
    + +

    When the right operand is nil, IS NULL is used instead.

    +
    // name IS NULL
    +Column("name") == nil
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // validated
    +Column("validated") == true
    +
    +// NOT validated
    +Column("validated") == false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the = SQL operator.

    +
    // 'Arthur' = name
    +"Arthur" == Column("name")
    +
    + +

    When the left operand is nil, IS NULL is used instead.

    +
    // name IS NULL
    +nil == Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // validated
    +true == Column("validated")
    +
    +// NOT validated
    +false == Column("validated")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the = SQL operator.

    +
    // email = login
    +Column("email") == Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the <> SQL operator.

    +
    // name <> 'Arthur'
    +Column("name") != "Arthur"
    +
    + +

    When the right operand is nil, IS NOT NULL is used instead.

    +
    // name IS NOT NULL
    +Column("name") != nil
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // NOT validated
    +Column("validated") != true
    +
    +// validated
    +Column("validated") != false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the <> SQL operator.

    +
    // 'Arthur' <> name
    +"Arthur" != Column("name")
    +
    + +

    When the left operand is nil, IS NOT NULL is used instead.

    +
    // name IS NOT NULL
    +nil != Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // NOT validated
    +true != Column("validated")
    +
    +// validated
    +false != Column("validated")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the <> SQL operator.

    +
    // email <> login
    +Column("email") != Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS SQL operator.

    +
    // name IS 'Arthur'
    +Column("name") === "Arthur"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS SQL operator.

    +
    // name IS 'Arthur'
    +"Arthur" === Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS SQL operator.

    +
    // email IS login
    +Column("email") === Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS NOT SQL operator.

    +
    // name IS NOT 'Arthur'
    +Column("name") !== "Arthur"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS NOT SQL operator.

    +
    // name IS NOT 'Arthur'
    +"Arthur" !== Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS NOT SQL operator.

    +
    // email IS NOT login
    +Column("email") !== Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Comparison Operators (<, >, <=, >=) +

+
+
+ +
+
+
+ + +
+ +

Arithmetic Operators (+, -, *, /) +

+
+
+ +
+
+
+ + +
+ +

Logical Operators (AND, OR, NOT) +

+
+
+ +
+
+
+ + +
+ +

Public +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Return as many question marks separated with commas as the count argument.

    +
    databaseQuestionMarks(count: 3) // "?,?,?"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseQuestionMarks(count: Int) -> String
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols.html b/docs/5.16/Protocols.html new file mode 100644 index 000000000..6398f614b --- /dev/null +++ b/docs/5.16/Protocols.html @@ -0,0 +1,2786 @@ + + + + Protocols Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Protocols

+

The following protocols are available globally.

+ +
+
+
+
+ + +
+ +

Cursor +

+
+
+
    +
  • +
    + + + + Cursor + +
    +
    +
    +
    +
    +
    +

    A type that supplies the values of some external resource, one at a time.

    +

    Overview

    + +

    The most common way to iterate over the elements of a cursor is to use a +while loop:

    +
    let cursor = ...
    +while let element = try cursor.next() {
    +    ...
    +}
    +
    +

    Relationship with standard Sequence and IteratorProtocol

    + +

    Cursors share traits with lazy sequences and iterators from the Swift +standard library. Differences are:

    + +
      +
    • Cursor types are classes, and have a lifetime.
    • +
    • Cursor iteration may throw errors.
    • +
    • A cursor can not be repeated.
    • +
    + +

    The protocol comes with default implementations for many operations similar +to those defined by Swift’s Sequence protocol: contains, dropFirst, +dropLast, drop(while:), enumerated, filter, first, flatMap, +forEach, joined, joined(separator:), max, max(by:), min, +min(by:), map, prefix, prefix(while:), reduce, reduce(into:), +suffix.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol Cursor : AnyObject
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseAggregate + +
    +
    +
    +
    +
    +
    +

    The protocol for custom SQLite aggregates.

    + +

    For example:

    +
    struct MySum : DatabaseAggregate {
    +    var sum: Int = 0
    +
    +    mutating func step(_ dbValues: [DatabaseValue]) {
    +        if let int = Int.fromDatabaseValue(dbValues[0]) {
    +            sum += int
    +        }
    +    }
    +
    +    func finalize() -> DatabaseValueConvertible? {
    +        return sum
    +    }
    +}
    +
    +let dbQueue = DatabaseQueue()
    +let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
    +try dbQueue.write { db in
    +    db.add(function: fn)
    +    try db.execute(sql: "CREATE TABLE test(i)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (1)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (2)")
    +    try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseAggregate
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseReader + +
    +
    +
    +
    +
    +
    +

    DatabaseReader is the protocol for all types that can fetch values from +an SQLite database.

    + +

    It is adopted by DatabaseQueue, DatabasePool, and DatabaseSnapshot.

    + +

    The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

    + +

    Types that adopt the protocol can provide in practice stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

    + +

    Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseReader : AnyObject
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseRegionConvertible +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseRegionConvertible is the protocol for values that can be turned +into a DatabaseRegion.

    + +

    Such values specify the region obserbed by DatabaseRegionObservation.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Types that adopt DatabaseValueConvertible can be initialized from +database values.

    + +

    The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single values:

    +
    try String.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String
    +try String.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String]
    +try String.fetchOne(db, sql: "SELECT name FROM ...", arguments:...)    // String?
    +
    +let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +try String.fetchCursor(statement, arguments:...) // Cursor of String
    +try String.fetchAll(statement, arguments:...)    // [String]
    +try String.fetchOne(statement, arguments:...)    // String?
    +
    + +

    DatabaseValueConvertible is adopted by Bool, Int, String, etc.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseValueConvertible : SQLExpressible, StatementBinding
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FetchRequest +

+
+
+
    +
  • +
    + + + + FetchRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that fetch database rows, and tell how those +rows should be interpreted.

    +
    struct Player: FetchableRecord { ... }
    +let request: ... // Some FetchRequest that fetches Player
    +try request.fetchCursor(db) // Cursor of Player
    +try request.fetchAll(db)    // [Player]
    +try request.fetchSet(db)    // Set<Player>
    +try request.fetchOne(db)    // Player?
    +try request.fetchCount(db)  // Int
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol FetchRequest : DatabaseRegionConvertible, SQLSubqueryable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseWriter + +
    +
    +
    +
    +
    +
    +

    DatabaseWriter is the protocol for all types that can write into an +SQLite database.

    + +

    It is adopted by DatabaseQueue and DatabasePool.

    + +

    The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

    + +

    Types that adopt the protocol can in practice provide stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

    + +

    Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseWriter : DatabaseReader
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + RowAdapter + +
    +
    +
    +
    +
    +
    +

    RowAdapter is a protocol that helps two incompatible row interfaces +working together.

    + +

    GRDB ships with four concrete types that adopt the RowAdapter protocol:

    + + + +

    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)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol RowAdapter : _RowAdapter
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementBinding +

+
+
+
    +
  • +
    + + + + StatementBinding + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol StatementBinding
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The StatementColumnConvertible protocol grants access to the low-level C +interface that extracts values from query results: +https://www.sqlite.org/c3ref/column_blob.html. It can bring performance +improvements.

    + +

    To use it, have a value type adopt both StatementColumnConvertible and +DatabaseValueConvertible. GRDB will then automatically apply the +optimization whenever direct access to SQLite is possible:

    +
    let rows = Row.fetchCursor(db, sql: "SELECT ...")
    +while let row = try rows.next() {
    +    let int: Int = row[0]                 // there
    +}
    +let ints = Int.fetchAll(db, sql: "SELECT ...") // there
    +struct Player {
    +    init(row: Row) {
    +        name = row["name"]                // there
    +        score = row["score"]              // there
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol StatementColumnConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQLSelectable +

+
+
+ +
+
+
+ + +
+ +

SQLOrderingTerm +

+
+
+ +
+
+
+ + +
+ +

SQLExpressible +

+
+
+ +
+
+
+ + +
+ +

TransactionObserver +

+
+
+
    +
  • +
    + + + + TransactionObserver + +
    +
    +
    +
    +
    +
    +

    A transaction observer is notified of all changes and transactions committed +or rollbacked on a database.

    + +

    Adopting types must be a class.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TransactionObserver : AnyObject
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5CustomTokenizer + +
    +
    +
    +
    +
    +
    +

    The protocol for custom FTS5 tokenizers.

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5Tokenizer + +
    +
    +
    +
    +
    +
    +

    The protocol for FTS5 tokenizers

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5WrapperTokenizer + +
    +
    +
    +
    +
    +
    +

    The protocol for custom FTS5 tokenizers that wrap another tokenizer.

    + +

    Types that adopt FTS5WrapperTokenizer don’t have to implement the +low-level FTS5Tokenizer.tokenize(context:flags:pText:nText:tokenCallback:).

    + +

    Instead, they process regular Swift strings.

    + +

    Here is the implementation for a trivial tokenizer that wraps the +built-in ascii tokenizer without any custom processing:

    +
    class TrivialAsciiTokenizer : FTS5WrapperTokenizer {
    +    static let name = "trivial"
    +    let wrappedTokenizer: FTS5Tokenizer
    +
    +    init(db: Database, arguments: [String]) throws {
    +        wrappedTokenizer = try db.makeTokenizer(.ascii())
    +    }
    +
    +    func accept(
    +        token: String,
    +        flags: FTS5TokenFlags,
    +        for tokenization: FTS5Tokenization,
    +        tokenCallback: FTS5WrapperTokenCallback)
    +        throws
    +    {
    +        try tokenCallback(token, flags)
    +    }
    +}
    +
    + + See more +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

TableRequest +

+
+
+
    +
  • +
    + + + + TableRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that feed from a database table

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TableRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + TableRecord + +
    +
    +
    +
    +
    +
    +

    Types that adopt TableRecord declare a particular relationship with +a database table.

    + +

    Types that adopt both TableRecord and FetchableRecord are granted with +built-in methods that allow to fetch instances identified by key:

    +
    try Player.fetchOne(db, key: 123)  // Player?
    +try Citizenship.fetchOne(db, key: ["citizenId": 12, "countryId": 45]) // Citizenship?
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnExpression + +
    +
    +
    +
    +
    +
    +

    Adopt the ColumnExpression protocol when you define a column type.

    + +

    You can, for example, define a String-based column enum:

    +
    enum Columns: String, ColumnExpression {
    +    case id, name, score
    +}
    +let arthur = try Player.filter(Columns.name == "Arthur").fetchOne(db)
    +
    + +

    You can also define a genuine column type:

    +
    struct MyColumn: ColumnExpression {
    +    var name: String
    +    var sqlType: String
    +}
    +let nameColumn = MyColumn(name: "name", sqlType: "VARCHAR")
    +let arthur = try Player.filter(nameColumn == "Arthur").fetchOne(db)
    +
    + +

    See https://github.com/groue/GRDB.swift#the-query-interface

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol ColumnExpression : SQLSpecificExpressible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Association + +
    +
    +
    +
    +
    +
    +

    The base protocol for all associations that define a connection between two +record types.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol Association : DerivableRequest, _Association
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AssociationToOne +

+
+
+
    +
  • +
    + + + + AssociationToOne + +
    +
    +
    +
    +
    +
    +

    The base protocol for all associations that define a one-to-one connection.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol AssociationToOne : Association
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AssociationToMany +

+
+
+
    +
  • +
    + + + + AssociationToMany + +
    +
    +
    +
    +
    +
    +

    The base protocol for all associations that define a one-to-many connection.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol AssociationToMany : Association
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

TypedRequest +

+
+
+
    +
  • +
    + + + + TypedRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that know how database rows should +be interpreted.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TypedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SelectionRequest +

+
+
+
    +
  • +
    + + + + SelectionRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can refine their selection.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol SelectionRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FilteredRequest +

+
+
+
    +
  • +
    + + + + FilteredRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can be filtered.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol FilteredRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AggregatingRequest +

+
+
+
    +
  • +
    + + + + AggregatingRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can aggregate.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol AggregatingRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

OrderedRequest +

+
+
+
    +
  • +
    + + + + OrderedRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can be ordered.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol OrderedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

JoinableRequest +

+
+
+ +
+
+
+ + +
+ +

DerivableRequest +

+
+
+ +
+
+
+ + +
+ +

SQLSubqueryable +

+
+
+
    +
  • +
    + + + + SQLSubqueryable + +
    +
    +
    +
    +
    +
    +

    The protocol for types that can be embedded as a subquery.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol SQLSubqueryable : SQLSpecificExpressible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + VirtualTableModule + +
    +
    +
    +
    +
    +
    +

    The protocol for SQLite virtual table modules. It lets you define a DSL for +the Database.create(virtualTable:using:) method:

    +
    let module = ...
    +try db.create(virtualTable: "item", using: module) { t in
    +    ...
    +}
    +
    + +

    GRDB ships with three concrete classes that implement this protocol: FTS3, +FTS4 and FTS5.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol VirtualTableModule
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + EncodableRecord + +
    +
    +
    +
    +
    +
    +

    Types that adopt EncodableRecord can be encoded into the database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol EncodableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FetchableRecord + +
    +
    +
    +
    +
    +
    +

    Types that adopt FetchableRecord can be initialized from a database Row.

    +
    let row = try Row.fetchOne(db, sql: "SELECT ...")!
    +let player = Player(row)
    +
    + +

    The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single records:

    +
    try Player.fetchCursor(db, sql: "SELECT ...", arguments:...) // Cursor of Player
    +try Player.fetchAll(db, sql: "SELECT ...", arguments:...)    // [Player]
    +try Player.fetchOne(db, sql: "SELECT ...", arguments:...)    // Player?
    +
    +let statement = try db.makeStatement(sql: "SELECT ...")
    +try Player.fetchCursor(statement, arguments:...) // Cursor of Player
    +try Player.fetchAll(statement, arguments:...)    // [Player]
    +try Player.fetchOne(statement, arguments:...)    // Player?
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol FetchableRecord
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Types that adopt MutablePersistableRecord can be inserted, updated, +and deleted.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol MutablePersistableRecord : EncodableRecord, TableRecord
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

PersistableRecord +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/AggregatingRequest.html b/docs/5.16/Protocols/AggregatingRequest.html new file mode 100644 index 000000000..844490ef0 --- /dev/null +++ b/docs/5.16/Protocols/AggregatingRequest.html @@ -0,0 +1,1341 @@ + + + + AggregatingRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AggregatingRequest

+
+
+ +
public protocol AggregatingRequest
+ +
+
+

The protocol for all requests that can aggregate.

+ + +
+
+
+
    +
  • +
    + + + + group(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request grouped according to expressions promise.

    + +
    +

    Default Implementation

    +
    +

    Creates a request grouped according to expressions.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    + +
    +

    Default Implementation

    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func having(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AggregatingRequest +

+
+
+
    +
  • +
    + + + + group(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with a new grouping.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + group(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with a new grouping.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided sql added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided SQL literal added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/Association.html b/docs/5.16/Protocols/Association.html new file mode 100644 index 000000000..2a877d62f --- /dev/null +++ b/docs/5.16/Protocols/Association.html @@ -0,0 +1,1746 @@ + + + + Association Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Association

+
+
+ +
public protocol Association : DerivableRequest, _Association
+ +
+
+

The base protocol for all associations that define a connection between two +record types.

+ + +
+
+
+
    +
  • +
    + + + + OriginRowDecoder + +
    +
    +
    +
    +
    +
    +

    The record type at the origin of the association.

    + +

    In the belongsTo association below, it is Book:

    +
    struct Book: TableRecord {
    +    // BelongsToAssociation<Book, Author>
    +    static let author = belongsTo(Author.self)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + forKey(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates an association with the given key.

    + +

    This new key impacts how rows fetched from the resulting association +should be consumed:

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// Consume rows:
    +let request = Player.including(required: Player.team.forKey("custom"))
    +for row in Row.fetchAll(db, request) {
    +    let team: Team = row["custom"]
    +}
    +
    + +
    +

    Default Implementation

    +
    +

    Creates an association with the given key.

    + +

    This new key helps Decodable records decode rows fetched from the +resulting association:

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +struct PlayerInfo: FetchableRecord, Decodable {
    +    let player: Player
    +    let team: Team
    +
    +    static func all() -> QueryInterfaceRequest<PlayerInfo> {
    +        return Player
    +            .including(required: Player.team.forKey(CodingKeys.team))
    +            .asRequest(of: PlayerInfo.self)
    +    }
    +}
    +
    +let playerInfos = PlayerInfo.all().fetchAll(db)
    +print(playerInfos.first?.team)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func forKey(_ key: String) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.color = ‘red’” condition in the where +clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ...
    +// WHERE team.color = 'red'
    +let teamAlias = TableAlias()
    +let request = Player
    +    .including(required: Player.team.aliased(teamAlias))
    +    .filter(teamAlias[Column("color")] == "red")
    +
    + +

    When you give a name to a table alias, you can reliably inject sql +snippets in your requests:

    +
    // SELECT player.*, custom.*
    +// JOIN team custom ON ...
    +// WHERE custom.color = 'red'
    +let teamAlias = TableAlias(name: "custom")
    +let request = Player
    +    .including(required: Player.team.aliased(teamAlias))
    +    .filter(sql: "custom.color = ?", arguments: ["red"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func aliased(_ alias: TableAlias) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association which selects selection.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.color
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team.select { db in [Column("color")]
    +var request = Player.including(required: association)
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT player.*, team.color
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team
    +    .select { db in [Column("id")] }
    +    .select { db in [Column("color") }
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association which appends selection.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.color, team.name
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team
    +    .select([Column("color")])
    +    .annotated(with: { db in [Column("name")] })
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association with the provided predicate promise added to +the eventual set of already applied predicates.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId AND 1
    +let association = Player.team.filter { db in true }
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association with the provided orderings promise.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +// ORDER BY team.name
    +let association = Player.team.order { _ in [Column("name")] }
    +var request = Player.including(required: association)
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +// ORDER BY team.name
    +let association = Player.team
    +    .order{ _ in [Column("color")] }
    +    .reversed()
    +    .order{ _ in [Column("name")] }
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reversed() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association that reverses applied orderings.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +// ORDER BY team.name DESC
    +let association = Player.team.order(Column("name")).reversed()
    +var request = Player.including(required: association)
    +
    + +

    If no ordering was applied, the returned association is identical.

    +
    // SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team.reversed()
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reversed() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unordered() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association without any ordering.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team.order(Column("name")).unordered()
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unordered() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseTableName + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseTableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + group(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association grouped according to expressions promise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association with the provided predicate promise added to +the eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + distinct() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association for returns distinct rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func distinct() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an association that embeds the common table expression.

    + +

    See QueryInterfaceRequest.with(_:) for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/AssociationToMany.html b/docs/5.16/Protocols/AssociationToMany.html new file mode 100644 index 000000000..b6cafeeb5 --- /dev/null +++ b/docs/5.16/Protocols/AssociationToMany.html @@ -0,0 +1,1647 @@ + + + + AssociationToMany Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociationToMany

+
+
+ +
public protocol AssociationToMany : Association
+ +
+
+

The base protocol for all associations that define a one-to-many connection.

+ + +
+
+
+
+ + +
+ +

AssociationToMany +

+
+
+
    +
  • +
    + + + + forKey(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: String) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + count + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The number of associated records.

    + +

    It has a default name, which is “[key]Count”, where key is the key of +the association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var playerCount: Int
    +}
    +let request = Team.annotated(with: Team.players.count())
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.count() > 10).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var count: AssociationAggregate<OriginRowDecoder> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isEmpty + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate that is true if there exists no associated records.

    + +

    It has a default name, which is “hasNo[Key]”, where key is the key of +the association. For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var hasNoPlayer: Bool
    +}
    +let request = Team.annotated(with: Team.players.isEmpty())
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.isEmpty()).fetchAll(db)
    +let teams: [Team] = try Team.having(!Team.players.isEmpty())
    +let teams: [Team] = try Team.having(Team.players.isEmpty() == false)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: AssociationAggregate<OriginRowDecoder> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + average(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the average value of the given +expression in associated records.

    + +

    When the averaged expression is a column, the aggregate has a default +name which is “average[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var averagePlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.average(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.average(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean average(Column(...﹚﹚? If not, prefer average(value.databaseValue﹚ instead.")
    +public func average(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + average(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the average value of the given +expression in associated records.

    + +

    When the averaged expression is a column, the aggregate has a default +name which is “average[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var averagePlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.average(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.average(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func average(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + max(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the maximum value of the given +expression in associated records.

    + +

    When the maximized expression is a column, the aggregate has a default +name which is “maximum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var maxPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.max(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.max(Column("score")) < 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean max(Column(...﹚﹚? If not, prefer max(value.databaseValue﹚ instead.")
    +public func max(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + max(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the maximum value of the given +expression in associated records.

    + +

    When the maximized expression is a column, the aggregate has a default +name which is “maximum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var maxPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.max(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.max(Column("score")) < 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func max(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + min(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the minimum value of the given +expression in associated records.

    + +

    When the minimized expression is a column, the aggregate has a default +name which is “minimum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var minPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.min(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.min(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean min(Column(...﹚﹚? If not, prefer min(value.databaseValue﹚ instead.")
    +public func min(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + min(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the minimum value of the given +expression in associated records.

    + +

    When the minimized expression is a column, the aggregate has a default +name which is “minimum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var minPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.min(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.min(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func min(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sum(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the sum of the given expression +in associated records.

    + +

    When the summed expression is a column, the aggregate has a default +name which is “[key][Column]Sum”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var playerScoreSum: Double
    +}
    +let request = Team.annotated(with: Team.players.sum(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.sum(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean sum(Column(...﹚﹚? If not, prefer sum(value.databaseValue﹚ instead.")
    +public func sum(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sum(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the sum of the given expression +in associated records.

    + +

    When the summed expression is a column, the aggregate has a default +name which is “[key][Column]Sum”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var playerScoreSum: Double
    +}
    +let request = Team.annotated(with: Team.players.sum(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.sum(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func sum(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/AssociationToOne.html b/docs/5.16/Protocols/AssociationToOne.html new file mode 100644 index 000000000..3cac3dc78 --- /dev/null +++ b/docs/5.16/Protocols/AssociationToOne.html @@ -0,0 +1,1157 @@ + + + + AssociationToOne Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociationToOne

+
+
+ +
public protocol AssociationToOne : Association
+ +
+
+

The base protocol for all associations that define a one-to-one connection.

+ + +
+
+
+
+ + +
+ +

AssociationToOne +

+
+
+
    +
  • +
    + + + + forKey(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: String) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/ColumnExpression.html b/docs/5.16/Protocols/ColumnExpression.html new file mode 100644 index 000000000..f562188ce --- /dev/null +++ b/docs/5.16/Protocols/ColumnExpression.html @@ -0,0 +1,1339 @@ + + + + ColumnExpression Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnExpression

+
+
+ +
public protocol ColumnExpression : SQLSpecificExpressible
+ +
+
+

Adopt the ColumnExpression protocol when you define a column type.

+ +

You can, for example, define a String-based column enum:

+
enum Columns: String, ColumnExpression {
+    case id, name, score
+}
+let arthur = try Player.filter(Columns.name == "Arthur").fetchOne(db)
+
+ +

You can also define a genuine column type:

+
struct MyColumn: ColumnExpression {
+    var name: String
+    var sqlType: String
+}
+let nameColumn = MyColumn(name: "name", sqlType: "VARCHAR")
+let arthur = try Player.filter(nameColumn == "Arthur").fetchOne(db)
+
+ +

See https://github.com/groue/GRDB.swift#the-query-interface

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The unqualified name of a database column.

    + +

    “score” is a valid unqualified name. “player.score” is not.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var name: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + match(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A matching SQL expression with the MATCH SQL operator.

    +
    // content MATCH '...'
    +Column("content").match(pattern)
    +
    + +

    If the search pattern is nil, SQLite will evaluate the expression +to false.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func match(_ pattern: FTS3Pattern?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ColumnAssignment +

+
+
+
    +
  • +
    + + + + set(to:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an assignment to a value.

    +
    Column("valid").set(to: true)
    +Column("score").set(to: 0)
    +Column("score").set(to: nil)
    +Column("score").set(to: Column("score") + Column("bonus"))
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.updateAll(db, Column("score").set(to: 0))
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func set(to value: SQLExpressible?) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlExpression + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self == Column +

+
+
+
    +
  • +
    + + + + rowID + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The hidden rowID column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var rowID: Self { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/Cursor.html b/docs/5.16/Protocols/Cursor.html new file mode 100644 index 000000000..1981978f0 --- /dev/null +++ b/docs/5.16/Protocols/Cursor.html @@ -0,0 +1,2574 @@ + + + + Cursor Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Cursor

+
+
+ +
public protocol Cursor : AnyObject
+ +
+
+

A type that supplies the values of some external resource, one at a time.

+

Overview

+ +

The most common way to iterate over the elements of a cursor is to use a +while loop:

+
let cursor = ...
+while let element = try cursor.next() {
+    ...
+}
+
+

Relationship with standard Sequence and IteratorProtocol

+ +

Cursors share traits with lazy sequences and iterators from the Swift +standard library. Differences are:

+ +
    +
  • Cursor types are classes, and have a lifetime.
  • +
  • Cursor iteration may throw errors.
  • +
  • A cursor can not be repeated.
  • +
+ +

The protocol comes with default implementations for many operations similar +to those defined by Swift’s Sequence protocol: contains, dropFirst, +dropLast, drop(while:), enumerated, filter, first, flatMap, +forEach, joined, joined(separator:), max, max(by:), min, +min(by:), map, prefix, prefix(while:), reduce, reduce(into:), +suffix.

+ + +
+
+
+
    +
  • +
    + + + + Element + +
    +
    +
    +
    +
    +
    +

    The type of element traversed by the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype Element
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    +

    Advances to the next element and returns it, or nil if no next element +exists. Once nil has been returned, all subsequent calls return nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func next() throws -> Element?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Cursor +

+
+
+
    +
  • +
    + + + + isEmpty() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Boolean value indicating whether the cursor contains +an element.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isEmpty() throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + contains(where:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Boolean value indicating whether the cursor contains an +element that satisfies the given predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(where predicate: (Element) throws -> Bool) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + predicate + + +
    +

    A closure that takes an element of the cursor as +its argument and returns a Boolean value that indicates whether the +passed element represents a match.

    +
    +
    +
    +
    +

    Return Value

    +

    true if the cursor contains an element that satisfies +predicate; otherwise, false.

    +
    + +
    +
    +
  • +
  • +
    + + + + enumerated() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor of pairs (n, x), where n represents a consecutive +integer starting at zero, and x represents an element of the cursor.

    +
    let cursor = try String.fetchCursor(db, sql: "SELECT 'foo' UNION ALL SELECT 'bar'")
    +let c = cursor.enumerated()
    +while let (n, x) = c.next() {
    +    print("\(n): \(x)")
    +}
    +// Prints: "0: foo"
    +// Prints: "1: bar"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func enumerated() -> EnumeratedCursor<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of the cursor that satisfy the given predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ isIncluded: @escaping (Element) throws -> Bool) -> FilterCursor<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + first(where:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the first element of the cursor that satisfies the given +predicate or nil if no such element is found.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func first(where predicate: (Element) throws -> Bool) throws -> Element?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + compactMap(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated non-nil results of mapping +transform over this cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func compactMap<ElementOfResult>(_ transform: @escaping (Element) throws -> ElementOfResult?)
    +-> MapCursor<FilterCursor<MapCursor<Self, ElementOfResult?>>, ElementOfResult>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + drop(while:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor that skips any initial elements that satisfy +predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func drop(while predicate: @escaping (Element) throws -> Bool) -> DropWhileCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + predicate + + +
    +

    A closure that takes an element of the cursir as +its argument and returns true if the element should be skipped or +false otherwise. Once predicate returns false it will not be +called again.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + dropFirst(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor containing all but the given number of initial +elements.

    + +

    If the number of elements to drop exceeds the number of elements in +the cursor, the result is an empty cursor.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropFirst(2))
    +// Prints "[3, 4, 5]"
    +try print(numbers.dropFirst(10))
    +// Prints "[]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropFirst(_ n: Int) -> DropFirstCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + n + + +
    +

    The number of elements to drop from the beginning of +the cursor. n must be greater than or equal to zero.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor starting after the specified number of +elements.

    +
    + +
    +
    +
  • +
  • +
    + + + + dropFirst() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor containing all but the first element of the cursor.

    + +

    The following example drops the first element from a cursor of integers.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropFirst())
    +// Prints "[2, 3, 4, 5]"
    +
    + +

    If the cursor has no elements, the result is an empty cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropFirst() -> DropFirstCursor<Self>
    + +
    +
    +
    +

    Return Value

    +

    A cursor starting after the first element of the cursor.

    +
    + +
    +
    +
  • +
  • +
    + + + + dropLast(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array containing all but the given number of final +elements.

    + +

    The cursor must be finite. If the number of elements to drop exceeds +the number of elements in the cursor, the result is an empty array.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropLast(2))
    +// Prints "[1, 2, 3]"
    +try print(numbers.dropLast(10))
    +// Prints "[]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropLast(_ n: Int) throws -> [Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + n + + +
    +

    The number of elements to drop off the end of the +cursor. n must be greater than or equal to zero.

    +
    +
    +
    +
    +

    Return Value

    +

    An array leaving off the specified number of elements.

    +
    + +
    +
    +
  • +
  • +
    + + + + dropLast() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array containing all but the last element of the cursor.

    + +

    The following example drops the last element from a cursor of integers.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropLast())
    +// Prints "[1, 2, 3, 4]"
    +
    + +

    If the cursor has no elements, the result is an empty cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropLast() throws -> [Element]
    + +
    +
    +
    +

    Return Value

    +

    An array leaving off the last element of the cursor.

    +
    + +
    +
    +
  • +
  • +
    + + + + flatMap(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated results of mapping transform +over self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func flatMap<SegmentOfResult>(_ transform: @escaping (Element) throws -> SegmentOfResult)
    +-> FlattenCursor<MapCursor<Self, AnyCursor<SegmentOfResult.Element>>>
    +where SegmentOfResult: Sequence
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + flatMap(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated results of mapping transform +over self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func flatMap<SegmentOfResult>(_ transform: @escaping (Element) throws -> SegmentOfResult)
    +-> FlattenCursor<MapCursor<Self, SegmentOfResult>>
    +where SegmentOfResult: Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + forEach(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Calls the given closure on each element in the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forEach(_ body: (Element) throws -> Void) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + map(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the results of the transform function applied to +this cursor’s elements.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func map<T>(_ transform: @escaping (Element) throws -> T) -> MapCursor<Self, T>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + max(by:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the maximum element in the cursor, using the given predicate as +the comparison between elements.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func max(by areInIncreasingOrder: (Element, Element) throws -> Bool) throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s maximum element, according to +areInIncreasingOrder. If the cursor has no elements, returns nil.

    +
    + +
    +
    +
  • +
  • +
    + + + + min(by:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the minimum element in the cursor, using the given predicate as +the comparison between elements.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func min(by areInIncreasingOrder: (Element, Element) throws -> Bool) throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s minimum element, according to +areInIncreasingOrder. If the cursor has no elements, returns nil.

    +
    + +
    +
    +
  • +
  • +
    + + + + prefix(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor, up to the specified maximum length, containing the +initial elements of the cursor.

    + +

    If the maximum length exceeds the number of elements in the cursor, +the result contains all the elements in the cursor.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.prefix(2))
    +// Prints "[1, 2]"
    +try print(numbers.prefix(10))
    +// Prints "[1, 2, 3, 4, 5]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func prefix(_ maxLength: Int) -> PrefixCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + maxLength + + +
    +

    The maximum number of elements to return. The +value of maxLength must be greater than or equal to zero.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor starting at the beginning of this cursor +with at most maxLength elements.

    +
    + +
    +
    +
  • +
  • +
    + + + + prefix(while:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor of the initial consecutive elements that satisfy +predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func prefix(while predicate: @escaping (Element) throws -> Bool) -> PrefixWhileCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + predicate + + +
    +

    A closure that takes an element of the cursor as +its argument and returns true if the element should be included or +false otherwise. Once predicate returns false it will not be +called again.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + reduce(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the result of calling the given combining closure with each +element of this cursor and an accumulating value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reduce<Result>(
    +    _ initialResult: Result,
    +    _ nextPartialResult: (Result, Element) throws -> Result)
    +throws -> Result
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reduce(into:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the result of calling the given combining closure with each +element of this cursor and an accumulating value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reduce<Result>(
    +    into initialResult: Result,
    +    _ updateAccumulatingResult: (inout Result, Element) throws -> Void)
    +throws -> Result
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + suffix(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array, up to the given maximum length, containing the +final elements of the cursor.

    + +

    The cursor must be finite. If the maximum length exceeds the number of +elements in the cursor, the result contains all the elements in the +cursor.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.suffix(2))
    +// Prints "[4, 5]"
    +try print(numbers.suffix(10))
    +// Prints "[1, 2, 3, 4, 5]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func suffix(_ maxLength: Int) throws -> [Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + maxLength + + +
    +

    The maximum number of elements to return. The +value of maxLength must be greater than or equal to zero.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Equatable +

+
+
+
    +
  • +
    + + + + contains(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Boolean value indicating whether the cursor contains the +given element.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: Element) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Comparable +

+
+
+
    +
  • +
    + + + + max() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the maximum element in the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func max() throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s maximum element, according to +areInIncreasingOrder. If the cursor has no elements, returns +nil.

    +
    + +
    +
    +
  • +
  • +
    + + + + min() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the minimum element in the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func min() throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s minimum element, according to +areInIncreasingOrder. If the cursor has no elements, returns +nil.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Cursor +

+
+
+
    +
  • +
    + + + + joined() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of this cursor of cursors, concatenated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined() -> FlattenCursor<Self>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Sequence +

+
+
+
    +
  • +
    + + + + joined() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of this cursor of sequences, concatenated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined() -> FlattenCursor<MapCursor<Self, AnyCursor<Element.Element>>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: StringProtocol +

+
+
+
    +
  • +
    + + + + joined(separator:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of this cursor of sequences, concatenated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(separator: String = "") throws -> String
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DatabaseAggregate.html b/docs/5.16/Protocols/DatabaseAggregate.html new file mode 100644 index 000000000..76b4152a6 --- /dev/null +++ b/docs/5.16/Protocols/DatabaseAggregate.html @@ -0,0 +1,1243 @@ + + + + DatabaseAggregate Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseAggregate

+
+
+ +
public protocol DatabaseAggregate
+ +
+
+

The protocol for custom SQLite aggregates.

+ +

For example:

+
struct MySum : DatabaseAggregate {
+    var sum: Int = 0
+
+    mutating func step(_ dbValues: [DatabaseValue]) {
+        if let int = Int.fromDatabaseValue(dbValues[0]) {
+            sum += int
+        }
+    }
+
+    func finalize() -> DatabaseValueConvertible? {
+        return sum
+    }
+}
+
+let dbQueue = DatabaseQueue()
+let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
+try dbQueue.write { db in
+    db.add(function: fn)
+    try db.execute(sql: "CREATE TABLE test(i)")
+    try db.execute(sql: "INSERT INTO test(i) VALUES (1)")
+    try db.execute(sql: "INSERT INTO test(i) VALUES (2)")
+    try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + step(_:) + +
    +
    +
    +
    +
    +
    +

    This method is called at each step of the aggregation.

    + +

    The dbValues argument contains as many values as given to the SQL +aggregate function.

    + +

    – One value + SELECT maxLength(name) FROM player

    + +

    – Two values + SELECT maxFullNameLength(firstName, lastName) FROM player

    + +

    This method is never called after the finalize() method has been called.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func step(_ dbValues: [DatabaseValue]) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + finalize() + +
    +
    +
    +
    +
    +
    +

    Returns the final result

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func finalize() throws -> DatabaseValueConvertible?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DatabaseCancellable.html b/docs/5.16/Protocols/DatabaseCancellable.html new file mode 100644 index 000000000..5f1751b05 --- /dev/null +++ b/docs/5.16/Protocols/DatabaseCancellable.html @@ -0,0 +1,1146 @@ + + + + DatabaseCancellable Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseCancellable

+
+
+ +
public protocol DatabaseCancellable
+ +
+
+

A protocol indicating that an activity or action supports cancellation.

+ + +
+
+
+
    +
  • +
    + + + + cancel() + +
    +
    +
    +
    +
    +
    +

    Cancel the activity.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func cancel()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DatabaseReader.html b/docs/5.16/Protocols/DatabaseReader.html new file mode 100644 index 000000000..af307efd5 --- /dev/null +++ b/docs/5.16/Protocols/DatabaseReader.html @@ -0,0 +1,1847 @@ + + + + DatabaseReader Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseReader

+
+
+ +
public protocol DatabaseReader : AnyObject
+ +
+
+

DatabaseReader is the protocol for all types that can fetch values from +an SQLite database.

+ +

It is adopted by DatabaseQueue, DatabasePool, and DatabaseSnapshot.

+ +

The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

+ +

Types that adopt the protocol can provide in practice stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

+ +

Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

+ + +
+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    +

    Closes the database connection with the sqlite3_close() function.

    + +

    Note: You DO NOT HAVE to call this method, and you SHOULD NOT call +it unless the correct execution of your program depends on precise +database closing. Database connections are automatically closed when +they are deinitialized, and this is sufficient for most applications.

    + +

    If this method does not throw, then the database is properly closed, and +every future database access will throw a DatabaseError of +code SQLITE_MISUSE.

    + +

    Otherwise, there exists concurrent database accesses or living prepared +statements that prevent the database from closing, and this method +throws a DatabaseError of code SQLITE_BUSY. +See https://www.sqlite.org/c3ref/close.html for more information.

    + +

    After an error has been thrown, the database may still be opened, and +you can keep on accessing it. It may also remain in a “zombie” state, +in which case it will throw SQLITE_MISUSE for all future +database accesses.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    +

    This method causes any pending database operation to abort and return at +its earliest opportunity.

    + +

    It can be called from any thread.

    + +

    A call to interrupt() that occurs when there are no running SQL +statements is a no-op and has no effect on SQL statements that are +started after interrupt() returns.

    + +

    A database operation that is interrupted will throw a DatabaseError with +code SQLITE_INTERRUPT. If the interrupted SQL operation is an INSERT, +UPDATE, or DELETE that is inside an explicit transaction, then the +entire transaction will be rolled back automatically. If the rolled back +transaction was started by a transaction-wrapping method such as +DatabaseWriter.write or Database.inTransaction, then all database +accesses will throw a DatabaseError with code SQLITE_ABORT until the +wrapping method returns.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // interrupted:
    +    try Player(...).insert(db)     // throws SQLITE_INTERRUPT
    +    // not executed:
    +    try Player(...).insert(db)
    +}                                  // throws SQLITE_INTERRUPT
    +
    +try dbQueue.write { db in
    +    do {
    +        // interrupted:
    +        try Player(...).insert(db) // throws SQLITE_INTERRUPT
    +    } catch { }
    +    try Player(...).insert(db)     // throws SQLITE_ABORT
    +}                                  // throws SQLITE_ABORT
    +
    +try dbQueue.write { db in
    +    do {
    +        // interrupted:
    +        try Player(...).insert(db) // throws SQLITE_INTERRUPT
    +    } catch { }
    +}                                  // throws SQLITE_ABORT
    +
    + +

    When an application creates transaction without a transaction-wrapping +method, no SQLITE_ABORT error warns of aborted transactions:

    +
    try dbQueue.inDatabase { db in // or dbPool.writeWithoutTransaction
    +    try db.beginTransaction()
    +    do {
    +        // interrupted:
    +        try Player(...).insert(db) // throws SQLITE_INTERRUPT
    +    } catch { }
    +    try Player(...).insert(db)     // success
    +    try db.commit()                // throws SQLITE_ERROR "cannot commit - no transaction is active"
    +}
    +
    + +

    Both SQLITE_ABORT and SQLITE_INTERRUPT errors can be checked with the +DatabaseError.isInterruptionError property.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Read From Database +

+
+
+
    +
  • +
    + + + + read(_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes a read-only function that accepts a database +connection, and returns its result.

    + +

    For example:

    +
    let count = try reader.read { db in
    +    try Player.fetchCount(db)
    +}
    +
    + +

    The value function runs in an isolated fashion: eventual concurrent +database updates are not visible from the function:

    +
    try reader.read { db in
    +    // Those two values are guaranteed to be equal, even if the
    +    // `player` table is modified, between the two requests, by
    +    // some other database connection or some other thread.
    +    let count1 = try Player.fetchCount(db)
    +    let count2 = try Player.fetchCount(db)
    +}
    +
    +try reader.read { db in
    +    // Now this value may be different:
    +    let count = try Player.fetchCount(db)
    +}
    +
    + +

    Attempts to write in the database throw a DatabaseError with +resultCode SQLITE_READONLY.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try reader.read { db in
    +    // Raises a fatal error
    +    try reader.read { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by value, or any DatabaseError that would +happen while establishing the read access to the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func read<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + asyncRead(_:) + +
    +
    +
    +
    +
    +
    +

    Asynchronously executes a read-only function that accepts a +database connection.

    + +

    The value function runs in an isolated fashion: eventual concurrent +database updates are not visible from the function:

    +
    reader.asyncRead { dbResult in
    +    do {
    +        let db = try dbResult.get()
    +        // Those two values are guaranteed to be equal, even if the
    +        // `player` table is modified, between the two requests, by
    +        // some other database connection or some other thread.
    +        let count1 = try Player.fetchCount(db)
    +        let count2 = try Player.fetchCount(db)
    +    } catch {
    +        // handle error
    +    }
    +}
    +
    + +

    Attempts to write in the database throw a DatabaseError with +resultCode SQLITE_READONLY.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database. Its argument +is a Result that provides the database connection, or the failure +that would prevent establishing the read access to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + unsafeRead(_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes a function that accepts a database +connection, and returns its result.

    + +

    For example:

    +
    let count = try reader.unsafeRead { db in
    +    try Player.fetchCount(db)
    +}
    +
    + +

    The guarantees of the read method are lifted:

    + +

    the value function is not isolated: eventual concurrent database +updates are visible from the function:

    +
    try reader.unsafeRead { db in
    +    // Those two values can be different, because some other
    +    // database connection or some other thread may modify the
    +    // database between the two requests.
    +    let count1 = try Player.fetchCount(db)
    +    let count2 = try Player.fetchCount(db)
    +}
    +
    + +

    The value function is not prevented from writing (DatabaseQueue, in +particular, will accept database modifications in unsafeRead).

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try reader.read { db in
    +    // Raises a fatal error
    +    try reader.unsafeRead { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by value, or any DatabaseError that would +happen while establishing the read access to the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes a function that accepts a database +connection, and returns its result.

    + +

    The guarantees of the safe read method are lifted:

    + +

    the value function is not isolated: eventual concurrent database +updates are visible from the function:

    +
    try reader.unsafeReentrantRead { db in
    +    // Those two values can be different, because some other
    +    // database connection or some other thread may modify the
    +    // database between the two requests.
    +    let count1 = try Player.fetchCount(db)
    +    let count2 = try Player.fetchCount(db)
    +}
    +
    + +

    The value function is not prevented from writing (DatabaseQueue, in +particular, will accept database modifications in unsafeRead).

    + +

    This method is reentrant. It should be avoided because it fosters +dangerous concurrency practices.

    +
    +

    Throws

    + The error thrown by value, or any DatabaseError that would +happen while establishing the read access to the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Backup +

+
+
+
    +
  • +
    + + + + backup(to:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Copies the database contents into another database.

    + +

    The backup method blocks the current thread until the destination +database contains the same contents as the source database.

    + +

    When the source is a DatabasePool, concurrent writes can happen during +the backup. Those writes may, or may not, be reflected in the backup, +but they won’t trigger any error.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func backup(to writer: DatabaseWriter) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Database Values +

+
+
+
    +
  • +
    + + + + readPublisher(value:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously completes with a fetched value.

    +
    // DatabasePublishers.Read<[Player]>
    +let players = dbQueue.readPublisher { db in
    +    try Player.fetchAll(db)
    +}
    +
    + +

    Its value and completion are emitted on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func readPublisher<Output>(
    +    value: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Read<Output>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A closure which accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + readPublisher(receiveOn:value:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously completes with a fetched value.

    +
    // DatabasePublishers.Read<[Player]>
    +let players = dbQueue.readPublisher(
    +    receiveOn: DispatchQueue.global(),
    +    value: { db in try Player.fetchAll(db) })
    +
    + +

    Its value and completion are emitted on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func readPublisher<S, Output>(
    +    receiveOn scheduler: S,
    +    value: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Read<Output>
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    + + value + + +
    +

    A closure which accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DatabaseRegionConvertible.html b/docs/5.16/Protocols/DatabaseRegionConvertible.html new file mode 100644 index 000000000..4c3061dcf --- /dev/null +++ b/docs/5.16/Protocols/DatabaseRegionConvertible.html @@ -0,0 +1,1215 @@ + + + + DatabaseRegionConvertible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegionConvertible

+
+
+ +
public protocol DatabaseRegionConvertible
+ +
+
+

DatabaseRegionConvertible is the protocol for values that can be turned +into a DatabaseRegion.

+ +

Such values specify the region obserbed by DatabaseRegionObservation.

+ + +
+
+
+
    +
  • +
    + + + + databaseRegion(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a database region.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseRegion(_ db: Database) throws -> DatabaseRegion
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self == DatabaseRegion +

+
+
+
    +
  • +
    + + + + fullDatabase + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The region that covers the full database: all columns and all rows +from all tables.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var fullDatabase: Self { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DatabaseValueConvertible.html b/docs/5.16/Protocols/DatabaseValueConvertible.html new file mode 100644 index 000000000..468dbb6fb --- /dev/null +++ b/docs/5.16/Protocols/DatabaseValueConvertible.html @@ -0,0 +1,3706 @@ + + + + DatabaseValueConvertible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseValueConvertible

+
+
+ +
public protocol DatabaseValueConvertible : SQLExpressible, StatementBinding
+ +
+
+

Types that adopt DatabaseValueConvertible can be initialized from +database values.

+ +

The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single values:

+
try String.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String
+try String.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String]
+try String.fetchOne(db, sql: "SELECT name FROM ...", arguments:...)    // String?
+
+let statement = try db.makeStatement(sql: "SELECT name FROM ...")
+try String.fetchCursor(statement, arguments:...) // Cursor of String
+try String.fetchAll(statement, arguments:...)    // [String]
+try String.fetchOne(statement, arguments:...)    // String?
+
+ +

DatabaseValueConvertible is adopted by Bool, Int, String, etc.

+ + +
+
+
+ +
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • +
    + + + + fetchCursor(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchCursor(statement) // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> DatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchAll(statement)  // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a prepared statement.

    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let name = try String.fetchOne(statement)   // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • +
    + + + + fetchCursor(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from an SQL query.

    +
    let names = try String.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String
    +while let name = try name.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> DatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from an SQL query.

    +
    let names = try String.fetchAll(db, sql: "SELECT name FROM ...") // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from an SQL query.

    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    let name = try String.fetchOne(db, sql: "SELECT name FROM ...") // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchCursor(db, request) // Cursor of String
    +while let name = try name.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R>(_ db: Database, _ request: R) throws -> DatabaseValueCursor<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchAll(db, request) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Self] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a fetch request.

    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    let request = Player.filter(key: 1).select(Column("name"))
    +let name = try String.fetchOne(db, request) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Self? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchSet(statement)  // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from an SQL query.

    +
    let names = try String.fetchSet(db, sql: "SELECT name FROM ...") // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchSet(db, request) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • +
    + + + + fetchCursor(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchCursor(statement) // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> FastDatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchAll(statement)  // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let name = try String.fetchOne(statement)   // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchSet(statement)  // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • +
    + + + + fetchCursor(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from an SQL query.

    +
    let names = try String.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> FastDatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from an SQL query.

    +
    let names = try String.fetchAll(db, sql: "SELECT name FROM ...") // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from an SQL query.

    +
    let name = try String.fetchOne(db, sql: "SELECT name FROM ...") // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from an SQL query.

    +
    let names = try String.fetchSet(db, sql: "SELECT name FROM ...") // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchCursor(db, request) // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R: FetchRequest>(_ db: Database, _ request: R)
    +throws -> FastDatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchAll(db, request) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Self] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a fetch request.

    +
    let request = Player.filter(key: 1).select(Column("name"))
    +let name = try String.fetchOne(db, request) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Self? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchSet(db, request) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: ReferenceConvertible, Self.ReferenceType: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + databaseValue + + + Default implementation + +
    +
    +
    +
    +
    +
    + +
    +

    Default Implementation

    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    + +
    +

    Default Implementation

    +
    +

    Returns a value initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DatabaseWriter.html b/docs/5.16/Protocols/DatabaseWriter.html new file mode 100644 index 000000000..cfaa6db8a --- /dev/null +++ b/docs/5.16/Protocols/DatabaseWriter.html @@ -0,0 +1,2286 @@ + + + + DatabaseWriter Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseWriter

+
+
+ +
public protocol DatabaseWriter : DatabaseReader
+ +
+
+

DatabaseWriter is the protocol for all types that can write into an +SQLite database.

+ +

It is adopted by DatabaseQueue and DatabasePool.

+ +

The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

+ +

Types that adopt the protocol can in practice provide stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

+ +

Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

+ + +
+
+
+
+ + +
+ +

Writing in Database +

+
+
+
    +
  • +
    + + + + write(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction, and returns the result.

    + +

    If the updates throw an error, the transaction is rollbacked and the +error is rethrown.

    + +

    Eventual concurrent database updates are postponed until the transaction +has completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try writer.write { db in
    +    // Raises a fatal error
    +    try writer.write { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates, or by the +wrapping transaction. + +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func write<T>(_ updates: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Eventual concurrent database updates are postponed until the updates +are completed.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try writer.write { db in
    +    // Raises a fatal error
    +    try writer.writeWithoutTransaction { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Updates are guaranteed an exclusive access to the database. They wait +until all pending writes and reads are completed. They postpone all +other writes and reads until they are completed.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try writer.write { db in
    +    // Raises a fatal error
    +    try writer.barrierWriteWithoutTransaction { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Updates are guaranteed an exclusive access to the database. They wait +until all pending writes and reads are completed. They postpone all +other writes and reads until they are completed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + asyncWrite(_:completion:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction.

    + +

    If the updates throw an error, the transaction is rollbacked.

    + +

    The completion closure is always called with the result of the +database updates. Its arguments are a database connection and the +result of the transaction. This result is a failure if the transaction +could not be committed.

    + +

    Eventual concurrent database updates are postponed until the transaction +and the completion closure have completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    This method is not reentrant.

    +
    +

    Throws

    + The error thrown by the updates, or by the wrapping transaction. + +
    + +
    +

    Default Implementation

    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction.

    + +

    If the updates throw an error, the transaction is rollbacked.

    + +

    The completion closure is always called with the result of the +database updates. Its arguments are a database connection and the +result of the transaction. This result is a failure if the transaction +could not be committed. The completion closure is executed in a +protected dispatch queue, outside of any transaction.

    + +

    Eventual concurrent database updates are postponed until the transaction +and the completion closure have completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    This method is not reentrant.

    +
    +

    Throws

    + The error thrown by the updates, or by the wrapping transaction. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncWrite<T>(
    +    _ updates: @escaping (Database) throws -> T,
    +    completion: @escaping (Database, Result<T, Error>) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    + + completion + + +
    +

    A closure that is called with the eventual +transaction error.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +outside of any transaction.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Eventual concurrent database updates are postponed until the updates +are completed.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +

    This method is reentrant. It should be avoided because it fosters +dangerous concurrency practices.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+
    +
  • +
    + + + + concurrentRead(_:) + +
    +
    +
    +
    +
    +
    +

    Concurrently executes a read-only block in a protected dispatch queue.

    + +

    This method must be called from a writing dispatch queue, outside of any +transaction. You’ll get a fatal error otherwise.

    + +

    The block argument is guaranteed to see the database in the last +committed state at the moment this method is called. Eventual concurrent +database updates are not visible inside the block.

    + +

    To access the fetched results, you call the wait() method of the +returned future, on any dispatch queue.

    + +

    In the example below, the number of players is fetched concurrently with +the player insertion. Yet the future is guaranteed to return zero:

    +
    try writer.writeWithoutTransaction { db in
    +    // Delete all players
    +    try Player.deleteAll()
    +
    +    // Count players concurrently
    +    let future = writer.concurrentRead { db in
    +        return try Player.fetchCount()
    +    }
    +
    +    // Insert a player
    +    try Player(...).insert(db)
    +
    +    // Guaranteed to be zero
    +    let count = try future.wait()
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Transaction Observers +

+
+
+
    +
  • +
    + + + + add(transactionObserver:extent:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Add a transaction observer, so that it gets notified of +database changes.

    + +

    To remove the observer, use DatabaseReader.remove(transactionObserver:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(
    +    transactionObserver: TransactionObserver,
    +    extent: Database.TransactionObservationExtent = .observerLifetime)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + transactionObserver + + +
    +

    A transaction observer.

    +
    +
    + + extent + + +
    +

    The duration of the observation. The default is +the observer lifetime (observation lasts until observer +is deallocated).

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove(transactionObserver:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(transactionObserver: TransactionObserver)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Erasing the content of the database +

+
+
+
    +
  • +
    + + + + erase() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Erases the content of the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func erase() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Claiming Disk Space +

+
+
+
    +
  • +
    + + + + vacuum() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Rebuilds the database file, repacking it into a minimal amount of +disk space.

    + +

    See https://www.sqlite.org/lang_vacuum.html for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func vacuum() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + vacuum(into:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a new database file at the specified path with a minimum +amount of disk space.

    + +

    Databases encrypted with SQLCipher are copied with the same password +and configuration as the original database.

    + +

    See https://www.sqlite.org/lang_vacuum.html#vacuuminto for more information.

    + +
    +
    +
    +
  • +
  • +
    + + + + vacuum(into:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a new database file at the specified path with a minimum +amount of disk space. +See https://www.sqlite.org/lang_vacuum.html#vacuuminto for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 11.0, iOS 14, tvOS 14, watchOS 7, *)
    +public func vacuum(into filePath: String) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + filePath + + +
    +

    file path for new database

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Database Updates +

+
+
+
    +
  • +
    + + + + writePublisher(updates:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher { db -> Int in
    +    try Player(...).insert(db)
    +    return try Player.fetchCount(db)
    +}
    +
    + +

    Its value and completion are emitted on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<Output>(
    +    updates: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + writePublisher(receiveOn:updates:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher(
    +    receiveOn: DispatchQueue.global(),
    +    updates: { db -> Int in
    +        try Player(...).insert(db)
    +        return try Player.fetchCount(db)
    +    })
    +
    + +

    Its value and completion are emitted on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<S, Output>(
    +    receiveOn scheduler: S,
    +    updates: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + writePublisher(updates:thenRead:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher(
    +    updates: { db in try Player(...).insert(db) }
    +    thenRead: { db, _ in try Player.fetchCount(db) })
    +
    + +

    Its value and completion are emitted on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<T, Output>(
    +    updates: @escaping (Database) throws -> T,
    +    thenRead value: @escaping (Database, T) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    + + value + + +
    +

    A closure which reads from the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + writePublisher(receiveOn:updates:thenRead:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher(
    +    receiveOn: DispatchQueue.global(),
    +    updates: { db in try Player(...).insert(db) }
    +    thenRead: { db, _ in try Player.fetchCount(db) })
    +
    + +

    Its value and completion are emitted on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<S, T, Output>(
    +    receiveOn scheduler: S,
    +    updates: @escaping (Database) throws -> T,
    +    thenRead value: @escaping (Database, T) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    + + value + + +
    +

    A closure which reads from the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/DerivableRequest.html b/docs/5.16/Protocols/DerivableRequest.html new file mode 100644 index 000000000..2d9eb3f7e --- /dev/null +++ b/docs/5.16/Protocols/DerivableRequest.html @@ -0,0 +1,1344 @@ + + + + DerivableRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DerivableRequest

+
+ +
+

The base protocol for all requests that can be refined.

+ + +
+
+
+
    +
  • +
    + + + + distinct() + +
    +
    +
    +
    +
    +
    +

    Creates a request which returns distinct rows.

    +
    // SELECT DISTINCT * FROM player
    +var request = Player.all()
    +request = request.distinct()
    +
    +// SELECT DISTINCT name FROM player
    +var request = Player.select(Column("name"))
    +request = request.distinct()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func distinct() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a request which embeds the common table expression.

    + +

    If a common table expression with the same table name had already been +embedded, it is replaced by the new one.

    + +

    For example, you can build a request that fetches all chats with their +latest message:

    +
    let latestMessageRequest = Message
    +    .annotated(with: max(Column("date")))
    +    .group(Column("chatID"))
    +
    +let latestMessageCTE = CommonTableExpression(
    +    named: "latestMessage",
    +    request: latestMessageRequest)
    +
    +let latestMessage = Chat.association(
    +    to: latestMessageCTE,
    +    on: { chat, latestMessage in
    +        chat[Column("id")] == latestMessage[Column("chatID")]
    +    })
    +
    +// WITH latestMessage AS
    +//   (SELECT *, MAX(date) FROM message GROUP BY chatID)
    +// SELECT chat.*, latestMessage.*
    +// FROM chat
    +// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
    +let request = Chat.all()
    +    .with(latestMessageCTE)
    +    .including(optional: latestMessage)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DerivableRequest +

+
+
+
    +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends aggregates to the current selection.

    +
    // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount
    +// FROM team LEFT JOIN player ...
    +var request = Team.all()
    +request = request.annotated(with: Team.players.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: AssociationAggregate<RowDecoder>...) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends aggregates to the current selection.

    +
    // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount
    +// FROM team LEFT JOIN player ...
    +var request = team.all()
    +request = request.annotated(with: [Team.players.count])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends the provided aggregate predicate to +the eventual set of already applied predicates.

    +
    // SELECT team.*
    +// FROM team LEFT JOIN player ...
    +// HAVING COUNT(DISTINCT player.id) = 0
    +var request = Team.all()
    +request = request.having(Team.players.isEmpty)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: AssociationAggregate<RowDecoder>) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/EncodableRecord.html b/docs/5.16/Protocols/EncodableRecord.html new file mode 100644 index 000000000..60e0f3d24 --- /dev/null +++ b/docs/5.16/Protocols/EncodableRecord.html @@ -0,0 +1,1577 @@ + + + + EncodableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

EncodableRecord

+
+
+ +
public protocol EncodableRecord
+ +
+
+

Types that adopt EncodableRecord can be encoded into the database.

+ + +
+
+
+
    +
  • +
    + + + + encode(to:) + +
    +
    +
    +
    +
    +
    +

    Encodes the record into database values.

    + +

    Store in the container argument all values that should be stored in +the columns of the database table (see databaseTableName()).

    + +

    Primary key columns, if any, must be included.

    +
    struct Player: EncodableRecord {
    +    var id: Int64?
    +    var name: String?
    +
    +    func encode(to container: inout PersistenceContainer) {
    +        container["id"] = id
    +        container["name"] = name
    +    }
    +}
    +
    + +

    It is undefined behavior to set different values for the same column. +Column names are case insensitive, so defining both “name” and “NAME” +is considered undefined behavior.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func encode(to container: inout PersistenceContainer)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Customizing the Format of Database Columns +

+
+
+
    +
  • +
    + + + + databaseEncodingUserInfo + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, you can use this dictionary to customize the encoding process +into database rows.

    + +

    For example:

    +
    // A key that holds a encoder's name
    +let encoderName = CodingUserInfoKey(rawValue: "encoderName")!
    +
    +struct Player: PersistableRecord, Encodable {
    +    // Customize the encoder name when encoding a database row
    +    static let databaseEncodingUserInfo: [CodingUserInfoKey: Any] = [encoderName: "Database"]
    +
    +    func encode(to encoder: Encoder) throws {
    +        // Print the encoder name
    +        print(encoder.userInfo[encoderName])
    +        ...
    +    }
    +}
    +
    +let player = Player(...)
    +
    +// prints "Database"
    +try player.insert(db)
    +
    +// prints "JSON"
    +let encoder = JSONEncoder()
    +encoder.userInfo = [encoderName: "JSON"]
    +let data = try encoder.encode(player)
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseEncodingUserInfo: [CodingUserInfoKey : Any] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseJSONEncoder(for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this method controls the encoding process of nested properties +into JSON database columns.

    + +

    The default implementation returns a JSONEncoder with the +following properties:

    + +
      +
    • dataEncodingStrategy: .base64
    • +
    • dateEncodingStrategy: .millisecondsSince1970
    • +
    • nonConformingFloatEncodingStrategy: .throw
    • +
    • outputFormatting: .sortedKeys (iOS 11.0+, macOS 10.13+, tvOS 11.0+, watchOS 4.0+)
    • +
    + +

    You can override those defaults:

    +
    struct Achievement: Encodable {
    +    var name: String
    +    var date: Date
    +}
    +
    +struct Player: Encodable, PersistableRecord {
    +    // stored in a JSON column
    +    var achievements: [Achievement]
    +
    +    static func databaseJSONEncoder(for column: String) -> JSONEncoder {
    +        let encoder = JSONEncoder()
    +        encoder.dateEncodingStrategy = .iso8601
    +        return encoder
    +    }
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static func databaseJSONEncoder(for column: String) -> JSONEncoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDateEncodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this property controls the encoding of date properties.

    + +

    Default value is .deferredToDate

    + +

    For example:

    +
    struct Player: PersistableRecord, Encodable {
    +    static let databaseDateEncodingStrategy: DatabaseDateEncodingStrategy = .timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // encoded as an epoch timestamp
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseDateEncodingStrategy: DatabaseDateEncodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseUUIDEncodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this property controls the encoding of UUID properties.

    + +

    Default value is .deferredToUUID

    + +

    For example:

    +
    struct Player: PersistableProtocol, Encodable {
    +    static let databaseUUIDEncodingStrategy: DatabaseUUIDEncodingStrategy = .uppercaseString
    +
    +    // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
    +    var uuid: UUID
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseUUIDEncodingStrategy: DatabaseUUIDEncodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseColumnEncodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this property controls the key encoding strategy.

    + +

    Default value is .useDefaultKeys

    + +

    For example:

    +
    struct Player: PersistableProtocol, Encodable {
    +    static let databaseColumnEncodingStrategy: DatabaseColumnEncodingStrategy = .convertToSnakeCase
    +
    +    // encoded as player_id
    +    var playerID: String
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseColumnEncodingStrategy: DatabaseColumnEncodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDictionary + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A dictionary whose keys are the columns encoded in the encode(to:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseDictionary: [String : DatabaseValue] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Record Comparison +

+
+
+
    +
  • +
    + + + + databaseEquals(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a boolean indicating whether this record and the other record +have the same database representation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseEquals(_ record: Self) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseChanges(from:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A dictionary of values changed from the other record.

    + +

    Its keys are column names. Its values come from the other record.

    + +

    Note that this method is not symmetrical, not only in terms of values, +but also in terms of columns. When the two records don’t define the +same set of columns in their encode(to:) method, only the columns +defined by the receiver record are considered.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseChanges<Record>(from record: Record) -> [String : DatabaseValue] where Record : EncodableRecord
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/FTS5CustomTokenizer.html b/docs/5.16/Protocols/FTS5CustomTokenizer.html new file mode 100644 index 000000000..1c2bf8fc7 --- /dev/null +++ b/docs/5.16/Protocols/FTS5CustomTokenizer.html @@ -0,0 +1,1182 @@ + + + + FTS5CustomTokenizer Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5CustomTokenizer

+

The protocol for custom FTS5 tokenizers.

+ +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the tokenizer; should uniquely identify your custom +tokenizer.

    + +
    +
    +
    +
  • +
  • +
    + + + + init(db:arguments:) + +
    +
    +
    +
    +
    +
    +

    Creates a custom tokenizer.

    + +

    The arguments parameter is an array of String built from the CREATE +VIRTUAL TABLE statement. In the example below, the arguments will +be ["arg1", "arg2"].

    +
    CREATE VIRTUAL TABLE document USING fts5(
    +    tokenize='custom arg1 arg2'
    +)
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + tokenizerDescriptor(arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an FTS5 tokenizer descriptor.

    +
    class MyTokenizer : FTS5CustomTokenizer { ... }
    +
    +db.create(virtualTable: "book", using: FTS5()) { t in
    +    let tokenizer = MyTokenizer.tokenizerDescriptor(arguments: ["unicode61", "remove_diacritics", "0"])
    +    t.tokenizer = tokenizer
    +}
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/FTS5Tokenizer.html b/docs/5.16/Protocols/FTS5Tokenizer.html new file mode 100644 index 000000000..914a05edb --- /dev/null +++ b/docs/5.16/Protocols/FTS5Tokenizer.html @@ -0,0 +1,1197 @@ + + + + FTS5Tokenizer Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5Tokenizer

+

The protocol for FTS5 tokenizers

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Tokenizes the text described by pText and nText, and +notifies found tokens to the tokenCallback function.

    + +

    It matches the xTokenize function documented at https://www.sqlite.org/fts5.html#custom_tokenizers

    + +
    +
    +
    +
  • +
  • +
    + + + + tokenize(document:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Tokenizes the string argument as a document that would be inserted into +an FTS5 table.

    + +

    For example:

    +
    let tokenizer = try db.makeTokenizer(.ascii())
    +try tokenizer.tokenize(document: "foo bar") // [("foo", flags), ("bar", flags)]
    +
    + +

    See also tokenize(query:).

    +
    +

    Throws

    + An error if tokenization fails. + +
    + +
    +
    +
    +
  • +
  • +
    + + + + tokenize(query:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Tokenizes the string argument as an FTS5 query.

    + +

    For example:

    +
    let tokenizer = try db.makeTokenizer(.ascii())
    +try tokenizer.tokenize(query: "foo bar") // [("foo", flags), ("bar", flags)]
    +
    + +

    See also tokenize(document:).

    +
    +

    Throws

    + An error if tokenization fails. + +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/FTS5WrapperTokenizer.html b/docs/5.16/Protocols/FTS5WrapperTokenizer.html new file mode 100644 index 000000000..06f5335b4 --- /dev/null +++ b/docs/5.16/Protocols/FTS5WrapperTokenizer.html @@ -0,0 +1,1218 @@ + + + + FTS5WrapperTokenizer Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5WrapperTokenizer

+

The protocol for custom FTS5 tokenizers that wrap another tokenizer.

+ +

Types that adopt FTS5WrapperTokenizer don’t have to implement the +low-level FTS5Tokenizer.tokenize(context:flags:pText:nText:tokenCallback:).

+ +

Instead, they process regular Swift strings.

+ +

Here is the implementation for a trivial tokenizer that wraps the +built-in ascii tokenizer without any custom processing:

+
class TrivialAsciiTokenizer : FTS5WrapperTokenizer {
+    static let name = "trivial"
+    let wrappedTokenizer: FTS5Tokenizer
+
+    init(db: Database, arguments: [String]) throws {
+        wrappedTokenizer = try db.makeTokenizer(.ascii())
+    }
+
+    func accept(
+        token: String,
+        flags: FTS5TokenFlags,
+        for tokenization: FTS5Tokenization,
+        tokenCallback: FTS5WrapperTokenCallback)
+        throws
+    {
+        try tokenCallback(token, flags)
+    }
+}
+
+ +
+
+
+
    +
  • +
    + + + + wrappedTokenizer + +
    +
    +
    +
    +
    +
    +

    The wrapped tokenizer

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Given a token produced by the wrapped tokenizer, notifies customized +tokens to the tokenCallback function.

    + +

    For example:

    +
    func accept(
    +    token: String,
    +    flags: FTS5TokenFlags,
    +    for tokenization: FTS5Tokenization,
    +    tokenCallback: FTS5WrapperTokenCallback)
    +    throws
    +{
    +    // pass through:
    +    try tokenCallback(token, flags)
    +}
    +
    + +

    When implementing the accept method, there are a two rules +to observe:

    + +
      +
    1. Errors thrown by the tokenCallback function must not be caught.

    2. +
    3. The input flags should be given unmodified to the tokenCallback +function, unless you union it with the .colocated flag when the +tokenizer produces synonyms (see +https://www.sqlite.org/fts5.html#synonym_support).

    4. +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Default implementation

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/FetchRequest.html b/docs/5.16/Protocols/FetchRequest.html new file mode 100644 index 000000000..c52d05128 --- /dev/null +++ b/docs/5.16/Protocols/FetchRequest.html @@ -0,0 +1,3136 @@ + + + + FetchRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FetchRequest

+
+
+ +
public protocol FetchRequest : DatabaseRegionConvertible, SQLSubqueryable
+ +
+
+

The protocol for all requests that fetch database rows, and tell how those +rows should be interpreted.

+
struct Player: FetchableRecord { ... }
+let request: ... // Some FetchRequest that fetches Player
+try request.fetchCursor(db) // Cursor of Player
+try request.fetchAll(db)    // [Player]
+try request.fetchSet(db)    // Set<Player>
+try request.fetchOne(db)    // Player?
+try request.fetchCount(db)  // Int
+
+ + +
+
+
+
    +
  • +
    + + + + RowDecoder + +
    +
    +
    +
    +
    +
    +

    The type that tells how fetched database rows should be interpreted.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a PreparedRequest that is ready to be executed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func makePreparedRequest(_ db: Database, forSingleResult singleResult: Bool) throws -> PreparedRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + singleResult + + +
    +

    A hint that a single result row will be +consumed. Implementations can optionally use it to optimize the +prepared statement, for example by adding a LIMIT 1 SQL clause.

    + +

    // Calls makePreparedRequest(db, forSingleResult: true) + try request.fetchOne(db)

    + +

    // Calls makePreparedRequest(db, forSingleResult: false) + try request.fetchAll(db)

    +
    +
    +
    +
    +

    Return Value

    +

    A prepared request.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the number of rows fetched by the request.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func fetchCount(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FetchRequest +

+
+
+
    +
  • +
    + + + + databaseRegion(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the database region that the request feeds from.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseRegion(_ db: Database) throws -> DatabaseRegion
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AdaptedFetchRequest +

+
+
+ +
+
+
+ + +
+ +

Fetching Values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchCursor(db) // Cursor of String
    +while let string = try strings.next() {   // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> DatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Optional values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchCursor(db) // Cursor of String?
    +while let string = try strings.next() {   // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> NullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String?
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Rows +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched rows.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let rows = try request.fetchCursor(db) // RowCursor
    +while let row = try rows.next() {  // Row
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched rows.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let rows = try request.fetchAll(db)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched rows.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let rows = try request.fetchSet(db)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched row.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let row = try request.fetchOne(db)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchCursor(db) // Cursor of String
    +while let string = try strings.next() {   // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastDatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Optional values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchCursor(db) // Cursor of String?
    +while let string = try strings.next() {   // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastNullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String?
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Records +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched records.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let players = try request.fetchCursor(db) // Cursor of Player
    +while let player = try players.next() {   // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RecordCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched records.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let players = try request.fetchAll(db) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched record.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let player = try request.fetchOne(db) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: FetchableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched records.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let players = try request.fetchSet(db) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/FetchableRecord.html b/docs/5.16/Protocols/FetchableRecord.html new file mode 100644 index 000000000..a472078df --- /dev/null +++ b/docs/5.16/Protocols/FetchableRecord.html @@ -0,0 +1,4221 @@ + + + + FetchableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FetchableRecord

+
+
+ +
public protocol FetchableRecord
+ +
+
+

Types that adopt FetchableRecord can be initialized from a database Row.

+
let row = try Row.fetchOne(db, sql: "SELECT ...")!
+let player = Player(row)
+
+ +

The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single records:

+
try Player.fetchCursor(db, sql: "SELECT ...", arguments:...) // Cursor of Player
+try Player.fetchAll(db, sql: "SELECT ...", arguments:...)    // [Player]
+try Player.fetchOne(db, sql: "SELECT ...", arguments:...)    // Player?
+
+let statement = try db.makeStatement(sql: "SELECT ...")
+try Player.fetchCursor(statement, arguments:...) // Cursor of Player
+try Player.fetchAll(statement, arguments:...)    // [Player]
+try Player.fetchOne(statement, arguments:...)    // Player?
+
+ + +
+
+
+
+ + +
+ +

Row Decoding +

+
+
+
    +
  • +
    + + + + init(row:) + +
    +
    +
    +
    +
    +
    +

    Creates a record from row.

    + +

    For performance reasons, the row argument may be reused during the +iteration of a fetch query. If you want to keep the row for later use, +make sure to store a copy: self.row = row.copy().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    init(row: Row)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Customizing the Format of Database Columns +

+
+
+
    +
  • +
    + + + + databaseDecodingUserInfo + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, you can use this dictionary to customize the decoding process +from database rows.

    + +

    For example:

    +
    // A key that holds a decoder's name
    +let decoderName = CodingUserInfoKey(rawValue: "decoderName")!
    +
    +// A FetchableRecord + Decodable record
    +struct Player: FetchableRecord, Decodable {
    +    // Customize the decoder name when decoding a database row
    +    static let databaseDecodingUserInfo: [CodingUserInfoKey: Any] = [decoderName: "Database"]
    +
    +    init(from decoder: Decoder) throws {
    +        // Print the decoder name
    +        print(decoder.userInfo[decoderName])
    +        ...
    +    }
    +}
    +
    +// prints "Database"
    +let player = try Player.fetchOne(db, ...)
    +
    +// prints "JSON"
    +let decoder = JSONDecoder()
    +decoder.userInfo = [decoderName: "JSON"]
    +let player = try decoder.decode(Player.self, from: ...)
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseDecodingUserInfo: [CodingUserInfoKey : Any] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseJSONDecoder(for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, this method controls the decoding process of nested properties +from JSON database columns.

    + +

    The default implementation returns a JSONDecoder with the +following properties:

    + +
      +
    • dataDecodingStrategy: .base64
    • +
    • dateDecodingStrategy: .millisecondsSince1970
    • +
    • nonConformingFloatDecodingStrategy: .throw
    • +
    + +

    You can override those defaults:

    +
    struct Achievement: Decodable {
    +    var name: String
    +    var date: Date
    +}
    +
    +struct Player: Decodable, FetchableRecord {
    +    // stored in a JSON column
    +    var achievements: [Achievement]
    +
    +    static func databaseJSONDecoder(for column: String) -> JSONDecoder {
    +        let decoder = JSONDecoder()
    +        decoder.dateDecodingStrategy = .iso8601
    +        return decoder
    +    }
    +}
    +
    + +
    +

    Default Implementation

    +
    +

    Returns a JSONDecoder with the following properties:

    + +
      +
    • dataDecodingStrategy: .base64
    • +
    • dateDecodingStrategy: .millisecondsSince1970
    • +
    • nonConformingFloatDecodingStrategy: .throw
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static func databaseJSONDecoder(for column: String) -> JSONDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDateDecodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, this property controls the decoding of date properties.

    + +

    Default value is .deferredToDate

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseDateDecodingStrategy: DatabaseDateDecodingStrategy = .timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // decoded from epoch timestamp
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseDateDecodingStrategy: DatabaseDateDecodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseColumnDecodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, this property controls the key decoding strategy.

    + +

    Default value is .useDefaultKeys

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseDateDecodingStrategy: DatabaseColumnDecodingStrategy = .convertFromSnakeCase
    +
    +    var playerID: String // decoded from player_id
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseColumnDecodingStrategy: DatabaseColumnDecodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • +
    + + + + fetchCursor(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over records fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let players = try Player.fetchCursor(statement) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let players = try Player.fetchAll(statement) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let player = try Player.fetchOne(statement) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • +
    + + + + fetchCursor(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records fetched from an SQL query.

    +
    let players = try Player.fetchCursor(db, sql: "SELECT * FROM player") // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records fetched from an SQL query.

    +
    let players = try Player.fetchAll(db, sql: "SELECT * FROM player") // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record fetched from an SQL query.

    +
    let player = try Player.fetchOne(db, sql: "SELECT * FROM player") // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records fetched from a fetch request.

    +
    let request = try Player.all()
    +let players = try Player.fetchCursor(db, request) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R>(_ db: Database, _ request: R) throws -> RecordCursor<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records fetched from a fetch request.

    +
    let request = try Player.all()
    +let players = try Player.fetchAll(db, request) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Self] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record fetched from a fetch request.

    +
    let request = try Player.filter(key: 1)
    +let player = try Player.fetchOne(db, request) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Self? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching All +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over all records fetched from the database.

    +
    // SELECT * FROM player
    +let players = try Player.fetchCursor(db) // Cursor of Player
    +while let player = try players.next() {  // Player
    +    ...
    +}
    +
    + +

    Records are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(_ db: Database) throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of all records fetched from the database.

    +
    // SELECT * FROM player
    +let players = try Player.fetchAll(db) // [Player]
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(_ db: Database) throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first found record.

    +
    // SELECT * FROM player LIMIT 1
    +let player = try Player.fetchOne(db) // Player?
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of all records fetched from the database.

    +
    // SELECT * FROM player
    +let players = try Player.fetchSet(db) // Set<Player>
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(_ db: Database) throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + fetchCursor(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records, given their primary keys.

    +
    let players = try Player.fetchCursor(db, keys: [1, 2, 3]) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<Sequence>(_ db: Database, keys: Sequence)
    +throws -> RecordCursor<Self>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records, given their primary keys.

    +
    let players = try Player.fetchAll(db, keys: [1, 2, 3]) // [Player]
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<Sequence>(_ db: Database, keys: Sequence)
    +throws -> [Self]
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record given its primary key.

    +
    let player = try Player.fetchOne(db, key: 123) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType?)
    +throws -> Self?
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCursor(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records, given their primary keys.

    +
    let players = try Player.fetchCursor(db, ids: [1, 2, 3]) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<Collection>(_ db: Database, ids: Collection)
    +throws -> RecordCursor<Self>
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records, given their primary keys.

    +
    let players = try Player.fetchAll(db, ids: [1, 2, 3]) // [Player]
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<Collection>(_ db: Database, ids: Collection)
    +throws -> [Self]
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record given its primary key.

    +
    let player = try Player.fetchOne(db, id: 123) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database, id: ID) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCursor(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records, given their primary keys.

    +
    let players = try Player.fetchCursor(db, ids: [1, 2, 3]) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<Collection>(_ db: Database, ids: Collection)
    +throws -> RecordCursor<Self>
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records, given their primary keys.

    +
    let players = try Player.fetchAll(db, ids: [1, 2, 3]) // [Player]
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<Collection>(_ db: Database, ids: Collection)
    +throws -> [Self]
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record given its primary key.

    +
    let player = try Player.fetchOne(db, id: 123) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database, id: ID.Wrapped) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records, given their primary keys.

    +
    let players = try Player.fetchSet(db, keys: [1, 2, 3]) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<Sequence>(_ db: Database, keys: Sequence)
    +throws -> Set<Self>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable & Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchSet(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records, given their primary keys.

    +
    let players = try Player.fetchSet(db, ids: [1, 2, 3]) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<Collection>(_ db: Database, ids: Collection)
    +throws -> Set<Self>
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable & Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchSet(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records, given their primary keys.

    +
    let players = try Player.fetchSet(db, ids: [1, 2, 3]) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<Collection>(_ db: Database, ids: Collection)
    +throws -> Set<Self>
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching by Key +

+
+
+
    +
  • +
    + + + + fetchCursor(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records identified by the provided unique keys +(primary key or any key with a unique index on it).

    +
    // Cursor of Player
    +let players = try Player.fetchCursor(db, keys: [
    +    ["email": "a@example.com"],
    +    ["email": "b@example.com"]])
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(_ db: Database, keys: [[String: DatabaseValueConvertible?]])
    +throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records identified by the provided unique keys +(primary key or any key with a unique index on it).

    +
    // [Player]
    +let players = try Player.fetchAll(db, keys: [
    +    ["email": "a@example.com"],
    +    ["email": "b@example.com"]])
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record identified by a unique key (the primary key or +any key with a unique index on it).

    +
    let player = try Player.fetchOne(db, key: ["name": Arthur"]) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database, key: [String : DatabaseValueConvertible?]?) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records identified by the provided unique keys +(primary key or any key with a unique index on it).

    +
    // Set<Player>
    +let players = try Player.fetchSet(db, keys: [
    +    ["email": "a@example.com"],
    +    ["email": "b@example.com"]])
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let players = try Player.fetchSet(statement) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records fetched from an SQL query.

    +
    let players = try Player.fetchSet(db, sql: "SELECT * FROM player") // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records fetched from a fetch request.

    +
    let request = try Player.all()
    +let players = try Player.fetchSet(db, request) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/FilteredRequest.html b/docs/5.16/Protocols/FilteredRequest.html new file mode 100644 index 000000000..f387d87e7 --- /dev/null +++ b/docs/5.16/Protocols/FilteredRequest.html @@ -0,0 +1,1294 @@ + + + + FilteredRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FilteredRequest

+
+
+ +
public protocol FilteredRequest
+ +
+
+

The protocol for all requests that can be filtered.

+ + +
+
+
+
    +
  • +
    + + + + filter(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE 1
    +var request = Player.all()
    +request = request.filter { db in true }
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +var request = Player.all()
    +request = request.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FilteredRequest +

+
+
+
    +
  • +
    + + + + filter(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +var request = Player.all()
    +request = request.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT * FROM player WHERE name = 'O''Brien'
    +let name = "O'Brien"
    +var request = Player.all()
    +request = request.filter(literal: "email = \(email)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + none() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that matches nothing.

    +
    // SELECT * FROM player WHERE 0
    +var request = Player.all()
    +request = request.none()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func none() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/JoinableRequest.html b/docs/5.16/Protocols/JoinableRequest.html new file mode 100644 index 000000000..4b1c8a59a --- /dev/null +++ b/docs/5.16/Protocols/JoinableRequest.html @@ -0,0 +1,1435 @@ + + + + JoinableRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

JoinableRequest

+
+
+ +
public protocol JoinableRequest : TypedRequest, _JoinableRequest
+ +
+
+

The protocol for all requests that can be associated.

+ + +
+
+
+
+ + +
+ +

JoinableRequest +

+
+
+
    +
  • +
    + + + + including(all:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that prefetches an association.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A>(all association: A) -> Self where A : AssociationToMany, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned request does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A>(optional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned request requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A>(required association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that joins an association. The columns of the +associated record are not selected. The returned request does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A>(optional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that joins an association. The columns of the +associated record are not selected. The returned request requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A>(required association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: SelectionRequest +

+
+
+
    +
  • +
    + + + + annotated(withOptional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the current selection.

    +
    // SELECT player.*, team.color
    +// FROM player LEFT JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.all().annotated(withOptional: teamColor)
    +
    + +

    This method performs the same SQL request as including(optional:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String?
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(optional:):

    +
    let teamAlias = TableAlias()
    +let request = Player.all()
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(optional: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A>(withOptional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(withRequired:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the current selection.

    +
    // SELECT player.*, team.color
    +// FROM player JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.all().annotated(withRequired: teamColor)
    +
    + +

    This method performs the same SQL request as including(required:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(required:):

    +
    let teamAlias = TableAlias()
    +let request = Player.all()
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(required: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A>(withRequired association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/MutablePersistableRecord.html b/docs/5.16/Protocols/MutablePersistableRecord.html new file mode 100644 index 000000000..c42e1fd35 --- /dev/null +++ b/docs/5.16/Protocols/MutablePersistableRecord.html @@ -0,0 +1,2346 @@ + + + + MutablePersistableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

MutablePersistableRecord

+
+
+ +
public protocol MutablePersistableRecord : EncodableRecord, TableRecord
+ +
+
+

Types that adopt MutablePersistableRecord can be inserted, updated, +and deleted.

+ + +
+
+
+
    +
  • +
    + + + + persistenceConflictPolicy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    The policy that handles SQLite conflicts when records are inserted +or updated.

    + +

    This property is optional: its default value uses the ABORT policy +for both insertions and updates, and has GRDB generate regular +INSERT and UPDATE queries.

    + +

    If insertions are resolved with .ignore policy, the +didInsert(with:for:) method is not called upon successful insertion, +even if a row was actually inserted without any conflict.

    + +

    See https://www.sqlite.org/lang_conflict.html

    + +
    +

    Default Implementation

    +
    +

    Describes the conflict policy for insertions and updates.

    + +

    The default value specifies ABORT policy for both insertions and +updates, which has GRDB generate regular INSERT and UPDATE queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var persistenceConflictPolicy: PersistenceConflictPolicy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + didInsert(with:for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Notifies the record that it was successfully inserted.

    + +

    Do not call this method directly: it is called for you, in a protected +dispatch queue, with the inserted RowID and the eventual +INTEGER PRIMARY KEY column name.

    + +

    This method is optional: the default implementation does nothing.

    +
    struct Player : MutablePersistableRecord {
    +    var id: Int64?
    +    var name: String?
    +
    +    mutating func didInsert(with rowID: Int64, for column: String?) {
    +        self.id = rowID
    +    }
    +}
    +
    + +
    +

    Default Implementation

    +
    +

    Notifies the record that it was successfully inserted.

    + +

    The default implementation does nothing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func didInsert(with rowID: Int64, for column: String?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + rowID + + +
    +

    The inserted rowID.

    +
    +
    + + column + + +
    +

    The name of the eventual INTEGER PRIMARY KEY column.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

CRUD +

+
+
+
    +
  • +
    + + + + insert(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement.

    + +

    This method is guaranteed to have inserted a row in the database if it +returns without error.

    + +

    Upon successful insertion, the didInsert(with:for:) method +is called with the inserted RowID and the eventual INTEGER PRIMARY KEY +column name.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of insert(). In their implementation, it is recommended +that they invoke the performInsert() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT statement.

    + +

    The default implementation for insert() invokes performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func insert(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + update(_:columns:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an UPDATE statement.

    + +

    This method is guaranteed to have updated a row in the database if it +returns without error.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of update(). In their implementation, it is recommended +that they invoke the performUpdate() method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +

    Default Implementation

    +
    +

    Executes an UPDATE statement.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func update(_ db: Database, columns: Set<String>) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + save(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    If the receiver has a non-nil primary key and a matching row in the +database, this method performs an update.

    + +

    Otherwise, performs an insert.

    + +

    This method is guaranteed to have inserted or updated a row in the +database if it returns without error.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of save(). In their implementation, it is recommended +that they invoke the performSave() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs, or errors +thrown by update(). + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    The default implementation for save() invokes performSave().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func save(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes a DELETE statement.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of delete(). In their implementation, it is recommended +that they invoke the performDelete() method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Executes a DELETE statement.

    + +

    The default implementation for delete() invokes performDelete().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +func delete(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
  • +
    + + + + exists(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if the primary key matches a row in +the database.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of exists(). In their implementation, it is recommended +that they invoke the performExists() method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Returns true if and only if the primary key matches a row in +the database.

    + +

    The default implementation for exists() invokes performExists().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func exists(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the primary key matches a row in the database.

    +
    + +
    +
    +
  • +
  • +
    + + + + inserted(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement so that self is saved in the database, +and return the inserted record.

    + +

    Usage:

    +
    let player = Player(id: nil, name: "Arthur")
    +let insertedPlayer = try dbQueue.write { db in
    +    try player.inserted(db)
    +}
    +print(player.id)         // nil
    +print(insertedPlayer.id) // some id
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inserted(_ db: Database) throws -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + update(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Executes an UPDATE statement that updates all table columns.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func update(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + updateChanges(_:from:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    If the record has any difference from the other record, executes an +UPDATE statement so that those differences and only those difference are +saved in the database.

    + +

    This method is guaranteed to have saved the eventual differences in the +database if it returns without error.

    + +

    For example:

    +
    if let oldPlayer = try Player.fetchOne(db, key: 42) {
    +    var newPlayer = oldPlayer
    +    newPlayer.score += 10
    +    newPlayer.hasAward = true
    +    try newPlayer.updateChanges(db, from: oldRecord)
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    +

    See also

    + updateChanges(_:with:) + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateChanges<Record>(_ db: Database, from record: Record) throws -> Bool where Record : MutablePersistableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + record + + +
    +

    The comparison record.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
  • +
    + + + + updateChanges(_:with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Mutates the record according to the provided closure, and then, if the +record has any difference from its previous version, executes an +UPDATE statement so that those differences and only those difference are +saved in the database.

    + +

    This method is guaranteed to have saved the eventual differences in the +database if it returns without error.

    + +

    For example:

    +
    if var player = try Player.fetchOne(db, key: 42) {
    +    try player.updateChanges(db) {
    +        $0.score += 10
    +        $0.hasAward = true
    +    }
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public mutating func updateChanges(_ db: Database, with change: (inout Self) throws -> Void) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + change + + +
    +

    A closure that modifies the record.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
  • +
    + + + + saved(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database, and return the saved record.

    + +

    Usage:

    +
    let player = Player(id: nil, name: "Arthur")
    +let savedPlayer = try dbQueue.write { db in
    +    try player.saved(db)
    +}
    +print(player.id)      // nil
    +print(savedPlayer.id) // some id
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func saved(_ db: Database) throws -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

CRUD Internals +

+
+
+
    +
  • +
    + + + + performInsert(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performInsert() provides the default implementation for insert(). Types +that adopt MutablePersistableRecord can invoke performInsert() in their +implementation of insert(). They should not provide their own +implementation of performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func performInsert(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performUpdate(_:columns:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performUpdate() provides the default implementation for update(). Types +that adopt MutablePersistableRecord can invoke performUpdate() in their +implementation of update(). They should not provide their own +implementation of performUpdate().

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performUpdate(_ db: Database, columns: Set<String>) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + performSave(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performSave() provides the default implementation for save(). Types +that adopt MutablePersistableRecord can invoke performSave() in their +implementation of save(). They should not provide their own +implementation of performSave().

    + +

    This default implementation forwards the job to update or insert.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func performSave(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performDelete(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performDelete() provides the default implementation for deelte(). Types +that adopt MutablePersistableRecord can invoke performDelete() in +their implementation of delete(). They should not provide their own +implementation of performDelete().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performDelete(_ db: Database) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performExists(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performExists() provides the default implementation for exists(). Types +that adopt MutablePersistableRecord can invoke performExists() in +their implementation of exists(). They should not provide their own +implementation of performExists().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performExists(_ db: Database) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Record Comparison +

+
+
+
    +
  • +
    + + + + updateChanges(_:with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Mutates the record according to the provided closure, and then, if the +record has any difference from its previous version, executes an +UPDATE statement so that those differences and only those difference are +saved in the database.

    + +

    This method is guaranteed to have saved the eventual differences in the +database if it returns without error.

    + +

    For example:

    +
    if let player = try Player.fetchOne(db, key: 42) {
    +    try player.updateChanges(db) {
    +        $0.score += 10
    +        $0.hasAward = true
    +    }
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateChanges(_ db: Database, with change: (Self) throws -> Void) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + change + + +
    +

    A closure that modifies the record.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/OrderedRequest.html b/docs/5.16/Protocols/OrderedRequest.html new file mode 100644 index 000000000..a6c0d398d --- /dev/null +++ b/docs/5.16/Protocols/OrderedRequest.html @@ -0,0 +1,1353 @@ + + + + OrderedRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

OrderedRequest

+
+
+ +
public protocol OrderedRequest
+ +
+
+

The protocol for all requests that can be ordered.

+ + +
+
+
+
    +
  • +
    + + + + order(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided orderings promise.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order { _ in [Column("name")] }
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order{ _ in [Column("email")] }
    +    .reversed()
    +    .order{ _ in [Column("name")] }
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request with the provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order(Column("name"))
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order(Column("email"))
    +    .reversed()
    +    .order(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reversed() + +
    +
    +
    +
    +
    +
    +

    Creates a request that reverses applied orderings.

    +
    // SELECT * FROM player ORDER BY name DESC
    +var request = Player.all().order(Column("name"))
    +request = request.reversed()
    +
    + +

    If no ordering was applied, the returned request is identical.

    +
    // SELECT * FROM player
    +var request = Player.all()
    +request = request.reversed()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func reversed() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unordered() + +
    +
    +
    +
    +
    +
    +

    Creates a request without any ordering.

    +
    // SELECT * FROM player
    +var request = Player.all().order(Column("name"))
    +request = request.unordered()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unordered() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

OrderedRequest +

+
+
+
    +
  • +
    + + + + order(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to sql.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order(sql: "name")
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order(sql: "email")
    +    .order(sql: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to an SQL literal.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order(literal: "name")
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order(literal: "email")
    +    .order(literal: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/PersistableRecord.html b/docs/5.16/Protocols/PersistableRecord.html new file mode 100644 index 000000000..2348ade34 --- /dev/null +++ b/docs/5.16/Protocols/PersistableRecord.html @@ -0,0 +1,1448 @@ + + + + PersistableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistableRecord

+
+
+ +
public protocol PersistableRecord : MutablePersistableRecord
+ +
+
+

Types that adopt PersistableRecord can be inserted, updated, and deleted.

+ +

Unlike MutablePersistableRecord, the insert(_:) and save(_:) methods +are not mutating methods.

+ + +
+
+
+
    +
  • +
    + + + + didInsert(with:for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Notifies the record that it was successfully inserted.

    + +

    Do not call this method directly: it is called for you, in a protected +dispatch queue, with the inserted RowID and the eventual +INTEGER PRIMARY KEY column name.

    + +

    This method is optional: the default implementation does nothing.

    + +

    If you need a mutating variant of this method, adopt the +MutablePersistableRecord protocol instead.

    + +
    +

    Default Implementation

    +
    +

    Notifies the record that it was successfully inserted.

    + +

    The default implementation does nothing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func didInsert(with rowID: Int64, for column: String?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + rowID + + +
    +

    The inserted rowID.

    +
    +
    + + column + + +
    +

    The name of the eventual INTEGER PRIMARY KEY column.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + insert(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement.

    + +

    This method is guaranteed to have inserted a row in the database if it +returns without error.

    + +

    Upon successful insertion, the didInsert(with:for:) method +is called with the inserted RowID and the eventual INTEGER PRIMARY KEY +column name.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of insert(). In their implementation, it is recommended +that they invoke the performInsert() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT statement.

    + +

    The default implementation for insert() invokes performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func insert(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + save(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    If the receiver has a non-nil primary key and a matching row in the +database, this method performs an update.

    + +

    Otherwise, performs an insert.

    + +

    This method is guaranteed to have inserted or updated a row in the +database if it returns without error.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of save(). In their implementation, it is recommended +that they invoke the performSave() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs, or errors +thrown by update(). + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    The default implementation for save() invokes performSave().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func save(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Immutable CRUD Internals +

+
+
+
    +
  • +
    + + + + performInsert(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt PersistableRecord.

    + +

    performInsert() provides the default implementation for insert(). Types +that adopt PersistableRecord can invoke performInsert() in their +implementation of insert(). They should not provide their own +implementation of performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performInsert(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performSave(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt PersistableRecord.

    + +

    performSave() provides the default implementation for save(). Types +that adopt PersistableRecord can invoke performSave() in their +implementation of save(). They should not provide their own +implementation of performSave().

    + +

    This default implementation forwards the job to update or insert.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performSave(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/RowAdapter.html b/docs/5.16/Protocols/RowAdapter.html new file mode 100644 index 000000000..f39c9fe7e --- /dev/null +++ b/docs/5.16/Protocols/RowAdapter.html @@ -0,0 +1,1190 @@ + + + + RowAdapter Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RowAdapter

+
+
+ +
public protocol RowAdapter : _RowAdapter
+ +
+
+

RowAdapter is a protocol that helps two incompatible row interfaces +working together.

+ +

GRDB ships with four concrete types that adopt the RowAdapter protocol:

+ + + +

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.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func addingScopes(_ scopes: [String : RowAdapter]) -> RowAdapter
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + scopes + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/SQLExpressible.html b/docs/5.16/Protocols/SQLExpressible.html new file mode 100644 index 000000000..e60867a9d --- /dev/null +++ b/docs/5.16/Protocols/SQLExpressible.html @@ -0,0 +1,1248 @@ + + + + SQLExpressible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLExpressible

+
+
+ +
public protocol SQLExpressible
+ +
+
+

SQLExpressible is the protocol for all types that can be used as an +SQL expression.

+ +

It is adopted by protocols like DatabaseValueConvertible, and types +like Column.

+ +

See https://github.com/groue/GRDB.swift/#the-query-interface

+ + +
+
+
+ +
+
+
+ + +
+ +

Available where Self: RawRepresentable, Self.RawValue: SQLExpressible +

+
+
+
    +
  • +
    + + + + sqlExpression + + + Default implementation + +
    +
    +
    +
    +
    +
    + +
    +

    Default Implementation

    +
    +

    Returns the raw value as an SQL expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self == Column +

+
+
+
    +
  • +
    + + + + rowID + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The hidden rowID column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var rowID: Self { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/SQLOrderingTerm.html b/docs/5.16/Protocols/SQLOrderingTerm.html new file mode 100644 index 000000000..d08848ce2 --- /dev/null +++ b/docs/5.16/Protocols/SQLOrderingTerm.html @@ -0,0 +1,1147 @@ + + + + SQLOrderingTerm Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLOrderingTerm

+
+
+ +
public protocol SQLOrderingTerm
+ +
+
+

The protocol for all types that can be used as an SQL ordering term, as +described at https://www.sqlite.org/syntax/ordering-term.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/SQLSelectable.html b/docs/5.16/Protocols/SQLSelectable.html new file mode 100644 index 000000000..5ab681eda --- /dev/null +++ b/docs/5.16/Protocols/SQLSelectable.html @@ -0,0 +1,1147 @@ + + + + SQLSelectable Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSelectable

+
+
+ +
public protocol SQLSelectable
+ +
+
+

SQLSelectable is the protocol for types that can be selected, as +described at https://www.sqlite.org/syntax/result-column.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/SQLSpecificExpressible.html b/docs/5.16/Protocols/SQLSpecificExpressible.html new file mode 100644 index 000000000..6a0ec1907 --- /dev/null +++ b/docs/5.16/Protocols/SQLSpecificExpressible.html @@ -0,0 +1,1539 @@ + + + + SQLSpecificExpressible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSpecificExpressible

+
+
+ +
public protocol SQLSpecificExpressible : SQLExpressible, SQLOrderingTerm, SQLSelectable
+ +
+
+

SQLSpecificExpressible is a protocol for all database-specific types that +can be turned into an SQL expression. Types whose existence is not purely +dedicated to the database should adopt the SQLExpressible +protocol instead.

+ +

For example, Column is a type that only exists to help you build requests, +and it adopts SQLSpecificExpressible.

+ +

On the other side, Int adopts SQLExpressible.

+ + +
+
+
+
+ + +
+ +

SQLExpressible +

+
+
+ +
+
+
+ + +
+ +

SQL Ordering Support +

+
+
+ +
+
+
+ + +
+ +

SQL Collations Support +

+
+
+
    +
  • +
    + + + + collating(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a collated expression.

    + +

    For example:

    +
    Player.filter(Column("email").collating(.nocase) == "contact@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func collating(_ collation: Database.CollationName) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + collating(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a collated expression.

    + +

    For example:

    +
    Player.filter(Column("name").collating(.localizedStandardCompare) == "Hervé")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func collating(_ collation: DatabaseCollation) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Like Operator +

+
+
+
    +
  • +
    + + + + like(_:escape:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An SQL expression with the LIKE SQL operator.

    +
    // email LIKE '%@example.com"
    +Column("email").like("%@example.com")
    +
    +// title LIKE '%10\%%' ESCAPE '\'
    +Column("title").like("%10\\%%", escape: "\\")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func like(_ pattern: SQLExpressible, escape: SQLExpressible? = nil) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/SQLSubqueryable.html b/docs/5.16/Protocols/SQLSubqueryable.html new file mode 100644 index 000000000..d39ae4244 --- /dev/null +++ b/docs/5.16/Protocols/SQLSubqueryable.html @@ -0,0 +1,1268 @@ + + + + SQLSubqueryable Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSubqueryable

+
+
+ +
public protocol SQLSubqueryable : SQLSpecificExpressible
+ +
+
+

The protocol for types that can be embedded as a subquery.

+ + +
+
+
+ +
+
+
+ + +
+ +

SQLSubqueryable +

+
+
+
    +
  • +
    + + + + sqlExpression + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a subquery expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + contains(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an expression that checks the inclusion of the expression in +the subquery.

    +
    // 1000 IN (SELECT score FROM player)
    +let request = Player.select(Column("score"), as: Int.self)
    +let condition = request.contains(1000)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + exists() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an expression that is true if and only if the subquery would +return one or more rows.

    +
    // EXISTS (SELECT * FROM player WHERE name = 'Arthur')
    +let request = Player.filter(Column("name") == "Arthur")
    +let condition = request.exists()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists() -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/SelectionRequest.html b/docs/5.16/Protocols/SelectionRequest.html new file mode 100644 index 000000000..48a5960ea --- /dev/null +++ b/docs/5.16/Protocols/SelectionRequest.html @@ -0,0 +1,1333 @@ + + + + SelectionRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SelectionRequest

+
+
+ +
public protocol SelectionRequest
+ +
+
+

The protocol for all requests that can refine their selection.

+ + +
+
+
+
    +
  • +
    + + + + select(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection promise.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select { db in [Column("id"), Column("email") })
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select { db in [Column("id")] }
    +    .select { db in [Column("email")] }
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select(Column("id"), Column("email"))
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select(Column("id"))
    +    .select(Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection promise.

    +
    // SELECT id, email, name FROM player
    +var request = Player.all()
    +request = request
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: { db in [Column("name")] })
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +var request = Player.all()
    +request = request
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func annotated(with selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SelectionRequest +

+
+
+
    +
  • +
    + + + + select(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects sql.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select(sql: "id, email")
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select(sql: "id")
    +    .select(sql: "email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT id, email, score + 1000 FROM player
    +let bonus = 1000
    +var request = Player.all()
    +request = request.select(literal: """
    +    id, email, score + \(bonus)
    +    """)
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select(...)
    +    .select(literal: "email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/StatementBinding.html b/docs/5.16/Protocols/StatementBinding.html new file mode 100644 index 000000000..8b5285e68 --- /dev/null +++ b/docs/5.16/Protocols/StatementBinding.html @@ -0,0 +1,1181 @@ + + + + StatementBinding Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

StatementBinding

+
+
+ +
public protocol StatementBinding
+ +
+
+

Undocumented

+ + +
+
+
+
    +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    +

    Binds a statement argument.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    An SQLite statement.

    +
    +
    + + index + + +
    +

    1-based index to statement arguments

    +
    +
    +
    +
    +

    Return Value

    +

    the code returned by the sqlite3_bind_xxx function.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/StatementColumnConvertible.html b/docs/5.16/Protocols/StatementColumnConvertible.html new file mode 100644 index 000000000..34d0ff5b7 --- /dev/null +++ b/docs/5.16/Protocols/StatementColumnConvertible.html @@ -0,0 +1,1210 @@ + + + + StatementColumnConvertible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

StatementColumnConvertible

+
+
+ +
public protocol StatementColumnConvertible
+ +
+
+

The StatementColumnConvertible protocol grants access to the low-level C +interface that extracts values from query results: +https://www.sqlite.org/c3ref/column_blob.html. It can bring performance +improvements.

+ +

To use it, have a value type adopt both StatementColumnConvertible and +DatabaseValueConvertible. GRDB will then automatically apply the +optimization whenever direct access to SQLite is possible:

+
let rows = Row.fetchCursor(db, sql: "SELECT ...")
+while let row = try rows.next() {
+    let int: Int = row[0]                 // there
+}
+let ints = Int.fetchAll(db, sql: "SELECT ...") // there
+struct Player {
+    init(row: Row) {
+        name = row["name"]                // there
+        score = row["score"]              // there
+    }
+}
+
+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Initializes a value from a raw SQLite statement pointer, if possible.

    + +

    For example, here is the how Int64 adopts StatementColumnConvertible:

    +
    extension Int64: StatementColumnConvertible {
    +    init?(sqliteStatement: SQLiteStatement, index: Int32) {
    +        self = sqlite3_column_int64(sqliteStatement, index)
    +    }
    +}
    +
    + +

    This initializer is never called for NULL database values. Just return +nil for failed conversions: GRDB will interpret a nil result as a +decoding failure.

    + +

    See https://www.sqlite.org/c3ref/column_blob.html for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/TableRecord.html b/docs/5.16/Protocols/TableRecord.html new file mode 100644 index 000000000..a5f8e64dd --- /dev/null +++ b/docs/5.16/Protocols/TableRecord.html @@ -0,0 +1,5960 @@ + + + + TableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRecord

+
+
+ +
public protocol TableRecord
+ +
+
+

Types that adopt TableRecord declare a particular relationship with +a database table.

+ +

Types that adopt both TableRecord and FetchableRecord are granted with +built-in methods that allow to fetch instances identified by key:

+
try Player.fetchOne(db, key: 123)  // Player?
+try Citizenship.fetchOne(db, key: ["citizenId": 12, "countryId": 45]) // Citizenship?
+
+ + +
+
+
+
    +
  • +
    + + + + databaseTableName + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    The name of the database table used to build requests.

    +
    struct Player : TableRecord {
    +    static var databaseTableName = "player"
    +}
    +
    +// SELECT * FROM player
    +try Player.fetchAll(db)
    +
    + +
    +

    Default Implementation

    +
    +

    The default name of the database table used to build requests.

    + +
      +
    • Player -> “player”
    • +
    • Place -> “place”
    • +
    • PostalAddress -> “postalAddress”
    • +
    • HTTPRequest -> “httpRequest”
    • +
    • TOEFL -> “toefl”
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseTableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseSelection + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    The default request selection.

    + +

    Unless said otherwise, requests select all columns:

    +
    // SELECT * FROM player
    +try Player.fetchAll(db)
    +
    + +

    You can provide a custom implementation and provide an explicit list +of columns:

    +
    struct RestrictedPlayer : TableRecord {
    +    static var databaseTableName = "player"
    +    static var databaseSelection = [Column("id"), Column("name")]
    +}
    +
    +// SELECT id, name FROM player
    +try RestrictedPlayer.fetchAll(db)
    +
    + +

    You can also add extra columns such as the rowid column:

    +
    struct ExtendedPlayer : TableRecord {
    +    static var databaseTableName = "player"
    +    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
    +}
    +
    +// SELECT *, rowid FROM player
    +try ExtendedPlayer.fetchAll(db)
    +
    + +
    +

    Default Implementation

    +
    +

    Default value: [AllColumns()].

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseSelection: [SQLSelectable] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a QueryInterfaceRequest with a matching predicate.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func matching(_ pattern: FTS3Pattern?) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to TableRecord +

+
+
+
    +
  • +
    + + + + belongsTo(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +type, based on a database foreign key.

    +
    struct Author: TableRecord { ... }
    +struct Book: TableRecord {
    +    static let author = belongsTo(Author.self)
    +}
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all books with their authors:
    +let request = Book.including(optional: Book.author)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct BookInfo: FetchableRecord, Decodable {
    +    var book: Book
    +    var author: Author?
    +}
    +
    +let bookInfos = try dbQueue.read { db in
    +    return try BookInfo.fetchAll(db, request)
    +}
    +for bookInfo in bookInfos {
    +    print("\(bookInfo.book.title) by \(bookInfo.author.name)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Book: TableRecord, EncodableRecord {
    +    static let author = belongsTo(Author.self)
    +    var author: QueryInterfaceRequest<Author> {
    +        return request(for: Book.author)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let book: Book = ...
    +    let author = try book.author.fetchOne(db) // Author?
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func belongsTo<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<Self, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination type, +based on a database foreign key.

    +
    struct Book: TableRecord { ... }
    +struct Author: TableRecord {
    +    static let books = hasMany(Book.self)
    +}
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all (author, book) pairs:
    +let request = Author.including(required: Author.books)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct Authorship: FetchableRecord, Decodable {
    +    var author: Author
    +    var book: Book
    +}
    +
    +let authorships = try dbQueue.read { db in
    +    return try Authorship.fetchAll(db, request)
    +}
    +for authorship in authorships {
    +    print("\(authorship.author.name) wrote \(authorship.book.title)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Author: TableRecord, EncodableRecord {
    +    static let books = hasMany(Book.self)
    +    var books: QueryInterfaceRequest<Book> {
    +        return request(for: Author.books)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let author: Author = ...
    +    let books = try author.books.fetchAll(db) // [Book]
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasMany<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<Self, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination type, +based on a database foreign key.

    +
    struct Demographics: TableRecord { ... }
    +struct Country: TableRecord {
    +    static let demographics = hasOne(Demographics.self)
    +}
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all countries with their demographic profile:
    +let request = Country.including(optional: Country.demographics)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct CountryInfo: FetchableRecord, Decodable {
    +    var country: Country
    +    var demographics: Demographics?
    +}
    +
    +let countryInfos = try dbQueue.read { db in
    +    return try CountryInfo.fetchAll(db, request)
    +}
    +for countryInfo in countryInfos {
    +    print("\(countryInfo.country.name) has \(countryInfo.demographics.population) citizens")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Country: TableRecord, EncodableRecord {
    +    static let demographics = hasOne(Demographics.self)
    +    var demographics: QueryInterfaceRequest<Demographics> {
    +        return request(for: Country.demographics)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let country: Country = ...
    +    let demographics = try country.demographics.fetchOne(db) // Demographics?
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasOne<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<Self, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to Table +

+
+
+
    +
  • +
    + + + + belongsTo(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +table, based on a database foreign key.

    + +

    For more information, see TableRecord.belongsTo(_:key:using:) where +the first argument is TableRecord.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func belongsTo<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasMany(_:key:using:) where +the first argument is TableRecord.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasMany<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasOne(_:key:using:) where +the first argument is TableRecord.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasOne<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to CommonTableExpression +

+
+
+
    +
  • +
    + + + + association(to:on:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +

    For example, you can build a request that fetches all chats with their +latest message:

    +
    let latestMessageRequest = Message
    +    .annotated(with: max(Column("date")))
    +    .group(Column("chatID"))
    +
    +let latestMessageCTE = CommonTableExpression(
    +    named: "latestMessage",
    +    request: latestMessageRequest)
    +
    +let latestMessage = Chat.association(
    +    to: latestMessageCTE,
    +    on: { chat, latestMessage in
    +        chat[Column("id")] == latestMessage[Column("chatID")]
    +    })
    +
    +// WITH latestMessage AS
    +//   (SELECT *, MAX(date) FROM message GROUP BY chatID)
    +// SELECT chat.*, latestMessage.*
    +// FROM chat
    +// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
    +let request = Chat
    +    .with(latestMessageCTE)
    +    .including(optional: latestMessage)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func association<Destination>(
    +    to cte: CommonTableExpression<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func association<Destination>(
    +    to cte: CommonTableExpression<Destination>)
    +-> JoinAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

“Through” Associations +

+
+
+
    +
  • +
    + + + + hasMany(_:through:using:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has Many Through” association between Self and the +destination type.

    +
    struct Country: TableRecord {
    +    static let passports = hasMany(Passport.self)
    +    static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
    +}
    +
    +struct Passport: TableRecord {
    +    static let citizen = belongsTo(Citizen.self)
    +}
    +
    +struct Citizen: TableRecord { }
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all (country, citizen) pairs:
    +let request = Country.including(required: Coutry.citizens)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct Citizenship: FetchableRecord, Decodable {
    +    var country: Country
    +    var citizen: Citizen
    +}
    +
    +let citizenships = try dbQueue.read { db in
    +    return try Citizenship.fetchAll(db, request)
    +}
    +for citizenship in citizenships {
    +    print("\(citizenship.citizen.name) is a citizen of \(citizenship.country.name)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Country: TableRecord, EncodableRecord {
    +    static let passports = hasMany(Passport.self)
    +    static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
    +    var citizens: QueryInterfaceRequest<Citizen> {
    +        return request(for: Country.citizens)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let country: Country = ...
    +    let citizens = try country.citizens.fetchAll(db) // [Country]
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasMany<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasManyThroughAssociation<Self, Target.RowDecoder>
    +where Pivot: Association,
    +      Target: Association,
    +      Pivot.OriginRowDecoder == Self,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:through:using:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has One Through” association between Self and the +destination type.

    +
    struct Book: TableRecord {
    +    static let library = belongsTo(Library.self)
    +    static let returnAddress = hasOne(Address.self, through: library, using: Library.address)
    +}
    +
    +struct Library: TableRecord {
    +    static let address = hasOne(Address.self)
    +}
    +
    +struct Address: TableRecord { ... }
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all (book, returnAddress) pairs:
    +let request = Book.including(required: Book.returnAddress)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct Todo: FetchableRecord, Decodable {
    +    var book: Book
    +    var address: Address
    +}
    +
    +let todos = try dbQueue.read { db in
    +    return try Todo.fetchAll(db, request)
    +}
    +for todo in todos {
    +    print("Please return \(todo.book) to \(todo.address)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Book: TableRecord, EncodableRecord {
    +    static let library = belongsTo(Library.self)
    +    static let returnAddress = hasOne(Address.self, through: library, using: library.address)
    +    var returnAddress: QueryInterfaceRequest<Address> {
    +        return request(for: Book.returnAddress)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let book: Book = ...
    +    let address = try book.returnAddress.fetchOne(db) // Address?
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasOne<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasOneThroughAssociation<Self, Target.RowDecoder>
    +where Pivot: AssociationToOne,
    +      Target: AssociationToOne,
    +      Pivot.OriginRowDecoder == Self,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Joining Methods +

+
+
+
    +
  • +
    + + + + including(all:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that prefetches an association.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func including<A: AssociationToMany>(all association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func including<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func including<A: Association>(required association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func joining<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func joining<A: Association>(required association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(withOptional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the selection.

    +
    // SELECT player.*, team.color
    +// FROM player LEFT JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.annotated(withOptional: teamColor)
    +
    + +

    This method performs the same SQL request as including(optional:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String?
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(optional:):

    +
    let teamAlias = TableAlias()
    +let request = Player
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(optional: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated<A: Association>(withOptional association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(withRequired:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the selection.

    +
    // SELECT player.*, team.color
    +// FROM player JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.annotated(withRequired: teamColor)
    +
    + +

    This method performs the same SQL request as including(required:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(required:):

    +
    let teamAlias = TableAlias()
    +let request = Player
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(required: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated<A: Association>(withRequired association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Aggregates +

+
+
+
    +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let request = Player.annotated(with: Player.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with aggregates: AssociationAggregate<Self>...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let request = Player.annotated(with: [Player.books.count])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with aggregates: [AssociationAggregate<Self>]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided aggregate predicate.

    +
    // SELECT player.*
    +// FROM player LEFT JOIN book ...
    +// HAVING COUNT(DISTINCT book.id) = 0
    +var request = Player.all()
    +request = request.having(Player.books.isEmpty)
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func having(_ predicate: AssociationAggregate<Self>) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Request Derivation +

+
+
+
    +
  • +
    + + + + all() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches all records.

    +
    // SELECT * FROM player
    +let request = Player.all()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func all() -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + none() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches no record.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func none() -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let request = Player.select(Column("id"), Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(_ selection: SQLSelectable...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let request = Player.select([Column("id"), Column("email")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(_ selection: [SQLSelectable]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects sql.

    +
    // SELECT id, email FROM player
    +let request = Player.select(sql: "id, email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT id, email, score + 1000 FROM player
    +let bonus = 1000
    +let request = Player.select(literal: """
    +    id, email, score + \(bonus)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(literal sqlLiteral: SQL) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.select([max(Column("score"))], as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    _ selection: [SQLSelectable],
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.select(max(Column("score")), as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    _ selection: SQLSelectable...,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(sql:arguments:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects sql, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.select(sql: "max(score)", as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal, and fetches values of +type type.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +let defaultName = "Anonymous"
    +let request = Player.select(
    +    literal: "IFNULL(name, \(defaultName))",
    +    as: String.self)
    +let name: String? = try request.fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    literal sqlLiteral: SQL,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let request = Player
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: [Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let request = Player
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with selection: SQLSelectable...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let request = Player.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean filter(id:﹚ or filter(key:﹚? If not, prefer filter(value.databaseValue﹚ instead. See also none(﹚.")
    +public static func filter(_ predicate: SQLExpressible) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let request = Player.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(_ predicate: SQLSpecificExpressible) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id = 1
    +let request = Player.filter(key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<PrimaryKeyType>(key: PrimaryKeyType?)
    +-> QueryInterfaceRequest<Self>
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let request = Player.filter(keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<Sequence>(keys: Sequence)
    +-> QueryInterfaceRequest<Self>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE personId = 1 AND countryCode = 'FR'
    +let request = Passport.filter(key: ["personId": 1, "countryCode": "FR"])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(key: [String : DatabaseValueConvertible?]?) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE (personId = 1 AND countryCode = 'FR') OR ...
    +let request = Passport.filter(keys: [["personId": 1, "countryCode": "FR"], ...])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(keys: [[String : DatabaseValueConvertible?]]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let request = Player.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT * FROM player WHERE name = 'O''Brien'
    +let name = "O'Brien"
    +let request = Player.filter(literal: "email = \(email)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(literal sqlLiteral: SQL) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(_ orderings: SQLOrderingTerm...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order([Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(_ orderings: [SQLOrderingTerm]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + orderByPrimaryKey() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted by primary key.

    +
    // SELECT * FROM player ORDER BY id
    +let request = Player.orderByPrimaryKey()
    +
    +// SELECT * FROM country ORDER BY code
    +let request = Country.orderByPrimaryKey()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func orderByPrimaryKey() -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to sql.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order(sql: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to an SQL literal.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order(literal: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(literal sqlLiteral: SQL) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + limit(_:offset:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches limit rows, starting at +offset.

    +
    // SELECT * FROM player LIMIT 1
    +let request = Player.limit(1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func limit(_ limit: Int, offset: Int? = nil) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.avgScore < player.score” condition in +the ON clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ... AND team.avgScore < player.score
    +let playerAlias = TableAlias()
    +let request = Player
    +    .aliased(playerAlias)
    +    .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func aliased(_ alias: TableAlias) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a request which embeds the common table expression.

    + +

    If a common table expression with the same table name had already been +embedded, it is replaced by the new one.

    + +

    For example, you can build a request that fetches all chats with their +latest post:

    +
    let latestMessageRequest = Message
    +    .annotated(with: max(Column("date")))
    +    .group(Column("chatID"))
    +
    +let latestMessageCTE = CommonTableExpression(
    +    named: "latestMessage",
    +    request: latestMessageRequest)
    +
    +let latestMessage = Chat.association(
    +    to: latestMessageCTE,
    +    on: { chat, latestMessage in
    +        chat[Column("id")] == latestMessage[Column("chatID")]
    +    })
    +
    +// WITH latestMessage AS
    +//   (SELECT *, MAX(date) FROM message GROUP BY chatID)
    +// SELECT chat.*, latestMessage.*
    +// FROM chat
    +// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
    +let request = Chat
    +    .with(latestMessageCTE)
    +    .including(optional: latestMessage)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> QueryInterfaceRequest<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    A request.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Counting All +

+
+
+
    +
  • +
    + + + + fetchCount(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The number of records.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCount(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQL Generation +

+
+
+
    +
  • +
    + + + + numberOfSelectedColumns(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the number of selected columns.

    + +

    For example:

    +
    struct Player: TableRecord {
    +    static let databaseTableName = "player"
    +}
    +
    +try dbQueue.write { db in
    +    try db.create(table: "player") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("name", .text)
    +        t.column("score", .integer)
    +    }
    +
    +    // 3
    +    try Player.numberOfSelectedColumns(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func numberOfSelectedColumns(_ db: Database) throws -> Int
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Delete +

+
+
+
    +
  • +
    + + + + deleteAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Deletes all records; returns the number of deleted rows.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Player.exists(db, key: 123)
    +try Country.exists(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Document.exists(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this unique key (primary key or any key +with a unique index on it).

    +
    try Player.exists(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Player.deleteAll(db, keys: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Country.deleteAll(db, keys: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Document.deleteAll(db, keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll<Sequence>(_ db: Database, keys: Sequence)
    +throws -> Int
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Player.deleteOne(db, key: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Country.deleteOne(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Document.deleteOne(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType?)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by the provided unique keys (primary key or +any key with a unique index on it); returns the number of deleted rows.

    +
    try Player.deleteAll(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by a unique key (the primary key or any key +with a unique index on it); returns whether a database row was deleted.

    +
    Player.deleteOne(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Update +

+
+
+
    +
  • +
    + + + + updateAll(_:onConflict:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Updates all records; returns the number of updated records.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.updateAll(db, [Column("score").set(to: 0)])
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignments: [ColumnAssignment])
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution, +defaulting to the record’s persistenceConflictPolicy.

    +
    +
    + + assignments + + +
    +

    An array of column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + updateAll(_:onConflict:_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Updates all records; returns the number of updated records.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.updateAll(db, Column("score").set(to: 0))
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignment: ColumnAssignment,
    +    _ otherAssignments: ColumnAssignment...)
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution, +defaulting to the record’s persistenceConflictPolicy.

    +
    +
    + + assignment + + +
    +

    A column assignment.

    +
    +
    + + otherAssignments + + +
    +

    Eventual other column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: EncodableRecord +

+
+
+
    +
  • +
    + + + + request(for:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that fetches the associated record(s).

    + +

    For example:

    +
    struct Team: TableRecord, EncodableRecord {
    +    static let players = hasMany(Player.self)
    +    var players: QueryInterfaceRequest<Player> {
    +        return request(for: Team.players)
    +    }
    +}
    +
    +let team: Team = ...
    +let players = try team.players.fetchAll(db) // [Player]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func request<A: Association>(for association: A)
    +-> QueryInterfaceRequest<A.RowDecoder>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let request = Player.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(id: ID) -> QueryInterfaceRequest<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let request = Player.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<Self>
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let request = try Player.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func selectID() -> QueryInterfaceRequest<ID>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let request = Player.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(id: ID.Wrapped) -> QueryInterfaceRequest<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let request = Player.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<Self>
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let request = try Player.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func selectID() -> QueryInterfaceRequest<ID.Wrapped>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Player.deleteOne(db, id: 123)
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists(_ db: Database, id: ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Player.deleteOne(db, id: 123)
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists(_ db: Database, id: ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Player.deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Country.deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Document.deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Player.deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne(_ db: Database, id: ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Player.deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Country.deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Document.deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Player.deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne(_ db: Database, id: ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/TableRequest.html b/docs/5.16/Protocols/TableRequest.html new file mode 100644 index 000000000..e80cb6cf5 --- /dev/null +++ b/docs/5.16/Protocols/TableRequest.html @@ -0,0 +1,1829 @@ + + + + TableRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRequest

+
+
+ +
public protocol TableRequest
+ +
+
+

The protocol for all requests that feed from a database table

+ + +
+
+
+
    +
  • +
    + + + + databaseTableName + +
    +
    +
    +
    +
    +
    +

    The name of the database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var databaseTableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.avgScore < player.score” condition in +the ON clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ... AND team.avgScore < player.score
    +let playerAlias = TableAlias()
    +let request = Player
    +    .all()
    +    .aliased(playerAlias)
    +    .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func aliased(_ alias: TableAlias) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with a full-text predicate added to the eventual +set of already applied predicates.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.all()
    +request = request.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func matching(_ pattern: FTS3Pattern?) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: FilteredRequest, Self: TypedRequest +

+
+
+
    +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id = 1
    +let request = try Player...filter(key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<PrimaryKeyType>(key: PrimaryKeyType?) -> Self where PrimaryKeyType : DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + key + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id IN (1, 2, 3)
    +let request = try Player...filter(keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Sequence: Swift.Sequence>(keys: Sequence)
    +-> Self
    +where Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + keys + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by unique key.

    +
    // SELECT * FROM player WHERE ... email = 'arthur@example.com'
    +let request = try Player...filter(key: ["email": "arthur@example.com"])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(key: [String : DatabaseValueConvertible?]?) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + key + + +
    +

    A unique key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by unique key.

    +
    // SELECT * FROM player WHERE ... email = 'arthur@example.com' OR ...
    +let request = try Player...filter(keys: [["email": "arthur@example.com"], ...])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(keys: [[String : DatabaseValueConvertible?]]) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + keys + + +
    +

    A collection of unique keys

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: FilteredRequest, Self: TypedRequest, RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id = 1
    +let request = try Player...filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id IN (1, 2, 3)
    +let request = try Player...filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection: Swift.Collection>(ids: Collection)
    +-> Self
    +where Collection.Element == RowDecoder.ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: FilteredRequest, Self: TypedRequest, RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id = 1
    +let request = try Player...filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID.Wrapped) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id IN (1, 2, 3)
    +let request = try Player...filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection: Swift.Collection>(ids: Collection)
    +-> Self
    +where Collection.Element == RowDecoder.ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: OrderedRequest +

+
+
+
    +
  • +
    + + + + orderByPrimaryKey() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request ordered by primary key.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func orderByPrimaryKey() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: AggregatingRequest +

+
+
+
    +
  • +
    + + + + groupByPrimaryKey() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request grouped by primary key.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func groupByPrimaryKey() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/TransactionObserver.html b/docs/5.16/Protocols/TransactionObserver.html new file mode 100644 index 000000000..342a00090 --- /dev/null +++ b/docs/5.16/Protocols/TransactionObserver.html @@ -0,0 +1,1441 @@ + + + + TransactionObserver Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionObserver

+
+
+ +
public protocol TransactionObserver : AnyObject
+ +
+
+

A transaction observer is notified of all changes and transactions committed +or rollbacked on a database.

+ +

Adopting types must be a class.

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Filters database changes that should be notified the the +databaseDidChange(with:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Notifies a database change (insert, update, or delete).

    + +

    The change is pending until the current transaction ends. See +databaseWillCommit, databaseDidCommit and databaseDidRollback.

    + +

    This method is called in a protected dispatch queue, serialized will all +database updates.

    + +

    The event is only valid for the duration of this method call. If you +need to keep it longer, store a copy: event.copy()

    + +

    The observer has an opportunity to stop receiving further change events +from the current transaction by calling the +stopObservingDatabaseChangesUntilNextTransaction() method.

    +
    +

    Warning

    + this method must not change the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseDidChange(with event: DatabaseEvent)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseWillCommit() + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When a transaction is about to be committed, the transaction observer +has an opportunity to rollback pending changes by throwing an error.

    + +

    This method is called on the database queue.

    +
    +

    Warning

    +

    this method must not change the database.

    + +
    +

    Throws

    +

    An eventual error that rollbacks pending changes.

    + +
    + +
    +

    Default Implementation

    +
    +

    Default implementation does nothing

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseWillCommit() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDidCommit(_:) + +
    +
    +
    +
    +
    +
    +

    Database changes have been committed.

    + +

    This method is called on the database queue. It can change the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseDidCommit(_ db: Database)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Database changes have been rollbacked.

    + +

    This method is called on the database queue. It can change the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseDidRollback(_ db: Database)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseWillChange(with:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Notifies before a database change (insert, update, or delete) +with change information (initial / final values for the row’s +columns). (Called before databaseDidChangeWithEvent.)

    + +

    The change is pending until the end of the current transaction, +and you always get a second chance to get basic event information in +the databaseDidChangeWithEvent callback.

    + +

    This callback is mostly useful for calculating detailed change +information for a row, and provides the initial / final values.

    + +

    This method is called in a protected dispatch queue, serialized will all +database updates.

    + +

    The event is only valid for the duration of this method call. If you +need to keep it longer, store a copy: event.copy()

    +
    +

    Warning

    + this method must not change the database. + +
    + +

    Availability Info

    + +

    Requires SQLite 3.13.0 + +Compiled with option SQLITE_ENABLE_PREUPDATE_HOOK

    + +

    As of OSX 10.11.5, and iOS 9.3.2, the built-in SQLite library +does not have this enabled, so you’ll need to compile your own +version of SQLite: +See https://github.com/groue/GRDB.swift/blob/master/Documentation/CustomSQLiteBuilds.md

    + +

    The databaseDidChangeWithEvent callback is always available, +and may provide most/all of what you need.

    + +
    +

    Default Implementation

    +
    +

    Default implementation does nothing

    + +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

TransactionObserver +

+
+
+
    +
  • +
    + + + + stopObservingDatabaseChangesUntilNextTransaction() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    After this method has been called, the databaseDidChange(with:) +method won’t be called until the next transaction.

    + +

    For example:

    +
    class PlayerObserver: TransactionObserver {
    +    var playerTableWasModified = false
    +
    +    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
    +        return eventKind.tableName == "player"
    +    }
    +
    +    func databaseDidChange(with event: DatabaseEvent) {
    +        playerTableWasModified = true
    +
    +        // It is pointless to keep on tracking further changes:
    +        stopObservingDatabaseChangesUntilNextTransaction()
    +    }
    +}
    +
    +
    +

    Precondition

    + This method must be called from databaseDidChange(with:). + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func stopObservingDatabaseChangesUntilNextTransaction()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/TypedRequest.html b/docs/5.16/Protocols/TypedRequest.html new file mode 100644 index 000000000..b38e93a7d --- /dev/null +++ b/docs/5.16/Protocols/TypedRequest.html @@ -0,0 +1,1151 @@ + + + + TypedRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TypedRequest

+
+
+ +
public protocol TypedRequest
+ +
+
+

The protocol for all requests that know how database rows should +be interpreted.

+ + +
+
+
+
    +
  • +
    + + + + RowDecoder + +
    +
    +
    +
    +
    +
    +

    The type that can decode database rows.

    + +

    In the request below, it is Player:

    +
    let request = Player.all()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype RowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Protocols/VirtualTableModule.html b/docs/5.16/Protocols/VirtualTableModule.html new file mode 100644 index 000000000..2a96a302b --- /dev/null +++ b/docs/5.16/Protocols/VirtualTableModule.html @@ -0,0 +1,1334 @@ + + + + VirtualTableModule Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

VirtualTableModule

+
+
+ +
public protocol VirtualTableModule
+ +
+
+

The protocol for SQLite virtual table modules. It lets you define a DSL for +the Database.create(virtualTable:using:) method:

+
let module = ...
+try db.create(virtualTable: "item", using: module) { t in
+    ...
+}
+
+ +

GRDB ships with three concrete classes that implement this protocol: FTS3, +FTS4 and FTS5.

+ + +
+
+
+
    +
  • +
    + + + + TableDefinition + +
    +
    +
    +
    +
    +
    +

    The type of the closure argument in the +Database.create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "item", using: module) { t in
    +    // t is TableDefinition
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + moduleName + +
    +
    +
    +
    +
    +
    +

    The name of the module.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var moduleName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + makeTableDefinition() + +
    +
    +
    +
    +
    +
    +

    Returns a table definition that is passed as the closure argument in the +Database.create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "item", using: module) { t in
    +    // t is the result of makeTableDefinition()
    +}
    +
    +
    +

    Warning

    + This method is DEPRECATED. Define +makeTableDefinition(configuration:) instead. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func makeTableDefinition() -> TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + makeTableDefinition(configuration:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Returns a table definition that is passed as the closure argument in the +Database.create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "item", using: module) { t in
    +    // t is the result of makeTableDefinition(configuration:)
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func makeTableDefinition(configuration: VirtualTableConfiguration) -> TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the module arguments for the CREATE VIRTUAL TABLE query.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func moduleArguments(for definition: TableDefinition, in db: Database) throws -> [String]
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Execute any relevant database statement after the virtual table has +been created.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func database(_ db: Database, didCreate tableName: String, using definition: TableDefinition) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs.html b/docs/5.16/Structs.html new file mode 100644 index 000000000..23c25f852 --- /dev/null +++ b/docs/5.16/Structs.html @@ -0,0 +1,3822 @@ + + + + Structures Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Structures

+

The following structures are available globally.

+ +
+
+
+
    +
  • +
    + + + + Configuration + +
    +
    +
    +
    +
    +
    +

    Configuration for a DatabaseQueue or DatabasePool.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct Configuration
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnInfo + +
    +
    +
    +
    +
    +
    +

    A column of a database table.

    + +

    This type closely matches the information returned by the +table_info and table_xinfo pragmas.

    +
    sqlite> CREATE TABLE player (
    +   ...>   id INTEGER PRIMARY KEY,
    +   ...>   firstName TEXT,
    +   ...>   lastName TEXT);
    +sqlite> PRAGMA table_info(player);
    +cid     name        type        notnull     dflt_value  pk
    +------  ----------  ----------  ----------  ----------  -----
    +0       id          INTEGER     0                       1
    +1       firstName   TEXT        0                       0
    +2       lastName    TEXT        0                       0
    +sqlite> PRAGMA table_xinfo(player);
    +cid     name        type        notnull     dflt_value  pk     hidden
    +------  ----------  ----------  ----------  ----------  -----  ----------
    +0       id          INTEGER     0                       1      0
    +1       firstName   TEXT        0                       0      0
    +2       lastName    TEXT        0                       0      0
    +
    + +

    See Database.columns(in:) and https://www.sqlite.org/pragma.html#pragma_table_info

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ColumnInfo : FetchableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + IndexInfo + +
    +
    +
    +
    +
    +
    +

    An index on a database table.

    + +

    See Database.indexes(on:)

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct IndexInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ForeignKeyViolation + +
    +
    +
    +
    +
    +
    +

    A foreign key violation produced by PRAGMA foreign_key_check

    + +

    See https://www.sqlite.org/pragma.html#pragma_foreign_key_check

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ForeignKeyViolation : FetchableRecord, CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + PrimaryKeyInfo + +
    +
    +
    +
    +
    +
    +

    Primary keys are returned from the Database.primaryKey(_:) method.

    + +

    When the table’s primary key is the rowid:

    +
    // CREATE TABLE item (name TEXT)
    +let pk = try db.primaryKey("item")
    +pk.columns     // ["rowid"]
    +pk.rowIDColumn // nil
    +pk.isRowID     // true
    +
    +// CREATE TABLE citizen (
    +//   id INTEGER PRIMARY KEY,
    +//   name TEXT
    +// )
    +let pk = try db.primaryKey("citizen")!
    +pk.columns     // ["id"]
    +pk.rowIDColumn // "id"
    +pk.isRowID     // true
    +
    + +

    When the table’s primary key is not the rowid:

    +
    // CREATE TABLE country (
    +//   isoCode TEXT NOT NULL PRIMARY KEY
    +//   name TEXT
    +// )
    +let pk = db.primaryKey("country")!
    +pk.columns     // ["isoCode"]
    +pk.rowIDColumn // nil
    +pk.isRowID     // false
    +
    +// CREATE TABLE citizenship (
    +//   citizenID INTEGER NOT NULL REFERENCES citizen(id)
    +//   countryIsoCode TEXT NOT NULL REFERENCES country(isoCode)
    +//   PRIMARY KEY (citizenID, countryIsoCode)
    +// )
    +let pk = db.primaryKey("citizenship")!
    +pk.columns     // ["citizenID", "countryIsoCode"]
    +pk.rowIDColumn // nil
    +pk.isRowID     // false
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PrimaryKeyInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ForeignKeyInfo + +
    +
    +
    +
    +
    +
    +

    You get foreign keys from table names, with the +foreignKeys(on:) method.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ForeignKeyInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ResultCode + +
    +
    +
    +
    +
    +
    +

    An SQLite result code.

    + +

    See https://www.sqlite.org/rescode.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseError + +
    +
    +
    +
    +
    +
    +

    DatabaseError wraps an SQLite error.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseError : Error, CustomStringConvertible, CustomNSError
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseRegion + +
    +
    +
    +
    +
    +
    +

    DatabaseRegion defines a region in the database. DatabaseRegion is dedicated +to help transaction observers recognize impactful database changes in their +observes(eventsOfKind:) and databaseDidChange(with:) methods.

    + +

    A database region is the union of any number of “table regions”, which can +cover a full table, or the combination of columns and rows:

    +
    |Table1 |   |Table2 |   |Table3 |   |Table4 |   |Table5 |
    +|-------|   |-------|   |-------|   |-------|   |-------|
    +|x|x|x|x|   |x| | | |   |x|x|x|x|   |x|x| |x|   | | | | |
    +|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | |x| | |
    +|x|x|x|x|   |x| | | |   | | | | |   |x|x| |x|   | | | | |
    +|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | | | | |
    +
    + +

    To create a database region, you use one of those methods:

    + +
      +
    • DatabaseRegion.fullDatabase: the region that covers all database tables.

    • +
    • DatabaseRegion(): the empty region.

    • +
    • DatabaseRegion(table:): the region that covers one database table.

    • +
    • Statement.databaseRegion:

      +
      let statement = try db.makeStatement(sql: "SELECT name, score FROM player")
      +let region = statement.databaseRegion
      +
    • +
    • FetchRequest.databaseRegion(_:)

      +
      let request = Player.filter(key: 1)
      +let region = try request.databaseRegion(db)
      +
    • +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseRegion : CustomStringConvertible, Equatable
    +
    extension DatabaseRegion: DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseRegionConvertible +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    A type-erased DatabaseRegionConvertible

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AnyDatabaseRegionConvertible : DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    DatabaseRegionObservation tracks changes in the results of database +requests, and notifies each database transaction whenever the +database changes.

    + +

    For example:

    +
    let observation = DatabaseRegionObservation(tracking: Player.all)
    +let observer = try observation.start(in: dbQueue) { db: Database in
    +    print("Players have changed.")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseRegionObservation
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseValue +

+
+
+ +
+
+
+ + +
+ +

PreparedRequest +

+
+
+
    +
  • +
    + + + + PreparedRequest + +
    +
    +
    +
    +
    +
    +

    A PreparedRequest is a request that is ready to be executed.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PreparedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AdaptedFetchRequest +

+
+
+ +
+
+
+ + +
+ +

AnyFetchRequest +

+
+
+
    +
  • +
    + + + + AnyFetchRequest + +
    +
    +
    +
    +
    +
    +

    A type-erased FetchRequest.

    + +

    An AnyFetchRequest forwards its operations to an underlying request, +hiding its specifics.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AnyFetchRequest<RowDecoder> : FetchRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

RowIndex +

+
+
+
    +
  • +
    + + + + RowIndex + +
    +
    +
    +
    +
    +
    +

    Indexes to (ColumnName, DatabaseValue) pairs in a database row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct RowIndex : Comparable, Strideable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + EmptyRowAdapter + +
    +
    +
    +
    +
    +
    +

    EmptyRowAdapter is a row adapter that hides all columns.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct EmptyRowAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnMapping + +
    +
    +
    +
    +
    +
    +

    ColumnMapping is a row adapter that maps column names.

    +
    let adapter = ColumnMapping(["foo": "bar"])
    +let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
    +
    +// [foo:"bar"]
    +try Row.fetchOne(db, sql: sql, adapter: adapter)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ColumnMapping : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SuffixRowAdapter + +
    +
    +
    +
    +
    +
    +

    SuffixRowAdapter is a row adapter that hides the first columns in a row.

    +
    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)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SuffixRowAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + RangeRowAdapter + +
    +
    +
    +
    +
    +
    +

    RangeRowAdapter is a row adapter that only exposes a range of columns.

    +
    let adapter = RangeRowAdapter(1..<3)
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz, 4 as qux"
    +
    +// [bar:2 baz:3]
    +try Row.fetchOne(db, sql: sql, adapter: adapter)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct RangeRowAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ScopeAdapter + +
    +
    +
    +
    +
    +
    +

    ScopeAdapter is a row adapter that lets you define scopes on rows.

    +
    // Two adapters
    +let fooAdapter = ColumnMapping(["value": "foo"])
    +let barAdapter = ColumnMapping(["value": "bar"])
    +
    +// Define scopes
    +let adapter = ScopeAdapter([
    +    "foo": fooAdapter,
    +    "bar": barAdapter])
    +
    +// Fetch
    +let sql = "SELECT 'foo' AS foo, 'bar' AS bar"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +// Scoped rows:
    +if let fooRow = row.scopes["foo"] {
    +    fooRow["value"]    // "foo"
    +}
    +if let barRow = row.scopes["bar"] {
    +    barRow["value"]    // "bar"
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ScopeAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + RenameColumnAdapter + +
    +
    +
    +
    +
    +
    +

    RenameColumnAdapter is a row adapter that renames columns.

    + +

    For example:

    +
    let adapter = RenameColumnAdapter { $0 + "rrr" }
    +let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
    +
    +// [foorrr:"foo", barrrr:"bar", bazrrr:"baz"]
    +try Row.fetchOne(db, sql: sql, adapter: adapter)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct RenameColumnAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQL + +
    +
    +
    +
    +
    +
    +

    SQL helps you build SQL literal with +SQL Interpolation.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    let name: String = ...
    +    let id: Int64 = ...
    +    let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
    +    try db.execute(literal: query)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQL
    +
    extension SQL: SQLSpecificExpressible
    +
    extension SQL: SQLSelectable
    +
    extension SQL: SQLOrderingTerm
    +
    extension SQL: ExpressibleByStringInterpolation
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLRequest + +
    +
    +
    +
    +
    +
    +

    A FetchRequest built from raw SQL.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQLRequest<RowDecoder>
    +
    extension SQLRequest: FetchRequest
    +
    extension SQLRequest: ExpressibleByStringInterpolation
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementArguments +

+
+
+
    +
  • +
    + + + + StatementArguments + +
    +
    +
    +
    +
    +
    +

    StatementArguments provide values to argument placeholders in raw +SQL queries.

    + +

    Placeholders can take several forms (see https://www.sqlite.org/lang_expr.html#varparam +for more information):

    + +
      +
    • ?NNN (e.g. ?2): the NNN-th argument (starts at 1)
    • +
    • ?: the N-th argument, where N is one greater than the largest argument +number already assigned
    • +
    • :AAAA (e.g. :name): named argument

    • +
    • $AAAA (e.g. $name): named argument

    • +
    +

    Positional Arguments

    + +

    To fill question marks placeholders, feed StatementArguments with an array:

    +
    db.execute(
    +    sql: "INSERT ... (?, ?)",
    +    arguments: StatementArguments(["Arthur", 41]))
    +
    +// Array literals are automatically converted:
    +db.execute(
    +    sql: "INSERT ... (?, ?)",
    +    arguments: ["Arthur", 41])
    +
    +

    Named Arguments

    + +

    To fill named arguments, feed StatementArguments with a dictionary:

    +
    db.execute(
    +    sql: "INSERT ... (:name, :score)",
    +    arguments: StatementArguments(["name": "Arthur", "score": 41]))
    +
    +// Dictionary literals are automatically converted:
    +db.execute(
    +    sql: "INSERT ... (:name, :score)",
    +    arguments: ["name": "Arthur", "score": 41])
    +
    +

    Concatenating Arguments

    + +

    Several arguments can be concatenated and mixed with the +append(contentsOf:) method and the +, &+, += operators:

    +
    var arguments: StatementArguments = ["Arthur"]
    +arguments += [41]
    +db.execute(sql: "INSERT ... (?, ?)", arguments: arguments)
    +
    + +

    + and += operators consider that overriding named arguments is a +programmer error:

    +
    var arguments: StatementArguments = ["name": "Arthur"]
    +arguments += ["name": "Barbara"]
    +// fatal error: already defined statement argument: name
    +
    + +

    &+ and append(contentsOf:) allow overriding named arguments:

    +
    var arguments: StatementArguments = ["name": "Arthur"]
    +arguments = arguments &+ ["name": "Barbara"]
    +print(arguments)
    +// Prints ["name": "Barbara"]
    +
    +

    Mixed Arguments

    + +

    It is possible to mix named and positional arguments. Yet this is usually +confusing, and it is best to avoid this practice:

    +
    let sql = "SELECT ?2 AS two, :foo AS foo, ?1 AS one, :foo AS foo2, :bar AS bar"
    +var arguments: StatementArguments = [1, 2, "bar"] + ["foo": "foo"]
    +let row = try Row.fetchOne(db, sql: sql, arguments: arguments)!
    +print(row)
    +// Prints [two:2 foo:"foo" one:1 foo2:"foo" bar:"bar"]
    +
    + +

    Mixed arguments exist as a support for requests like the following:

    +
    let players = try Player
    +    .filter(sql: "team = :team", arguments: ["team": "Blue"])
    +    .filter(sql: "score > ?", arguments: [1000])
    +    .fetchAll(db)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct StatementArguments: CustomStringConvertible, Equatable,
    +                                  ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    DatabaseDateComponents reads and stores DateComponents in the database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseDateComponents : DatabaseValueConvertible, StatementColumnConvertible, Codable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database events +

+
+
+
    +
  • +
    + + + + DatabaseEvent + +
    +
    +
    +
    +
    +
    +

    A database event, notified to TransactionObserver.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseEvent
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS3 + +
    +
    +
    +
    +
    +
    +

    FTS3 lets you define “fts3” virtual tables.

    +
    // CREATE VIRTUAL TABLE document USING fts3(content)
    +try db.create(virtualTable: "document", using: FTS3()) { t in
    +    t.column("content")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS3 : VirtualTableModule
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS3Pattern + +
    +
    +
    +
    +
    +
    +

    A full text pattern that can query FTS3 and FTS4 virtual tables.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS3Pattern
    +
    extension FTS3Pattern: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    An FTS3 tokenizer, suitable for FTS3 and FTS4 table definitions:

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .simple // FTS3TokenizerDescriptor
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS3TokenizerDescriptor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS4 + +
    +
    +
    +
    +
    +
    +

    FTS4 lets you define “fts4” virtual tables.

    +
    // CREATE VIRTUAL TABLE document USING fts4(content)
    +try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS4 : VirtualTableModule
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5 + +
    +
    +
    +
    +
    +
    +

    FTS5 lets you define “fts5” virtual tables.

    +
    // CREATE VIRTUAL TABLE document USING fts5(content)
    +try db.create(virtualTable: "document", using: FTS5()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5Pattern + +
    +
    +
    +
    +
    +
    +

    A full text pattern that can query FTS5 virtual tables.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    + +
    +
    +
    +
    +
  • +
  • +
    + + + + FTS5Tokenization + +
    +
    +
    +
    +
    +
    +

    The reason why FTS5 is requesting tokenization.

    + +

    See https://www.sqlite.org/fts5.html#custom_tokenizers

    + + See more +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    An FTS5 tokenizer, suitable for FTS5 table definitions:

    +
    db.create(virtualTable: "book", using: FTS5()) { t in
    +    t.tokenizer = .unicode61() // FTS5TokenizerDescriptor
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html#tokenizers

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5TokenFlags + +
    +
    +
    +
    +
    +
    +

    Flags that tell SQLite how to register a token.

    + +

    See the FTS5_TOKEN_* flags in https://www.sqlite.org/fts5.html#custom_tokenizers.

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + DatabaseMigrator + +
    +
    +
    +
    +
    +
    +

    A DatabaseMigrator registers and applies database migrations.

    + +

    Migrations are named blocks of SQL statements that are guaranteed to be +applied in order, once and only once.

    + +

    When a user upgrades your application, only non-applied migration are run.

    + +

    Usage:

    +
    var migrator = DatabaseMigrator()
    +
    +// 1st migration
    +migrator.registerMigration("createLibrary") { db in
    +    try db.create(table: "author") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("creationDate", .datetime)
    +        t.column("name", .text).notNull()
    +    }
    +
    +    try db.create(table: "book") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("authorId", .integer)
    +            .notNull()
    +            .references("author", onDelete: .cascade)
    +        t.column("title", .text).notNull()
    +    }
    +}
    +
    +// 2nd migration
    +migrator.registerMigration("AddBirthYearToAuthors") { db in
    +    try db.alter(table: "author") { t
    +        t.add(column: "birthYear", .integer)
    +    }
    +}
    +
    +// Migrations for future versions will be inserted here:
    +//
    +// // 3rd migration
    +// migrator.registerMigration("...") { db in
    +//     ...
    +// }
    +
    +try migrator.migrate(dbQueue)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseMigrator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ForeignKey + +
    +
    +
    +
    +
    +
    +

    A ForeignKey helps building associations when GRDB can’t infer a foreign +key from the database schema.

    + +

    Sometimes the database schema does not define any foreign key between two +tables. And sometimes, there are several foreign keys from a table +to another:

    +
    | Table book   |       | Table person |
    +| ------------ |       | ------------ |
    +| id           |   +-->• id           |
    +| authorId     •---+   | name         |
    +| translatorId •---+
    +| title        |
    +
    + +

    When this happens, associations can’t be automatically inferred from the +database schema. GRDB will complain with a fatal error such as “Ambiguous +foreign key from book to person”, or “Could not infer foreign key from book +to person”.

    + +

    Your help is needed. You have to instruct GRDB which foreign key to use:

    +
    struct Book: TableRecord {
    +    // Define foreign keys
    +    static let authorForeignKey = ForeignKey(["authorId"]))
    +    static let translatorForeignKey = ForeignKey(["translatorId"]))
    +
    +    // Use foreign keys to define associations:
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +    static let translator = belongsTo(Person.self, using: translatorForeignKey)
    +}
    +
    + +

    Foreign keys are always defined from the table that contains the columns at +the origin of the foreign key. Person’s symmetric HasMany associations reuse +Book’s foreign keys:

    +
    struct Person: TableRecord {
    +    static let writtenBooks = hasMany(Book.self, using: Book.authorForeignKey)
    +    static let translatedBooks = hasMany(Book.self, using: Book.translatorForeignKey)
    +}
    +
    + +

    Foreign keys can also be defined from query interface columns:

    +
    struct Book: TableRecord {
    +    enum Columns: String, ColumnExpression {
    +        case id, title, authorId, translatorId
    +    }
    +
    +    static let authorForeignKey = ForeignKey([Columns.authorId]))
    +    static let translatorForeignKey = ForeignKey([Columns.translatorId]))
    +}
    +
    + +

    When the destination table of a foreign key does not define any primary key, +you need to provide the full definition of a foreign key:

    +
    struct Book: TableRecord {
    +    static let authorForeignKey = ForeignKey(["authorId"], to: ["id"]))
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ForeignKey : Equatable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + AssociationAggregate + +
    +
    +
    +
    +
    +
    +

    An AssociationAggregate is able to compute aggregated values from a +population of associated records.

    + +

    For example:

    +
    struct Author: TableRecord {
    +    static let books = hasMany(Book.self)
    +}
    +
    +let bookCount = Author.books.count // AssociationAggregate<Author>
    +
    + +

    Association aggregates can be used in the annotated(with:) and +having(_:) request methods:

    +
    let request = Author.annotated(with: bookCount)
    +let request = Author.having(bookCount >= 10)
    +
    + +

    The RowDecoder generic type helps the compiler prevent incorrect use +of aggregates:

    +
    // Won't compile because Fruit is not Author.
    +let request = Fruit.annotated(with: bookCount)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + BelongsToAssociation + +
    +
    +
    +
    +
    +
    +

    The BelongsTo association sets up a one-to-one connection from a record +type to another record type, such as each instance of the declaring record +“belongs to” an instance of the other record.

    + +

    For example, if your application includes authors and books, and each book +is assigned its author, you’d declare the association this way:

    +
    struct Author: TableRecord { ... }
    +struct Book: TableRecord {
    +    static let author = belongsTo(Author.self)
    +    ...
    +}
    +
    + +

    A BelongsTo associations should be supported by an SQLite foreign key.

    + +

    Foreign keys are the recommended way to declare relationships between +database tables because not only will SQLite guarantee the integrity of your +data, but GRDB will be able to use those foreign keys to automatically +configure your association.

    + +

    You define the foreign key when you create database tables. For example:

    +
    try db.create(table: "author") { t in
    +    t.autoIncrementedPrimaryKey("id")             // (1)
    +    t.column("name", .text)
    +}
    +try db.create(table: "book") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("authorId", .integer)                // (2)
    +        .notNull()                                // (3)
    +        .indexed()                                // (4)
    +        .references("author", onDelete: .cascade) // (5)
    +    t.column("title", .text)
    +}
    +
    + +
      +
    1. The author table has a primary key.
    2. +
    3. The book.authorId column is used to link a book to the author it +belongs to.
    4. +
    5. Make the book.authorId column not null if you want SQLite to guarantee +that all books have an author.
    6. +
    7. Create an index on the book.authorId column in order to ease the +selection of an author’s books.
    8. +
    9. Create a foreign key from book.authorId column to authors.id, so that +SQLite guarantees that no book refers to a missing author. The +onDelete: .cascade option has SQLite automatically delete all of an +author’s books when that author is deleted. +See https://sqlite.org/foreignkeys.html#fk_actions for more information.
    10. +
    + +

    The example above uses auto-incremented primary keys. But generally +speaking, all primary keys are supported.

    + +

    If the database schema does not define foreign keys between tables, you can +still use BelongsTo associations. But your help is needed to define the +missing foreign key:

    +
    struct Book: FetchableRecord, TableRecord {
    +    static let author = belongsTo(Author.self, using: ForeignKey(...))
    +}
    +
    + +

    See ForeignKey for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct BelongsToAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HasManyAssociation + +
    +
    +
    +
    +
    +
    +

    The HasMany association indicates a one-to-many connection between two +record types, such as each instance of the declaring record “has many” +instances of the other record.

    + +

    For example, if your application includes authors and books, and each author +is assigned zero or more books, you’d declare the association this way:

    +
    struct Book: TableRecord { ... }
    +struct Author: TableRecord {
    +    static let books = hasMany(Book.self)
    +    ...
    +}
    +
    + +

    HasMany associations should be supported by an SQLite foreign key.

    + +

    Foreign keys are the recommended way to declare relationships between +database tables because not only will SQLite guarantee the integrity of your +data, but GRDB will be able to use those foreign keys to automatically +configure your association.

    + +

    You define the foreign key when you create database tables. For example:

    +
    try db.create(table: "author") { t in
    +    t.autoIncrementedPrimaryKey("id")             // (1)
    +    t.column("name", .text)
    +}
    +try db.create(table: "book") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("authorId", .integer)                // (2)
    +        .notNull()                                // (3)
    +        .indexed()                                // (4)
    +        .references("author", onDelete: .cascade) // (5)
    +    t.column("title", .text)
    +}
    +
    + +
      +
    1. The author table has a primary key.
    2. +
    3. The book.authorId column is used to link a book to the author it +belongs to.
    4. +
    5. Make the book.authorId column not null if you want SQLite to guarantee +that all books have an author.
    6. +
    7. Create an index on the book.authorId column in order to ease the +selection of an author’s books.
    8. +
    9. Create a foreign key from book.authorId column to authors.id, so that +SQLite guarantees that no book refers to a missing author. The +onDelete: .cascade option has SQLite automatically delete all of an +author’s books when that author is deleted. +See https://sqlite.org/foreignkeys.html#fk_actions for more information.
    10. +
    + +

    The example above uses auto-incremented primary keys. But generally +speaking, all primary keys are supported.

    + +

    If the database schema does not define foreign keys between tables, you can +still use HasMany associations. But your help is needed to define the +missing foreign key:

    +
    struct Author: TableRecord {
    +    static let books = hasMany(Book.self, using: ForeignKey(...))
    +}
    +
    + +

    See ForeignKey for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasManyAssociation<Origin, Destination> : AssociationToMany
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The HasManyThrough association is often used to set up a many-to-many +connection with another record. This association indicates that the +declaring record can be matched with zero or more instances of another +record by proceeding through a third record.

    + +

    For example, consider the practice of passport delivery. One coutry +“has many” citizens “through” its passports:

    +
    struct Country: TableRecord {
    +    static let passports = hasMany(Passport.self)
    +    static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
    +    ...
    +}
    +
    +struct Passport: TableRecord {
    +    static let citizen = belongsTo(Citizen.self)
    +    ...
    +}
    +
    +struct Citizen: TableRecord { ... }
    +
    + +

    The HasManyThrough association is also useful for setting up +“shortcuts” through nested HasMany associations. For example, if a document +has many sections, and a section has many paragraphs, you may sometimes want +to get a simple collection of all paragraphs in the document. You could set +that up this way:

    +
    struct Document: TableRecord {
    +    static let sections = hasMany(Section.self)
    +    static let paragraphs = hasMany(Paragraph.self, through: sections, using: Section.paragraphs)
    +}
    +
    +struct Section: TableRecord {
    +    static let paragraphs = hasMany(Paragraph.self)
    +}
    +
    +struct Paragraph: TableRecord {
    +}
    +
    + +

    As in the examples above, HasManyThrough association is always built from +two other associations: the through: and using: arguments. Those +associations can be any other association (BelongsTo, HasMany, +HasManyThrough, etc).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasManyThroughAssociation<Origin, Destination> : AssociationToMany
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HasOneAssociation + +
    +
    +
    +
    +
    +
    +

    The HasOne association indicates a one-to-one connection between two +record types, such as each instance of the declaring record “has one” +instances of the other record.

    + +

    For example, if your application has one database table for countries, and +another for their demographic profiles, you’d declare the association +this way:

    +
    struct Demographics: TableRecord { ... }
    +struct Country: TableRecord {
    +    static let demographics = hasOne(Demographics.self)
    +    ...
    +}
    +
    + +

    HasOne associations should be supported by an SQLite foreign key.

    + +

    Foreign keys are the recommended way to declare relationships between +database tables because not only will SQLite guarantee the integrity of your +data, but GRDB will be able to use those foreign keys to automatically +configure your association.

    + +

    You define the foreign key when you create database tables. For example:

    +
    try db.create(table: "country") { t in
    +    t.column("code", .text).primaryKey()           // (1)
    +    t.column("name", .text)
    +}
    +try db.create(table: "demographics") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("countryCode", .text)                 // (2)
    +        .notNull()                                 // (3)
    +        .unique()                                  // (4)
    +        .references("country", onDelete: .cascade) // (5)
    +    t.column("population", .integer)
    +    t.column("density", .double)
    +}
    +
    + +
      +
    1. The country table has a primary key.
    2. +
    3. The demographics.countryCode column is used to link a demographic +profile to the country it belongs to.
    4. +
    5. Make the demographics.countryCode column not null if you want SQLite to +guarantee that all profiles are linked to a country.
    6. +
    7. Create a unique index on the demographics.countryCode column in order to +guarantee the unicity of any country’s profile.
    8. +
    9. Create a foreign key from demographics.countryCode column to +country.code, so that SQLite guarantees that no profile refers to a +missing country. The onDelete: .cascade option has SQLite automatically +delete a profile when its country is deleted. +See https://sqlite.org/foreignkeys.html#fk_actions for more information.
    10. +
    + +

    The example above uses a string primary for the country table. But generally +speaking, all primary keys are supported.

    + +

    If the database schema does not follow this convention, and does not define +foreign keys between tables, you can still use HasOne associations. But +your help is needed to define the missing foreign key:

    +
    struct Country: FetchableRecord, TableRecord {
    +    static let demographics = hasOne(Demographics.self, using: ForeignKey(...))
    +}
    +
    + +

    See ForeignKey for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasOneAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A HasOneThrough association sets up a one-to-one connection with +another record. This association indicates that the declaring record can be +matched with one instance of another record by proceeding through a third +record. For example, if each book belongs to a library, and each library has +one address, then one knows where the book should be returned to:

    +
    struct Book: TableRecord {
    +    static let library = belongsTo(Library.self)
    +    static let returnAddress = hasOne(Address.self, through: library, using: Library.address)
    +    ...
    +}
    +
    +struct Library: TableRecord {
    +    static let address = hasOne(Address.self)
    +    ...
    +}
    +
    +struct Address: TableRecord { ... }
    +
    + +

    As in the example above, HasOneThrough association is always built from +two other associations: the through: and using: arguments. Those +associations can be any other association to one (BelongsTo, HasOne, +HasOneThrough).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasOneThroughAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + JoinAssociation + +
    +
    +
    +
    +
    +
    +

    The Join association is used to join common table expression to regular +tables or other common table expressions.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct JoinAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + CommonTableExpression + +
    +
    +
    +
    +
    +
    +

    A common table expression that can be +used with the GRDB query interface.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct CommonTableExpression<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + QueryInterfaceRequest + +
    +
    +
    +
    +
    +
    +

    QueryInterfaceRequest is a request that generates SQL for you.

    + +

    For example:

    +
    try dbQueue.read { db in
    +    let request = Player
    +        .filter(Column("score") > 1000)
    +        .order(Column("name"))
    +    let players = try request.fetchAll(db) // [Player]
    +}
    +
    + +

    See https://github.com/groue/GRDB.swift#the-query-interface

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct QueryInterfaceRequest<RowDecoder>
    +
    extension QueryInterfaceRequest: FetchRequest
    +
    extension QueryInterfaceRequest: SelectionRequest
    +
    extension QueryInterfaceRequest: FilteredRequest
    +
    extension QueryInterfaceRequest: OrderedRequest
    +
    extension QueryInterfaceRequest: AggregatingRequest
    +
    extension QueryInterfaceRequest: JoinableRequest
    +
    extension QueryInterfaceRequest: TableRequest
    +
    extension QueryInterfaceRequest: DerivableRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ColumnAssignment +

+
+
+ +
+
+
+ + +
+ +

PersistenceContainer +

+
+
+
    +
  • +
    + + + + PersistenceContainer + +
    +
    +
    +
    +
    +
    +

    Use persistence containers in the encode(to:) method of your +encodable records:

    +
    struct Player: EncodableRecord {
    +    var id: Int64?
    +    var name: String?
    +
    +    func encode(to container: inout PersistenceContainer) {
    +        container["id"] = id
    +        container["name"] = name
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PersistenceContainer
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLSelection + +
    +
    +
    +
    +
    +
    +

    The type that can be selected, as described at +https://www.sqlite.org/syntax/result-column.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQLSelection
    +
    extension SQLSelection: SQLSelectable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AllColumns +

+
+
+
    +
  • +
    + + + + AllColumns + +
    +
    +
    +
    +
    +
    +

    AllColumns is the * in SELECT *.

    + +

    You use AllColumns in your custom implementation of +TableRecord.databaseSelection.

    + +

    For example:

    +
    struct Player : TableRecord {
    +    static var databaseTableName = "player"
    +    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
    +}
    +
    +// SELECT *, rowid FROM player
    +let request = Player.all()
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AllColumns : SQLSelectable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLSubquery + +
    +
    +
    +
    +
    +
    +

    The type that can be embedded as a subquery.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQLSubquery
    +
    extension SQLSubquery: SQLSubqueryable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Table + +
    +
    +
    +
    +
    +
    +

    Table can build query interface requests.

    +
    // SELECT * FROM player WHERE score >= 1000
    +let table = Table("player")
    +let rows: [Row] = try dbQueue.read { db in
    +    table.all()
    +        .filter(Column("score") >= 1000)
    +        .fetchAll(db)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct Table<RowDecoder>
    +
    extension Table: DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct VirtualTableConfiguration
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The MutablePersistableRecord protocol uses this type in order to handle +SQLite conflicts when records are inserted or updated.

    + +

    See MutablePersistableRecord.persistenceConflictPolicy.

    + +

    See https://www.sqlite.org/lang_conflict.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PersistenceConflictPolicy
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Inflections + +
    +
    +
    +
    +
    +
    +

    Experimental

    + +

    A type that controls GRDB string inflections.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct Inflections
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ValueObservation + +
    +
    +
    +
    +
    +
    +

    ValueObservation tracks changes in the results of database requests, and +notifies fresh values whenever the database changes.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed.")
    +    })
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ValueObservation<Reducer> where Reducer : ValueReducer
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/AdaptedFetchRequest.html b/docs/5.16/Structs/AdaptedFetchRequest.html new file mode 100644 index 000000000..1b4255eb3 --- /dev/null +++ b/docs/5.16/Structs/AdaptedFetchRequest.html @@ -0,0 +1,1236 @@ + + + + AdaptedFetchRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AdaptedFetchRequest

+
+
+ +
public struct AdaptedFetchRequest<Base> : FetchRequest where Base : FetchRequest
+ +
+
+

An adapted request.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/AllColumns.html b/docs/5.16/Structs/AllColumns.html new file mode 100644 index 000000000..e402eebc6 --- /dev/null +++ b/docs/5.16/Structs/AllColumns.html @@ -0,0 +1,1193 @@ + + + + AllColumns Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AllColumns

+
+
+ +
public struct AllColumns : SQLSelectable
+ +
+
+

AllColumns is the * in SELECT *.

+ +

You use AllColumns in your custom implementation of +TableRecord.databaseSelection.

+ +

For example:

+
struct Player : TableRecord {
+    static var databaseTableName = "player"
+    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
+}
+
+// SELECT *, rowid FROM player
+let request = Player.all()
+
+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    The * selection.

    + +

    For example:

    +
    // SELECT * FROM player
    +Player.select(AllColumns())
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSelection + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSelection: SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/AnyDatabaseRegionConvertible.html b/docs/5.16/Structs/AnyDatabaseRegionConvertible.html new file mode 100644 index 000000000..28c2e0874 --- /dev/null +++ b/docs/5.16/Structs/AnyDatabaseRegionConvertible.html @@ -0,0 +1,1176 @@ + + + + AnyDatabaseRegionConvertible Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseRegionConvertible

+
+
+ +
public struct AnyDatabaseRegionConvertible : DatabaseRegionConvertible
+ +
+
+

A type-erased DatabaseRegionConvertible

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/AnyFetchRequest.html b/docs/5.16/Structs/AnyFetchRequest.html new file mode 100644 index 000000000..ea8f2997a --- /dev/null +++ b/docs/5.16/Structs/AnyFetchRequest.html @@ -0,0 +1,1307 @@ + + + + AnyFetchRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyFetchRequest

+
+
+ +
public struct AnyFetchRequest<RowDecoder> : FetchRequest
+ +
+
+

A type-erased FetchRequest.

+ +

An AnyFetchRequest forwards its operations to an underlying request, +hiding its specifics.

+ + +
+
+
+
    +
  • +
    + + + + asRequest(of:) + +
    +
    +
    +
    +
    +
    +

    Creates a request bound to type RowDecoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asRequest<RowDecoder>(of type: RowDecoder.Type) -> AnyFetchRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + type + + +
    +

    The fetched type RowDecoder

    +
    +
    +
    +
    +

    Return Value

    +

    A request bound to type RowDecoder.

    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSubquery + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSubquery: SQLSubquery { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCount(_ db: Database) throws -> Int
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makePreparedRequest(
    +    _ db: Database,
    +    forSingleResult singleResult: Bool = false)
    +throws -> PreparedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AnyFetchRequest +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that wraps and forwards operations to request.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Request: FetchRequest>(_ request: Request)
    +where Request.RowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/AssociationAggregate.html b/docs/5.16/Structs/AssociationAggregate.html new file mode 100644 index 000000000..0b5a86ff3 --- /dev/null +++ b/docs/5.16/Structs/AssociationAggregate.html @@ -0,0 +1,1219 @@ + + + + AssociationAggregate Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociationAggregate

+
+
+ +
public struct AssociationAggregate<RowDecoder>
+ +
+
+

An AssociationAggregate is able to compute aggregated values from a +population of associated records.

+ +

For example:

+
struct Author: TableRecord {
+    static let books = hasMany(Book.self)
+}
+
+let bookCount = Author.books.count // AssociationAggregate<Author>
+
+ +

Association aggregates can be used in the annotated(with:) and +having(_:) request methods:

+
let request = Author.annotated(with: bookCount)
+let request = Author.having(bookCount >= 10)
+
+ +

The RowDecoder generic type helps the compiler prevent incorrect use +of aggregates:

+
// Won't compile because Fruit is not Author.
+let request = Fruit.annotated(with: bookCount)
+
+ + +
+
+
+
    +
  • +
    + + + + forKey(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that is selected in a column with the given name.

    + +

    For example:

    +
    let aggregate = Author.books.count.forKey("numberOfBooks")
    +let request = Author.annotated(with: aggregate)
    +if let row = try Row.fetchOne(db, request) {
    +    let numberOfBooks: Int = row["numberOfBooks"]
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: String) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + forKey(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that is selected in a column named like the given +coding key.

    + +

    For example:

    +
    struct AuthorInfo: Decodable, FetchableRecord {
    +    var author: Author
    +    var numberOfBooks: Int
    +
    +    static func fetchAll(_ db: Database) throws -> [AuthorInfo] {
    +        let aggregate = Author.books.count.forKey(CodingKeys.numberOfBooks)
    +        let request = Author.annotated(with: aggregate)
    +        return try AuthorInfo.fetchAll(db, request)
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: CodingKey) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/Column.html b/docs/5.16/Structs/Column.html new file mode 100644 index 000000000..a96a76350 --- /dev/null +++ b/docs/5.16/Structs/Column.html @@ -0,0 +1,1271 @@ + + + + Column Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Column

+
+
+ +
public struct Column : ColumnExpression, Equatable
+ +
+
+

A column in a database table.

+ +

When you need to introduce your own column type, don’t wrap a Column. +Instead, adopt the ColumnExpression protocol.

+ +

See https://github.com/groue/GRDB.swift#the-query-interface

+ + +
+
+
+
    +
  • +
    + + + + rowID + +
    +
    +
    +
    +
    +
    +

    The hidden rowID column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let rowID: Column
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a column given its name.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ name: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a column given a CodingKey.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ codingKey: CodingKey)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @_disfavoredOverload
    +public static func == (lhs: Column, rhs: Column) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ColumnInfo.html b/docs/5.16/Structs/ColumnInfo.html new file mode 100644 index 000000000..6fd0ecfd3 --- /dev/null +++ b/docs/5.16/Structs/ColumnInfo.html @@ -0,0 +1,1323 @@ + + + + ColumnInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnInfo

+
+
+ +
public struct ColumnInfo : FetchableRecord
+ +
+
+

A column of a database table.

+ +

This type closely matches the information returned by the +table_info and table_xinfo pragmas.

+
sqlite> CREATE TABLE player (
+   ...>   id INTEGER PRIMARY KEY,
+   ...>   firstName TEXT,
+   ...>   lastName TEXT);
+sqlite> PRAGMA table_info(player);
+cid     name        type        notnull     dflt_value  pk
+------  ----------  ----------  ----------  ----------  -----
+0       id          INTEGER     0                       1
+1       firstName   TEXT        0                       0
+2       lastName    TEXT        0                       0
+sqlite> PRAGMA table_xinfo(player);
+cid     name        type        notnull     dflt_value  pk     hidden
+------  ----------  ----------  ----------  ----------  -----  ----------
+0       id          INTEGER     0                       1      0
+1       firstName   TEXT        0                       0      0
+2       lastName    TEXT        0                       0      0
+
+ +

See Database.columns(in:) and https://www.sqlite.org/pragma.html#pragma_table_info

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The column name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + type + +
    +
    +
    +
    +
    +
    +

    The column data type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let type: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isNotNull + +
    +
    +
    +
    +
    +
    +

    True if and only if the column is constrained to be not null.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let isNotNull: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + defaultValueSQL + +
    +
    +
    +
    +
    +
    +

    The SQL snippet that defines the default value, if any.

    + +

    When nil, the column has no default value.

    + +

    When not nil, it contains an SQL string that defines an expression. That +expression may be a literal, as 1, or 'foo'. It may also contain a +non-constant expression such as CURRENT_TIMESTAMP.

    + +

    For example:

    +
    try db.execute(sql: """
    +    CREATE TABLE player(
    +        id INTEGER PRIMARY KEY,
    +        name TEXT DEFAULT 'Anonymous',
    +        score INT DEFAULT 0,
    +        creationDate DATE DEFAULT CURRENT_TIMESTAMP
    +    )
    +    """)
    +let columnInfos = try db.columns(in: "player")
    +columnInfos[0].defaultValueSQL // nil
    +columnInfos[1].defaultValueSQL // "'Anoynymous'"
    +columnInfos[2].defaultValueSQL // "0"
    +columnInfos[3].defaultValueSQL // "CURRENT_TIMESTAMP"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let defaultValueSQL: String?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + primaryKeyIndex + +
    +
    +
    +
    +
    +
    +

    Zero for columns that are not part of the primary key.

    + +

    Before SQLite 3.7.16, it is 1 for columns that are part of the +primary key.

    + +

    Starting from SQLite 3.7.16, it is the one-based index of the column in +the primary key for columns that are part of the primary key.

    + +

    References:

    + + + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let primaryKeyIndex: Int
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ColumnMapping.html b/docs/5.16/Structs/ColumnMapping.html new file mode 100644 index 000000000..9aa8567b2 --- /dev/null +++ b/docs/5.16/Structs/ColumnMapping.html @@ -0,0 +1,1153 @@ + + + + ColumnMapping Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnMapping

+
+
+ +
public struct ColumnMapping : RowAdapter
+ +
+
+

ColumnMapping is a row adapter that maps column names.

+
let adapter = ColumnMapping(["foo": "bar"])
+let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
+
+// [foo:"bar"]
+try Row.fetchOne(db, sql: sql, adapter: adapter)
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a ColumnMapping with a dictionary from mapped column names to +column names in a base row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ mapping: [String : String])
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/CommonTableExpression.html b/docs/5.16/Structs/CommonTableExpression.html new file mode 100644 index 000000000..de2121407 --- /dev/null +++ b/docs/5.16/Structs/CommonTableExpression.html @@ -0,0 +1,2359 @@ + + + + CommonTableExpression Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CommonTableExpression

+
+
+ +
public struct CommonTableExpression<RowDecoder>
+ +
+
+

A common table expression that can be +used with the GRDB query interface.

+ + +
+
+
+
    +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name of the common table expression.

    + +

    For example:

    +
    // WITH answer AS (SELECT 42) ...
    +let answer = CommonTableExpression(
    +    named: "answer",
    +    sql: "SELECT 42")
    +answer.tableName // "answer"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from a request.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    request: Player.all())
    +
    +// WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    request: SQLRequest<Player>(sql: "SELECT * FROM player"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Request: SQLSubqueryable>(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    request: Request)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + request + + +
    +

    A request.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL string and +optional arguments.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    sql: "SELECT * FROM player WHERE name = ?",
    +    arguments: ["O'Brien"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let name = "O'Brien"
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    literal: "SELECT * FROM player WHERE name = \(name)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    literal sqlLiteral: SQL)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + all() + +
    +
    +
    +
    +
    +
    +

    Creates a request for all rows of the common table expression.

    + +

    You can fetch from this request:

    +
    // WITH answer AS (SELECT 42 AS value)
    +// SELECT * FROM answer
    +struct Answer: Decodable, FetchableRecord {
    +    var value: Int
    +}
    +let cte = CommonTableExpression<Answer>(
    +    named: "answer",
    +    sql: "SELECT 42 AS value")
    +let answer = try cte.all().with(cte).fetchOne(db)!
    +print(answer.value) // prints 42
    +
    + +

    You can embed this request as a subquery:

    +
    // WITH answer AS (SELECT 42 AS value)
    +// SELECT * FROM player
    +// WHERE score = (SELECT * FROM answer)
    +let answer = CommonTableExpression(
    +    named: "answer",
    +    sql: "SELECT 42 AS value")
    +let players = try Player
    +    .filter(Column("score") == answer.all())
    +    .with(answer)
    +    .fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func all() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a +common table expression.

    +
    let playerNameCTE = CommonTableExpression(
    +    named: "playerName",
    +    request: Player.select(Column("name"))
    +
    +// name IN playerName
    +playerNameCTE.contains(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table record that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Destination.Type,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of +the association.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table record that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Destination.Type)
    +-> JoinAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of +the association.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Table<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Table<Destination>)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from a request.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression(
    +    named: "p",
    +    request: Player.all())
    +
    +// WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression(
    +    named: "p",
    +    request: SQLRequest<Player>(sql: "SELECT * FROM player"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Request: SQLSubqueryable>(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    request: Request)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + request + + +
    +

    A request.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL string and +optional arguments.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let p = CommonTableExpression(
    +    named: "p",
    +    sql: "SELECT * FROM player WHERE name = ?",
    +    arguments: ["O'Brien"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let name = "O'Brien"
    +let p = CommonTableExpression(
    +    named: "p",
    +    literal: "SELECT * FROM player WHERE name = \(name)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    literal sqlLiteral: SQL)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/Configuration.html b/docs/5.16/Structs/Configuration.html new file mode 100644 index 000000000..2fb515972 --- /dev/null +++ b/docs/5.16/Structs/Configuration.html @@ -0,0 +1,1733 @@ + + + + Configuration Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Configuration

+
+
+ +
public struct Configuration
+ +
+
+

Configuration for a DatabaseQueue or DatabasePool.

+ + +
+
+
+
+ + +
+ +

Misc options +

+
+
+
    +
  • +
    + + + + foreignKeysEnabled + +
    +
    +
    +
    +
    +
    +

    If true, foreign key constraints are checked.

    + +

    Default: true

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var foreignKeysEnabled: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + readonly + +
    +
    +
    +
    +
    +
    +

    If true, database modifications are disallowed.

    + +

    Default: false

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var readonly: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + label + +
    +
    +
    +
    +
    +
    +

    The configuration label.

    + +

    You can query this label at runtime:

    +
    var configuration = Configuration()
    +configuration.label = "MyDatabase"
    +let dbQueue = try DatabaseQueue(path: ..., configuration: configuration)
    +
    +try dbQueue.read { db in
    +    print(db.configuration.label) // Prints "MyDatabase"
    +}
    +
    + +

    The configuration label is also used to name Database connections (the +Database.description property), and the various dispatch queues +created by GRDB, visible in debugging sessions and crash logs.

    + +

    Those connection names and dispatch queue labels are intended for +debugging only. Their format may change between GRDB releases. +Applications should not depend on connection names and dispatch +queue labels.

    + +

    If the configuration label is nil, the current GRDB implementation uses +the following names:

    + +
      +
    • GRDB.DatabaseQueue: the (unique) connection of a DatabaseQueue
    • +
    • GRDB.DatabasePool.writer: the (unique) writer connection of +a DatabasePool
    • +
    • GRDB.DatabasePool.reader.N, where N is 1, 2, …: one of the reader +connection(s) of a DatabasePool. N may get bigger than the maximum +number of concurrent readers, as SQLite connections get closed and new +ones are opened.
    • +
    • GRDB.DatabasePool.snapshot.N: the connection of a DatabaseSnapshot. +N grows with the number of snapshots.
    • +
    + +

    If the configuration label is not nil, for example “MyDatabase”, the +current GRDB implementation uses the following names:

    + +
      +
    • MyDatabase: the (unique) connection of a DatabaseQueue
    • +
    • MyDatabase.writer: the (unique) writer connection of a DatabasePool
    • +
    • MyDatabase.reader.N, where N is 1, 2, …: one of the reader +connection(s) of a DatabasePool. N may get bigger than the maximum +number of concurrent readers, as SQLite connections get closed and new +ones are opened.
    • +
    • MyDatabase.snapshot.N: the connection of a DatabaseSnapshot. N grows +with the number of snapshots.
    • +
    + +

    The default configuration label is nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var label: String?
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    If false, SQLite from version 3.29.0 will not interpret a double-quoted +string as a string literal if it does not match any valid identifier.

    + +

    For example:

    +
    // Error: no such column: foo
    +let name = try String.fetchOne(db, sql: """
    +    SELECT "foo" FROM "player"
    +    """)
    +
    + +

    When true, or before version 3.29.0, such strings are interpreted as +string literals, as in the example below. This is a well known SQLite +misfeature.

    +
    // Success: "foo"
    +let name = try String.fetchOne(db, sql: """
    +    SELECT "foo" FROM "player"
    +    """)
    +
    +
      +
    • Default value: false
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var acceptsDoubleQuotedStringLiterals: Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    When true, the Database.suspendNotification and +Database.resumeNotification suspend and resume the database. Database +suspension helps avoiding the 0xdead10cc +exception.

    + +

    During suspension, all database accesses but reads in WAL mode may throw +a DatabaseError of code SQLITE_INTERRUPT, or SQLITE_ABORT. You can +check for those error codes with the +DatabaseError.isInterruptionError property.

    + +

    Experimental

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var observesSuspensionNotifications: Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Managing SQLite Connections +

+
+
+
    +
  • +
    + + + + prepareDatabase(_:) + +
    +
    +
    +
    +
    +
    +

    The function argument is run when an SQLite connection is opened, +before the connection is made available for database access methods.

    + +

    This method can be called several times. The preparation functions are +run in the same order.

    + +

    For example:

    +
    var config = Configuration()
    +config.prepareDatabase { db in
    +    try db.execute(sql: "PRAGMA kdf_iter = 10000")
    +}
    +
    + +

    When you use a DatabasePool, preparation functions are called for +the writer connection and all reader connections. You can distinguish +them by querying db.configuration.readonly:

    +
    var config = Configuration()
    +config.prepareDatabase { db in
    +    if db.configuration.readonly {
    +        // reader connection
    +    } else {
    +        // writer connection
    +    }
    +}
    +
    + +

    On newly created databases, DatabasePool the WAL mode is activated +after the preparation functions have run.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func prepareDatabase(_ setup: @escaping (Database) throws -> Void)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Transactions +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    The default kind of transaction.

    + +

    Default: deferred

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var defaultTransactionKind: Database.TransactionKind
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    If false, it is a programmer error to leave a transaction opened at the +end of a database access block.

    + +

    For example:

    +
    let dbQueue = DatabaseQueue()
    +
    +// fatal error: A transaction has been left opened at the end of a database access
    +try dbQueue.inDatabase { db in
    +    try db.beginTransaction()
    +}
    +
    + +

    If true, one can leave opened transaction at the end of database access +blocks:

    +
    var config = Configuration()
    +config.allowsUnsafeTransactions = true
    +let dbQueue = DatabaseQueue(configuration: config)
    +
    +try dbQueue.inDatabase { db in
    +    try db.beginTransaction()
    +}
    +
    +try dbQueue.inDatabase { db in
    +    try db.commit()
    +}
    +
    + +

    This configuration flag has no effect on DatabasePool readers: those +never allow leaving a transaction opened at the end of a read access.

    + +

    Default: false

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var allowsUnsafeTransactions: Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Concurrency +

+
+
+
    +
  • +
    + + + + busyMode + +
    +
    +
    +
    +
    +
    +

    The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy

    + +

    Default: immediateError

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var busyMode: Database.BusyMode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + maximumReaderCount + +
    +
    +
    +
    +
    +
    +

    The maximum number of concurrent readers (applies to database +pools only).

    + +

    Default: 5

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var maximumReaderCount: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + qos + +
    +
    +
    +
    +
    +
    +

    The quality of service class for the work performed by the database.

    + +

    The quality of service is ignored if you supply a target queue.

    + +

    Default: .default

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var qos: DispatchQoS
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + targetQueue + +
    +
    +
    +
    +
    +
    +

    The target queue for all database accesses.

    + +

    When you use a database pool, make sure the queue is concurrent. If +it is serial, no concurrent database access can happen, and you may +experience deadlocks.

    + +

    If the queue is nil, all database accesses happen in unspecified +dispatch queues whose quality of service and label are determined by the +qos and label Configuration properties.

    + +

    Default: nil

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var targetQueue: DispatchQueue?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Factory Configuration +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a factory configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseDateComponents.html b/docs/5.16/Structs/DatabaseDateComponents.html new file mode 100644 index 000000000..8f12d4ba2 --- /dev/null +++ b/docs/5.16/Structs/DatabaseDateComponents.html @@ -0,0 +1,1543 @@ + + + + DatabaseDateComponents Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseDateComponents

+
+
+ +
public struct DatabaseDateComponents : DatabaseValueConvertible, StatementColumnConvertible, Codable
+ +
+
+

DatabaseDateComponents reads and stores DateComponents in the database.

+ + +
+
+
+
    +
  • +
    + + + + Format + +
    +
    +
    +
    +
    +
    +

    The available formats for reading and storing date components.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum Format : String
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

NSDateComponents conversion +

+
+
+
    +
  • +
    + + + + dateComponents + +
    +
    +
    +
    +
    +
    +

    The date components

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let dateComponents: DateComponents
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + format + +
    +
    +
    +
    +
    +
    +

    The database format

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let format: Format
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:format:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseDateComponents from a DateComponents and a format.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ dateComponents: DateComponents, format: Format)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + dateComponents + + +
    +

    An optional DateComponents.

    +
    +
    + + format + + +
    +

    The format used for storing the date components in +the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementColumnConvertible adoption +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseValueConvertible adoption +

+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a DatabaseDateComponents if dbValue contains a +valid date.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseDateComponents?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Codable adoption +

+
+
+
    +
  • +
    + + + + init(from:) + +
    +
    +
    +
    +
    +
    +

    Creates a new instance by decoding from the given decoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(from decoder: Decoder) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + decoder + + +
    +

    The decoder to read data from.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + encode(to:) + +
    +
    +
    +
    +
    +
    +

    Encodes this value into the given encoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func encode(to encoder: Encoder) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + encoder + + +
    +

    The encoder to write data to.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseDateComponents/Format.html b/docs/5.16/Structs/DatabaseDateComponents/Format.html new file mode 100644 index 000000000..dd4474d41 --- /dev/null +++ b/docs/5.16/Structs/DatabaseDateComponents/Format.html @@ -0,0 +1,1332 @@ + + + + Format Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Format

+
+
+ +
public enum Format : String
+ +
+
+

The available formats for reading and storing date components.

+ + +
+
+
+
    +
  • +
    + + + + YMD + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD = "yyyy-MM-dd"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + YMD_HM + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd HH:mm”.

    + +

    This format is lexically comparable with SQLite’s CURRENT_TIMESTAMP.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD_HM = "yyyy-MM-dd HH:mm"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + YMD_HMS + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd HH:mm:ss”.

    + +

    This format is lexically comparable with SQLite’s CURRENT_TIMESTAMP.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD_HMS = "yyyy-MM-dd HH:mm:ss"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + YMD_HMSS + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd HH:mm:ss.SSS”.

    + +

    This format is lexically comparable with SQLite’s CURRENT_TIMESTAMP.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD_HMSS = "yyyy-MM-dd HH:mm:ss.SSS"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HM + +
    +
    +
    +
    +
    +
    +

    The format “HH:mm”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case HM = "HH:mm"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HMS + +
    +
    +
    +
    +
    +
    +

    The format “HH:mm:ss”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case HMS = "HH:mm:ss"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HMSS + +
    +
    +
    +
    +
    +
    +

    The format “HH:mm:ss.SSS”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case HMSS = "HH:mm:ss.SSS"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseError.html b/docs/5.16/Structs/DatabaseError.html new file mode 100644 index 000000000..f0af28bed --- /dev/null +++ b/docs/5.16/Structs/DatabaseError.html @@ -0,0 +1,4298 @@ + + + + DatabaseError Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseError

+
+
+ +
public struct DatabaseError : Error, CustomStringConvertible, CustomNSError
+ +
+
+

DatabaseError wraps an SQLite error.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseEvent.html b/docs/5.16/Structs/DatabaseEvent.html new file mode 100644 index 000000000..19878805f --- /dev/null +++ b/docs/5.16/Structs/DatabaseEvent.html @@ -0,0 +1,1304 @@ + + + + DatabaseEvent Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseEvent

+
+
+ +
public struct DatabaseEvent
+ +
+
+

A database event, notified to TransactionObserver.

+ + +
+
+
+
    +
  • +
    + + + + Kind + +
    +
    +
    +
    +
    +
    +

    An event kind

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum Kind : Int32
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + kind + +
    +
    +
    +
    +
    +
    +

    The event kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let kind: Kind
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseName + +
    +
    +
    +
    +
    +
    +

    The database name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rowID + +
    +
    +
    +
    +
    +
    +

    The rowID of the changed row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let rowID: Int64
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns an event that can be stored:

    +
    class MyObserver: TransactionObserver {
    +    var events: [DatabaseEvent]
    +    func databaseDidChange(with event: DatabaseEvent) {
    +        events.append(event.copy())
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func copy() -> DatabaseEvent
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseEvent/Kind.html b/docs/5.16/Structs/DatabaseEvent/Kind.html new file mode 100644 index 000000000..139b195a7 --- /dev/null +++ b/docs/5.16/Structs/DatabaseEvent/Kind.html @@ -0,0 +1,1206 @@ + + + + Kind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Kind

+
+
+ +
public enum Kind : Int32
+ +
+
+

An event kind

+ + +
+
+
+
    +
  • +
    + + + + insert + +
    +
    +
    +
    +
    +
    +

    SQLITE_INSERT

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case insert = 18
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete + +
    +
    +
    +
    +
    +
    +

    SQLITE_DELETE

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case delete = 9
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + update + +
    +
    +
    +
    +
    +
    +

    SQLITE_UPDATE

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case update = 23
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseMigrator.html b/docs/5.16/Structs/DatabaseMigrator.html new file mode 100644 index 000000000..bc3f98a74 --- /dev/null +++ b/docs/5.16/Structs/DatabaseMigrator.html @@ -0,0 +1,2122 @@ + + + + DatabaseMigrator Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseMigrator

+
+
+ +
public struct DatabaseMigrator
+ +
+
+

A DatabaseMigrator registers and applies database migrations.

+ +

Migrations are named blocks of SQL statements that are guaranteed to be +applied in order, once and only once.

+ +

When a user upgrades your application, only non-applied migration are run.

+ +

Usage:

+
var migrator = DatabaseMigrator()
+
+// 1st migration
+migrator.registerMigration("createLibrary") { db in
+    try db.create(table: "author") { t in
+        t.autoIncrementedPrimaryKey("id")
+        t.column("creationDate", .datetime)
+        t.column("name", .text).notNull()
+    }
+
+    try db.create(table: "book") { t in
+        t.autoIncrementedPrimaryKey("id")
+        t.column("authorId", .integer)
+            .notNull()
+            .references("author", onDelete: .cascade)
+        t.column("title", .text).notNull()
+    }
+}
+
+// 2nd migration
+migrator.registerMigration("AddBirthYearToAuthors") { db in
+    try db.alter(table: "author") { t
+        t.add(column: "birthYear", .integer)
+    }
+}
+
+// Migrations for future versions will be inserted here:
+//
+// // 3rd migration
+// migrator.registerMigration("...") { db in
+//     ...
+// }
+
+try migrator.migrate(dbQueue)
+
+ + +
+
+
+
    +
  • +
    + + + + ForeignKeyChecks + +
    +
    +
    +
    +
    +
    +

    Controls how migrations handle foreign keys constraints.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum ForeignKeyChecks
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    When the eraseDatabaseOnSchemaChange flag is true, the migrator will +automatically wipe out the full database content, and recreate the whole +database from scratch, if it detects that a migration has changed its +definition.

    + +

    This flag can destroy your precious users’ data!

    + +

    But it may be useful in two situations:

    + +
      +
    1. During application development, as you are still designing +migrations, and the schema changes often.

      + +

      In this case, it is recommended that you make sure this flag does +not ship in the distributed application, in order to avoid undesired +data loss:

      +
      var migrator = DatabaseMigrator()
      +#if DEBUG
      +// Speed up development by nuking the database when migrations change
      +migrator.eraseDatabaseOnSchemaChange = true
      +#endif
      +
    2. +
    3. When the database content can easily be recreated, such as a cache +for some downloaded data.

    4. +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var eraseDatabaseOnSchemaChange: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    A new migrator.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Disabling Foreign Key Checks +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a migrator that will not perform deferred foreign key checks in +all newly registered migrations.

    + +

    The returned migrator is unsafe, because it no longer guarantees the +integrity of the database. It is your responsibility to register +migrations that do not break foreign key constraints.

    + +

    Running migrations without foreign key checks can improve migration +performance on huge databases.

    + +

    Example:

    +
    var migrator = DatabaseMigrator()
    +migrator.registerMigration("A") { db in
    +    // Runs with deferred foreign key checks
    +}
    +migrator.registerMigration("B", foreignKeyChecks: .immediate) { db in
    +    // Runs with immediate foreign key checks
    +}
    +
    +migrator = migrator.disablingDeferredForeignKeyChecks()
    +migrator.registerMigration("C") { db in
    +    // Runs with disabled foreign key checks
    +}
    +migrator.registerMigration("D", foreignKeyChecks: .immediate) { db in
    +    // Runs with immediate foreign key checks
    +}
    +
    +
    +

    Warning

    + Before using this unsafe method, try to run your migrations with +.immediate foreign key checks, if possible. This may enhance migration +performances, while preserving the database integrity guarantee. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func disablingDeferredForeignKeyChecks() -> DatabaseMigrator
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Registering Migrations +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Registers a migration.

    +
    migrator.registerMigration("createAuthors") { db in
    +    try db.create(table: "author") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("creationDate", .datetime)
    +        t.column("name", .text).notNull()
    +    }
    +}
    +
    +
    +

    Precondition

    +

    No migration with the same same as already been registered.

    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func registerMigration(
    +    _ identifier: String,
    +    foreignKeyChecks: ForeignKeyChecks = .deferred,
    +    migrate: @escaping (Database) throws -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + identifier + + +
    +

    The migration identifier.

    +
    +
    + + foreignKeyChecks + + +
    +

    This parameter is ignored if the database has +not enabled foreign keys.

    +
    +
    + + block + + +
    +

    The migration block that performs SQL statements.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Applying Migrations +

+
+
+
    +
  • +
    + + + + migrate(_:) + +
    +
    +
    +
    +
    +
    +

    Iterate migrations in the same order as they were registered. If a +migration has not yet been applied, its block is executed in +a transaction.

    +
    +

    Throws

    + An eventual error thrown by the registered migration blocks. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func migrate(_ writer: DatabaseWriter) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + migrate(_:upTo:) + +
    +
    +
    +
    +
    +
    +

    Iterate migrations in the same order as they were registered, up to the +provided target. If a migration has not yet been applied, its block is +executed in a transaction.

    +
    +

    Throws

    + An eventual error thrown by the registered migration blocks. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func migrate(_ writer: DatabaseWriter, upTo targetIdentifier: String) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    + + targetIdentifier + + +
    +

    The identifier of a registered migration.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Iterate migrations in the same order as they were registered. If a +migration has not yet been applied, its block is executed in +a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncMigrate(
    +    _ writer: DatabaseWriter,
    +    completion: @escaping (Database, Error?) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    + + completion + + +
    +

    A closure that is called in a protected dispatch +queue that can write in the database, with the eventual +migration error.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Querying Migrations +

+
+
+
    +
  • +
    + + + + migrations + +
    +
    +
    +
    +
    +
    +

    The list of registered migration identifiers, in the same order as they +have been registered.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var migrations: [String] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + appliedMigrations(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the identifiers of registered and applied migrations, in the +order of registration.

    + +

    See also appliedIdentifiers(_:).

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func appliedMigrations(_ db: Database) throws -> [String]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the applied migration identifiers, even unregistered ones.

    + +

    See also appliedMigrations(_:).

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func appliedIdentifiers(_ db: Database) throws -> Set<String>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the identifiers of completed migrations, of which all previous +migrations have been applied.

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func completedMigrations(_ db: Database) throws -> [String]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns true if all migrations are applied.

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasCompletedMigrations(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasBeenSuperseded(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether database contains unknown migration +identifiers, which is likely the sign that the database +has migrated further than the migrator itself supports.

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasBeenSuperseded(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Migrations +

+
+
+
    +
  • +
    + + + + migratePublisher(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously migrates a database.

    +
    let migrator: DatabaseMigrator = ...
    +let dbQueue: DatabaseQueue = ...
    +let publisher = migrator.migratePublisher(dbQueue)
    +
    + +

    It completes on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func migratePublisher(_ writer: DatabaseWriter) -> DatabasePublishers.Migrate
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously migrates a database.

    +
    let migrator: DatabaseMigrator = ...
    +let dbQueue: DatabaseQueue = ...
    +let publisher = migrator.migratePublisher(dbQueue, receiveOn: DispatchQueue.global())
    +
    + +

    It completes on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func migratePublisher<S>(_ writer: DatabaseWriter, receiveOn scheduler: S)
    +-> DatabasePublishers.Migrate
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseMigrator/ForeignKeyChecks.html b/docs/5.16/Structs/DatabaseMigrator/ForeignKeyChecks.html new file mode 100644 index 000000000..28942a369 --- /dev/null +++ b/docs/5.16/Structs/DatabaseMigrator/ForeignKeyChecks.html @@ -0,0 +1,1188 @@ + + + + ForeignKeyChecks Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyChecks

+
+
+ +
public enum ForeignKeyChecks
+ +
+
+

Controls how migrations handle foreign keys constraints.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabasePreUpdateEvent.html b/docs/5.16/Structs/DatabasePreUpdateEvent.html new file mode 100644 index 000000000..d069de89f --- /dev/null +++ b/docs/5.16/Structs/DatabasePreUpdateEvent.html @@ -0,0 +1,1382 @@ + + + + DatabasePreUpdateEvent Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabasePreUpdateEvent

+ +
+
+
+
    +
  • +
    + + + + Kind + +
    +
    +
    +
    +
    +
    +

    An event kind

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + kind + +
    +
    +
    +
    +
    +
    +

    The event kind

    + +
    +
    +
    +
  • +
  • +
    + + + + databaseName + +
    +
    +
    +
    +
    +
    +

    The database name

    + +
    +
    +
    +
  • +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name

    + +
    +
    +
    +
  • +
  • +
    + + + + count + +
    +
    +
    +
    +
    +
    +

    The number of columns in the row that is being inserted, updated, or deleted.

    + +
    +
    +
    +
  • +
  • +
    + + + + depth + +
    +
    +
    +
    +
    +
    +

    1 for inserts, updates, or deletes invoked by top-level triggers; +2 for changes resulting from triggers called by top-level triggers; +… and so forth

    + +
    +
    +
    +
  • +
  • +
    + + + + initialRowID + +
    +
    +
    +
    +
    +
    +

    The initial rowID of the row being changed for .Update and .Delete changes, +and nil for .Insert changes.

    + +
    +
    +
    +
  • +
  • +
    + + + + finalRowID + +
    +
    +
    +
    +
    +
    +

    The final rowID of the row being changed for .Update and .Insert changes, +and nil for .Delete changes.

    + +
    +
    +
    +
  • +
  • +
    + + + + initialDatabaseValues + +
    +
    +
    +
    +
    +
    +

    The initial database values in the row.

    + +

    Values appear in the same order as the columns in the table.

    + +

    The result is nil if the event is an .Insert event.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the initial DatabaseValue at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    The result is nil if the event is an .Insert event.

    + +
    +
    +
    +
  • +
  • +
    + + + + finalDatabaseValues + +
    +
    +
    +
    +
    +
    +

    The final database values in the row.

    + +

    Values appear in the same order as the columns in the table.

    + +

    The result is nil if the event is a .Delete event.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the final DatabaseValue at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    The result is nil if the event is a .Delete event.

    + +
    +
    +
    +
  • +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns an event that can be stored:

    +
    class MyObserver: TransactionObserver {
    +    var events: [DatabasePreUpdateEvent]
    +    func databaseWillChange(with event: DatabasePreUpdateEvent) {
    +        events.append(event.copy())
    +    }
    +}
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabasePreUpdateEvent/Kind.html b/docs/5.16/Structs/DatabasePreUpdateEvent/Kind.html new file mode 100644 index 000000000..dca3743d7 --- /dev/null +++ b/docs/5.16/Structs/DatabasePreUpdateEvent/Kind.html @@ -0,0 +1,1163 @@ + + + + Kind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Kind

+

An event kind

+ +
+
+
+
    +
  • +
    + + + + insert + +
    +
    +
    +
    +
    +
    +

    SQLITE_INSERT

    + +
    +
    +
    +
  • +
  • +
    + + + + delete + +
    +
    +
    +
    +
    +
    +

    SQLITE_DELETE

    + +
    +
    +
    +
  • +
  • +
    + + + + update + +
    +
    +
    +
    +
    +
    +

    SQLITE_UPDATE

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseRegion.html b/docs/5.16/Structs/DatabaseRegion.html new file mode 100644 index 000000000..58ec31b9e --- /dev/null +++ b/docs/5.16/Structs/DatabaseRegion.html @@ -0,0 +1,1457 @@ + + + + DatabaseRegion Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegion

+
+
+ +
public struct DatabaseRegion : CustomStringConvertible, Equatable
+
extension DatabaseRegion: DatabaseRegionConvertible
+ +
+
+

DatabaseRegion defines a region in the database. DatabaseRegion is dedicated +to help transaction observers recognize impactful database changes in their +observes(eventsOfKind:) and databaseDidChange(with:) methods.

+ +

A database region is the union of any number of “table regions”, which can +cover a full table, or the combination of columns and rows:

+
|Table1 |   |Table2 |   |Table3 |   |Table4 |   |Table5 |
+|-------|   |-------|   |-------|   |-------|   |-------|
+|x|x|x|x|   |x| | | |   |x|x|x|x|   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | |x| | |
+|x|x|x|x|   |x| | | |   | | | | |   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | | | | |
+
+ +

To create a database region, you use one of those methods:

+ +
    +
  • DatabaseRegion.fullDatabase: the region that covers all database tables.

  • +
  • DatabaseRegion(): the empty region.

  • +
  • DatabaseRegion(table:): the region that covers one database table.

  • +
  • Statement.databaseRegion:

    +
    let statement = try db.makeStatement(sql: "SELECT name, score FROM player")
    +let region = statement.databaseRegion
    +
  • +
  • FetchRequest.databaseRegion(_:)

    +
    let request = Player.filter(key: 1)
    +let region = try request.databaseRegion(db)
    +
  • +
+ + +
+
+
+
    +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    Returns whether the region is empty.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isFullDatabase + +
    +
    +
    +
    +
    +
    +

    Returns whether the region covers the full database: all columns and all +rows from all tables.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isFullDatabase: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fullDatabase + +
    +
    +
    +
    +
    +
    +

    The region that covers the full database: all columns and all rows +from all tables.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let fullDatabase: DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an empty database region.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(table:) + +
    +
    +
    +
    +
    +
    +

    Creates a region that spans all rows and columns of a database table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(table: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + table + + +
    +

    A table name.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + union(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the union of this region and the given one.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func union(_ other: DatabaseRegion) -> DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + formUnion(_:) + +
    +
    +
    +
    +
    +
    +

    Inserts the given region into this region

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func formUnion(_ other: DatabaseRegion)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Events +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns whether the content in the region would be impacted if the +database were modified by an event of this kind.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isModified(byEventsOfKind eventKind: DatabaseEventKind) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isModified(by:) + +
    +
    +
    +
    +
    +
    +

    Returns whether the content in the region is impacted by this event.

    +
    +

    Precondition

    + event has been filtered by the same region +in the TransactionObserver.observes(eventsOfKind:) method, by calling +region.isModified(byEventsOfKind:) + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isModified(by event: DatabaseEvent) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseRegionObservation.html b/docs/5.16/Structs/DatabaseRegionObservation.html new file mode 100644 index 000000000..4dcc5d249 --- /dev/null +++ b/docs/5.16/Structs/DatabaseRegionObservation.html @@ -0,0 +1,1407 @@ + + + + DatabaseRegionObservation Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegionObservation

+
+
+ +
public struct DatabaseRegionObservation
+ +
+
+

DatabaseRegionObservation tracks changes in the results of database +requests, and notifies each database transaction whenever the +database changes.

+ +

For example:

+
let observation = DatabaseRegionObservation(tracking: Player.all)
+let observer = try observation.start(in: dbQueue) { db: Database in
+    print("Players have changed.")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + extent + +
    +
    +
    +
    +
    +
    +

    The extent of the database observation. The default is +.observerLifetime: the observation lasts until the +observer returned by the start(in:onChange:) method +is deallocated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var extent: Database.TransactionObservationExtent
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(tracking:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseRegionObservation which observes regions, and +notifies whenever one of the observed regions is modified by a +database transaction.

    + +

    For example, this sample code counts the number of a times the player +table is modified:

    +
    let observation = DatabaseRegionObservation(tracking: Player.all())
    +
    +var count = 0
    +let observer = observation.start(in: dbQueue) { _ in
    +    count += 1
    +    print("Players have been modified \(count) times.")
    +}
    +
    + +

    The observation lasts until the observer returned by start is +deallocated. See the extent property for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(tracking regions: DatabaseRegionConvertible...)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + regions + + +
    +

    A list of observed regions.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(tracking:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseRegionObservation which observes regions, and +notifies whenever one of the observed regions is modified by a +database transaction.

    + +

    For example, this sample code counts the number of a times the player +table is modified:

    +
    let observation = DatabaseRegionObservation(tracking: [Player.all()])
    +
    +var count = 0
    +let observer = observation.start(in: dbQueue) { _ in
    +    count += 1
    +    print("Players have been modified \(count) times.")
    +}
    +
    + +

    The observation lasts until the observer returned by start is +deallocated. See the extent property for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(tracking regions: [DatabaseRegionConvertible])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + regions + + +
    +

    A list of observed regions.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + start(in:onChange:) + +
    +
    +
    +
    +
    +
    +

    Starts the observation in the provided database writer (such as +a database queue or database pool), and returns a transaction observer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func start(
    +    in dbWriter: DatabaseWriter,
    +    onChange: @escaping (Database) -> Void)
    +throws -> TransactionObserver
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseWriter.

    +
    +
    + + onChange + + +
    +

    A closure that is provided a database connection +with write access each time the observed region has been modified.

    +
    +
    +
    +
    +

    Return Value

    +

    a TransactionObserver

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Impactful Transactions +

+
+
+
    +
  • +
    + + + + publisher(in:) + +
    +
    +
    +
    +
    +
    +

    Returns a publisher that tracks changes in a database region.

    + +

    It emits database connections on a protected dispatch queue.

    + +

    Error completion, if any, is only emitted, synchronously, +on subscription.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func publisher(in writer: DatabaseWriter) -> DatabasePublishers.DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseValue.html b/docs/5.16/Structs/DatabaseValue.html new file mode 100644 index 000000000..6a55b53a1 --- /dev/null +++ b/docs/5.16/Structs/DatabaseValue.html @@ -0,0 +1,1474 @@ + + + + DatabaseValue Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseValue

+
+
+ +
public struct DatabaseValue : Hashable, CustomStringConvertible, DatabaseValueConvertible, SQLSpecificExpressible
+
extension DatabaseValue: StatementBinding
+ +
+
+

DatabaseValue is the intermediate type between SQLite and your values.

+ +

See https://www.sqlite.org/datatype3.html

+ + +
+
+
+
    +
  • +
    + + + + storage + +
    +
    +
    +
    +
    +
    +

    The SQLite storage

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let storage: Storage
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + null + +
    +
    +
    +
    +
    +
    +

    The NULL DatabaseValue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let null: DatabaseValue
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Storage + +
    +
    +
    +
    +
    +
    +

    An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @frozen
    +public enum Storage : Equatable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(value:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseValue from Any.

    + +

    The result is nil unless object adopts DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(value: Any)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting Value +

+
+
+
    +
  • +
    + + + + isNull + +
    +
    +
    +
    +
    +
    +

    Returns true if databaseValue is NULL.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isNull: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseValue +

+
+
+ +
+
+
+ + +
+ +

Hashable & Equatable +

+
+
+
    +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether two DatabaseValues are equal.

    +
    1.databaseValue == "foo".databaseValue // false
    +1.databaseValue == 1.databaseValue     // true
    +
    + +

    When comparing integers and doubles, the result is true if and only +values are equal, and if converting one type to the other does +not lose information:

    +
    1.databaseValue == 1.0.databaseValue   // true
    +
    + +

    For a comparison that distinguishes integer and doubles, compare +storages instead:

    +
    1.databaseValue.storage == 1.0.databaseValue.storage // false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func == (lhs: DatabaseValue, rhs: DatabaseValue) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns self

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the database value

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseValue?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlExpression + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/DatabaseValue/Storage.html b/docs/5.16/Structs/DatabaseValue/Storage.html new file mode 100644 index 000000000..25889fa08 --- /dev/null +++ b/docs/5.16/Structs/DatabaseValue/Storage.html @@ -0,0 +1,1331 @@ + + + + Storage Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Storage

+
+
+ +
@frozen
+public enum Storage : Equatable
+ +
+
+

An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).

+ + +
+
+
+
    +
  • +
    + + + + null + +
    +
    +
    +
    +
    +
    +

    The NULL storage class.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case null
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + int64(_:) + +
    +
    +
    +
    +
    +
    +

    The INTEGER storage class, wrapping an Int64.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case int64(Int64)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + double(_:) + +
    +
    +
    +
    +
    +
    +

    The REAL storage class, wrapping a Double.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case double(Double)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + string(_:) + +
    +
    +
    +
    +
    +
    +

    The TEXT storage class, wrapping a String.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case string(String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + blob(_:) + +
    +
    +
    +
    +
    +
    +

    The BLOB storage class, wrapping Data.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case blob(Data)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + value + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, Data or nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var value: DatabaseValueConvertible? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Return true if the storages are identical.

    + +

    Unlike DatabaseValue equality that considers the integer 1 to be +equal to the 1.0 double (as SQLite does), int64 and double storages +are never equal.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func == (lhs: Storage, rhs: Storage) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/EmptyRowAdapter.html b/docs/5.16/Structs/EmptyRowAdapter.html new file mode 100644 index 000000000..5e23ea184 --- /dev/null +++ b/docs/5.16/Structs/EmptyRowAdapter.html @@ -0,0 +1,1146 @@ + + + + EmptyRowAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

EmptyRowAdapter

+
+
+ +
public struct EmptyRowAdapter : RowAdapter
+ +
+
+

EmptyRowAdapter is a row adapter that hides all columns.

+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an EmptyRowAdapter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS3.html b/docs/5.16/Structs/FTS3.html new file mode 100644 index 000000000..3b1242682 --- /dev/null +++ b/docs/5.16/Structs/FTS3.html @@ -0,0 +1,1409 @@ + + + + FTS3 Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3

+
+
+ +
public struct FTS3 : VirtualTableModule
+ +
+
+

FTS3 lets you define “fts3” virtual tables.

+
// CREATE VIRTUAL TABLE document USING fts3(content)
+try db.create(virtualTable: "document", using: FTS3()) { t in
+    t.column("content")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + Diacritics + +
    +
    +
    +
    +
    +
    +

    Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum Diacritics
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a FTS3 module suitable for the Database +create(virtualTable:using:) method.

    +
    // CREATE VIRTUAL TABLE document USING fts3(content)
    +try db.create(virtualTable: "document", using: FTS3()) { t in
    +    t.column("content")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of tokens found in the string argument.

    + +

    For example:

    +
    FTS3.tokenize("SQLite database")  // ["sqlite", "database"]
    +FTS3.tokenize("Gustave Doré")     // ["gustave", "doré"])
    +
    + +

    Results can be altered with an explicit tokenizer - default is .simple. +See https://www.sqlite.org/fts3.html#tokenizer.

    +
    FTS3.tokenize("SQLite database", withTokenizer: .porter)   // ["sqlite", "databas"]
    +FTS3.tokenize("Gustave Doré", withTokenizer: .unicode61()) // ["gustave", "dore"])
    +
    + +

    Tokenization is performed by the fts3tokenize virtual table described +at https://www.sqlite.org/fts3.html#querying_tokenizers.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tokenize(
    +    _ string: String,
    +    withTokenizer tokenizer: FTS3TokenizerDescriptor = .simple)
    +-> [String]
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

VirtualTableModule Adoption +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS3/Diacritics.html b/docs/5.16/Structs/FTS3/Diacritics.html new file mode 100644 index 000000000..476e62fb7 --- /dev/null +++ b/docs/5.16/Structs/FTS3/Diacritics.html @@ -0,0 +1,1234 @@ + + + + Diacritics Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Diacritics

+
+
+ +
public enum Diacritics
+ +
+
+

Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+
    +
  • +
    + + + + keep + +
    +
    +
    +
    +
    +
    +

    Do not remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=0” tokenizer argument.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case keep
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + removeLegacy + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=1” tokenizer argument.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case removeLegacy
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=2” tokenizer argument, +available from SQLite 3.27.0

    + +
    +
    +
    +
  • +
  • +
    + + + + remove + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=2” tokenizer argument, +available from SQLite 3.27.0

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case remove
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS3Pattern.html b/docs/5.16/Structs/FTS3Pattern.html new file mode 100644 index 000000000..2ea43f50b --- /dev/null +++ b/docs/5.16/Structs/FTS3Pattern.html @@ -0,0 +1,1456 @@ + + + + FTS3Pattern Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3Pattern

+
+
+ +
public struct FTS3Pattern
+
extension FTS3Pattern: DatabaseValueConvertible
+ +
+
+

A full text pattern that can query FTS3 and FTS4 virtual tables.

+ + +
+
+
+
    +
  • +
    + + + + rawPattern + +
    +
    +
    +
    +
    +
    +

    The raw pattern string. Guaranteed to be a valid FTS3/4 pattern.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let rawPattern: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(rawPattern:) + +
    +
    +
    +
    +
    +
    +

    Creates a pattern from a raw pattern string; throws DatabaseError on +invalid syntax.

    + +

    The pattern syntax is documented at https://www.sqlite.org/fts3.html#full_text_index_queries

    +
    try FTS3Pattern(rawPattern: "and") // OK
    +try FTS3Pattern(rawPattern: "AND") // malformed MATCH expression: [AND]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawPattern: String) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches any token found in the input string; +returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAnyTokenIn: "")        // nil
    +FTS3Pattern(matchingAnyTokenIn: "foo bar") // foo OR bar
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingAnyTokenIn string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all tokens found in the input string; +returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAllTokensIn: "")        // nil
    +FTS3Pattern(matchingAllTokensIn: "foo bar") // foo bar
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingAllTokensIn string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all token prefixes found in the input +string; returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAllTokensIn: "")        // nil
    +FTS3Pattern(matchingAllTokensIn: "foo bar") // foo* bar*
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingAllPrefixesIn string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(matchingPhrase:) + +
    +
    +
    +
    +
    +
    +

    Creates a pattern that matches a contiguous string; returns nil if no +pattern could be built.

    +
    FTS3Pattern(matchingPhrase: "")        // nil
    +FTS3Pattern(matchingPhrase: "foo bar") // "foo bar"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingPhrase string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an FTS3Pattern initialized from dbValue, if it contains +a suitable value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> FTS3Pattern?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS3TokenizerDescriptor.html b/docs/5.16/Structs/FTS3TokenizerDescriptor.html new file mode 100644 index 000000000..7e42e7e69 --- /dev/null +++ b/docs/5.16/Structs/FTS3TokenizerDescriptor.html @@ -0,0 +1,1280 @@ + + + + FTS3TokenizerDescriptor Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3TokenizerDescriptor

+
+
+ +
public struct FTS3TokenizerDescriptor
+ +
+
+

An FTS3 tokenizer, suitable for FTS3 and FTS4 table definitions:

+
db.create(virtualTable: "book", using: FTS4()) { t in
+    t.tokenizer = .simple // FTS3TokenizerDescriptor
+}
+
+ +

See https://www.sqlite.org/fts3.html#tokenizer

+ + +
+
+
+
    +
  • +
    + + + + simple + +
    +
    +
    +
    +
    +
    +

    The “simple” tokenizer.

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .simple
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let simple: FTS3TokenizerDescriptor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + porter + +
    +
    +
    +
    +
    +
    +

    The “porter” tokenizer.

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .porter
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let porter: FTS3TokenizerDescriptor
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The “unicode61” tokenizer.

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .unicode61()
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func unicode61(
    +    diacritics: FTS3.Diacritics = .removeLegacy,
    +    separators: Set<Character> = [],
    +    tokenCharacters: Set<Character> = [])
    +-> FTS3TokenizerDescriptor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + diacritics + + +
    +

    By default SQLite will strip diacritics from +latin characters.

    +
    +
    + + separators + + +
    +

    Unless empty (the default), SQLite will consider these +characters as token separators.

    +
    +
    + + tokenCharacters + + +
    +

    Unless empty (the default), SQLite will consider +these characters as token characters.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS4.html b/docs/5.16/Structs/FTS4.html new file mode 100644 index 000000000..0af2b45fe --- /dev/null +++ b/docs/5.16/Structs/FTS4.html @@ -0,0 +1,1332 @@ + + + + FTS4 Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS4

+
+
+ +
public struct FTS4 : VirtualTableModule
+ +
+
+

FTS4 lets you define “fts4” virtual tables.

+
// CREATE VIRTUAL TABLE document USING fts4(content)
+try db.create(virtualTable: "document", using: FTS4()) { t in
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a FTS4 module suitable for the Database +create(virtualTable:using:) method.

    +
    // CREATE VIRTUAL TABLE document USING fts4(content)
    +try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

VirtualTableModule Adoption +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS5.html b/docs/5.16/Structs/FTS5.html new file mode 100644 index 000000000..caf057d57 --- /dev/null +++ b/docs/5.16/Structs/FTS5.html @@ -0,0 +1,1277 @@ + + + + FTS5 Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5

+

FTS5 lets you define “fts5” virtual tables.

+
// CREATE VIRTUAL TABLE document USING fts5(content)
+try db.create(virtualTable: "document", using: FTS5()) { t in
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+
    +
  • +
    + + + + Diacritics + +
    +
    +
    +
    +
    +
    +

    Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a FTS5 module suitable for the Database +create(virtualTable:using:) method.

    +
    // CREATE VIRTUAL TABLE document USING fts5(content)
    +try db.create(virtualTable: "document", using: FTS5()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

VirtualTableModule Adoption +

+
+
+
    +
  • +
    + + + + moduleName + +
    +
    +
    +
    +
    +
    +

    The virtual table module name

    + +
    +
    +
    +
  • +
  • +
    + + + + makeTableDefinition() + +
    +
    +
    +
    +
    +
    +

    Reserved; part of the VirtualTableModule protocol.

    + +

    See Database.create(virtualTable:using:)

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Reserved; part of the VirtualTableModule protocol.

    + +

    See Database.create(virtualTable:using:)

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Don’t use this method.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Reserved; part of the VirtualTableModule protocol.

    + +

    See Database.create(virtualTable:using:)

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS5/Diacritics.html b/docs/5.16/Structs/FTS5/Diacritics.html new file mode 100644 index 000000000..d5e5a5edf --- /dev/null +++ b/docs/5.16/Structs/FTS5/Diacritics.html @@ -0,0 +1,1170 @@ + + + + Diacritics Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Diacritics

+

Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+
    +
  • +
    + + + + keep + +
    +
    +
    +
    +
    +
    +

    Do not remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=0” tokenizer argument.

    + +
    +
    +
    +
  • +
  • +
    + + + + removeLegacy + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=1” tokenizer argument.

    + +
    +
    +
    +
  • +
  • +
    + + + + remove + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=2” tokenizer argument, +available from SQLite 3.27.0

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS5Pattern.html b/docs/5.16/Structs/FTS5Pattern.html new file mode 100644 index 000000000..d94e3b6ae --- /dev/null +++ b/docs/5.16/Structs/FTS5Pattern.html @@ -0,0 +1,1288 @@ + + + + FTS5Pattern Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5Pattern

+
+
+ + +
+
+

A full text pattern that can query FTS5 virtual tables.

+ +
+
+
+
    +
  • +
    + + + + rawPattern + +
    +
    +
    +
    +
    +
    +

    The raw pattern string. Guaranteed to be a valid FTS5 pattern.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches any token found in the input string; +returns nil if no pattern could be built.

    +
    FTS5Pattern(matchingAnyTokenIn: "")        // nil
    +FTS5Pattern(matchingAnyTokenIn: "foo bar") // foo OR bar
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all tokens found in the input string; +returns nil if no pattern could be built.

    +
    FTS5Pattern(matchingAllTokensIn: "")        // nil
    +FTS5Pattern(matchingAllTokensIn: "foo bar") // foo bar
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all token prefixes found in the input +string; returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAllTokensIn: "")        // nil
    +FTS3Pattern(matchingAllTokensIn: "foo bar") // foo* bar*
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + init(matchingPhrase:) + +
    +
    +
    +
    +
    +
    +

    Creates a pattern that matches a contiguous string; returns nil if no +pattern could be built.

    +
    FTS5Pattern(matchingPhrase: "")        // nil
    +FTS5Pattern(matchingPhrase: "foo bar") // "foo bar"
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches the prefix of an indexed document; +returns nil if no pattern could be built.

    +
    FTS5Pattern(matchingPrefixPhrase: "")         // nil
    +FTS5Pattern(matchingPrefixPhrase: "the word") // ^"the word"
    +
    + +

    This pattern matches a prefix made of full tokens: “the bat” matches +“the bat is happy”, but not “mind the bat”, or “the batcave is dark”.

    + +
    +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an FTS5Pattern initialized from dbValue, if it +contains a suitable value.

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS5TokenFlags.html b/docs/5.16/Structs/FTS5TokenFlags.html new file mode 100644 index 000000000..e8ee354e6 --- /dev/null +++ b/docs/5.16/Structs/FTS5TokenFlags.html @@ -0,0 +1,1163 @@ + + + + FTS5TokenFlags Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5TokenFlags

+

Flags that tell SQLite how to register a token.

+ +

See the FTS5_TOKEN_* flags in https://www.sqlite.org/fts5.html#custom_tokenizers.

+ +
+
+
+
    +
  • +
    + + + + rawValue + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + colocated + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKEN_COLOCATED

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS5Tokenization.html b/docs/5.16/Structs/FTS5Tokenization.html new file mode 100644 index 000000000..f488ca176 --- /dev/null +++ b/docs/5.16/Structs/FTS5Tokenization.html @@ -0,0 +1,1220 @@ + + + + FTS5Tokenization Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5Tokenization

+

The reason why FTS5 is requesting tokenization.

+ +

See https://www.sqlite.org/fts5.html#custom_tokenizers

+ +
+
+
+
    +
  • +
    + + + + rawValue + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + query + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_QUERY

    + +
    +
    +
    +
  • +
  • +
    + + + + prefix + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_PREFIX

    + +
    +
    +
    +
  • +
  • +
    + + + + document + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_DOCUMENT

    + +
    +
    +
    +
  • +
  • +
    + + + + aux + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_AUX

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/FTS5TokenizerDescriptor.html b/docs/5.16/Structs/FTS5TokenizerDescriptor.html new file mode 100644 index 000000000..265bf499f --- /dev/null +++ b/docs/5.16/Structs/FTS5TokenizerDescriptor.html @@ -0,0 +1,1235 @@ + + + + FTS5TokenizerDescriptor Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5TokenizerDescriptor

+

An FTS5 tokenizer, suitable for FTS5 table definitions:

+
db.create(virtualTable: "book", using: FTS5()) { t in
+    t.tokenizer = .unicode61() // FTS5TokenizerDescriptor
+}
+
+ +

See https://www.sqlite.org/fts5.html#tokenizers

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ForeignKey.html b/docs/5.16/Structs/ForeignKey.html new file mode 100644 index 000000000..2ab4f2f68 --- /dev/null +++ b/docs/5.16/Structs/ForeignKey.html @@ -0,0 +1,1324 @@ + + + + ForeignKey Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKey

+
+
+ +
public struct ForeignKey : Equatable
+ +
+
+

A ForeignKey helps building associations when GRDB can’t infer a foreign +key from the database schema.

+ +

Sometimes the database schema does not define any foreign key between two +tables. And sometimes, there are several foreign keys from a table +to another:

+
| Table book   |       | Table person |
+| ------------ |       | ------------ |
+| id           |   +-->• id           |
+| authorId     •---+   | name         |
+| translatorId •---+
+| title        |
+
+ +

When this happens, associations can’t be automatically inferred from the +database schema. GRDB will complain with a fatal error such as “Ambiguous +foreign key from book to person”, or “Could not infer foreign key from book +to person”.

+ +

Your help is needed. You have to instruct GRDB which foreign key to use:

+
struct Book: TableRecord {
+    // Define foreign keys
+    static let authorForeignKey = ForeignKey(["authorId"]))
+    static let translatorForeignKey = ForeignKey(["translatorId"]))
+
+    // Use foreign keys to define associations:
+    static let author = belongsTo(Person.self, using: authorForeignKey)
+    static let translator = belongsTo(Person.self, using: translatorForeignKey)
+}
+
+ +

Foreign keys are always defined from the table that contains the columns at +the origin of the foreign key. Person’s symmetric HasMany associations reuse +Book’s foreign keys:

+
struct Person: TableRecord {
+    static let writtenBooks = hasMany(Book.self, using: Book.authorForeignKey)
+    static let translatedBooks = hasMany(Book.self, using: Book.translatorForeignKey)
+}
+
+ +

Foreign keys can also be defined from query interface columns:

+
struct Book: TableRecord {
+    enum Columns: String, ColumnExpression {
+        case id, title, authorId, translatorId
+    }
+
+    static let authorForeignKey = ForeignKey([Columns.authorId]))
+    static let translatorForeignKey = ForeignKey([Columns.translatorId]))
+}
+
+ +

When the destination table of a foreign key does not define any primary key, +you need to provide the full definition of a foreign key:

+
struct Book: TableRecord {
+    static let authorForeignKey = ForeignKey(["authorId"], to: ["id"]))
+    static let author = belongsTo(Person.self, using: authorForeignKey)
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:to:) + +
    +
    +
    +
    +
    +
    +

    Creates a ForeignKey intended to define a record association.

    +
    struct Book: TableRecord {
    +    // Define foreign keys
    +    static let authorForeignKey = ForeignKey(["authorId"]))
    +    static let translatorForeignKey = ForeignKey(["translatorId"]))
    +
    +    // Use foreign keys to define associations:
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +    static let translator = belongsTo(Person.self, using: translatorForeignKey)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ originColumns: [String], to destinationColumns: [String]? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + originColumns + + +
    +

    The columns at the origin of the foreign key.

    +
    +
    + + destinationColumns + + +
    +

    The columns at the destination of the +foreign key. When nil (the default), GRDB automatically uses the +primary key.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:to:) + +
    +
    +
    +
    +
    +
    +

    Creates a ForeignKey intended to define a record association.

    +
    struct Book: TableRecord {
    +    // Define columns
    +    enum Columns: String, ColumnExpression {
    +        case id, title, authorId, translatorId
    +    }
    +
    +    // Define foreign keys
    +    static let authorForeignKey = ForeignKey([Columns.authorId]))
    +    static let translatorForeignKey = ForeignKey([Columns.translatorId]))
    +
    +    // Use foreign keys to define associations:
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +    static let translator = belongsTo(Person.self, using: translatorForeignKey)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ originColumns: [ColumnExpression], to destinationColumns: [ColumnExpression]? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + originColumns + + +
    +

    The columns at the origin of the foreign key.

    +
    +
    + + destinationColumns + + +
    +

    The columns at the destination of the +foreign key. When nil (the default), GRDB automatically uses the +primary key.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ForeignKeyInfo.html b/docs/5.16/Structs/ForeignKeyInfo.html new file mode 100644 index 000000000..08fbe9d4e --- /dev/null +++ b/docs/5.16/Structs/ForeignKeyInfo.html @@ -0,0 +1,1267 @@ + + + + ForeignKeyInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyInfo

+
+
+ +
public struct ForeignKeyInfo
+ +
+
+

You get foreign keys from table names, with the +foreignKeys(on:) method.

+ + +
+
+
+
    +
  • +
    + + + + id + +
    +
    +
    +
    +
    +
    +

    The first column in the output of the foreign_key_list pragma

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var id: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + destinationTable + +
    +
    +
    +
    +
    +
    +

    The name of the destination table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let destinationTable: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + mapping + +
    +
    +
    +
    +
    +
    +

    The column to column mapping

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let mapping: [(origin: String, destination: String)]
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + originColumns + +
    +
    +
    +
    +
    +
    +

    The origin columns

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var originColumns: [String] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + destinationColumns + +
    +
    +
    +
    +
    +
    +

    The destination columns

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var destinationColumns: [String] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ForeignKeyViolation.html b/docs/5.16/Structs/ForeignKeyViolation.html new file mode 100644 index 000000000..8724c3cad --- /dev/null +++ b/docs/5.16/Structs/ForeignKeyViolation.html @@ -0,0 +1,1362 @@ + + + + ForeignKeyViolation Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyViolation

+
+
+ +
public struct ForeignKeyViolation : FetchableRecord, CustomStringConvertible
+ +
+
+

A foreign key violation produced by PRAGMA foreign_key_check

+ +

See https://www.sqlite.org/pragma.html#pragma_foreign_key_check

+ + +
+
+
+
    +
  • +
    + + + + originTable + +
    +
    +
    +
    +
    +
    +

    The name of the table that contains the REFERENCES clause

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var originTable: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + originRowID + +
    +
    +
    +
    +
    +
    +

    The rowid of the row that contains the invalid REFERENCES clause, or +nil if the origin table is a WITHOUT ROWID table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var originRowID: Int64?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + destinationTable + +
    +
    +
    +
    +
    +
    +

    The name of the table that is referred to.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var destinationTable: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + foreignKeyId + +
    +
    +
    +
    +
    +
    +

    The id of the specific foreign key constraint that failed. This id +matches ForeignKeyInfo.id. See Database.foreignKeys(on:) for more +information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var foreignKeyId: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(row:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(row: Row)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + description + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var description: String { get }
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a precise description of the foreign key violation.

    + +

    For example: ‘FOREIGN KEY constraint violation - from player(teamId) to team(id), +in [id:1 teamId:2 name:“O'Brien” score: 1000]’

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func failureDescription(_ db: Database) throws -> String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseError(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseError(_ db: Database) -> DatabaseError
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/IndexInfo.html b/docs/5.16/Structs/IndexInfo.html new file mode 100644 index 000000000..88ed50992 --- /dev/null +++ b/docs/5.16/Structs/IndexInfo.html @@ -0,0 +1,1208 @@ + + + + IndexInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

IndexInfo

+
+
+ +
public struct IndexInfo
+ +
+
+

An index on a database table.

+ +

See Database.indexes(on:)

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the index

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + columns + +
    +
    +
    +
    +
    +
    +

    The indexed columns

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let columns: [String]
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isUnique + +
    +
    +
    +
    +
    +
    +

    True if the index is unique

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let isUnique: Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/Inflections.html b/docs/5.16/Structs/Inflections.html new file mode 100644 index 000000000..ab5c74901 --- /dev/null +++ b/docs/5.16/Structs/Inflections.html @@ -0,0 +1,1540 @@ + + + + Inflections Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Inflections

+
+
+ +
public struct Inflections
+ +
+
+

Experimental

+ +

A type that controls GRDB string inflections.

+ + +
+
+
+
+ + +
+ +

Initialization +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Configuration +

+
+
+
    +
  • +
    + + + + plural(_:options:_:) + +
    +
    +
    +
    +
    +
    +

    Appends a pluralization rule.

    +
    var inflections = Inflections()
    +inflections.plural("$", "s")
    +inflections.pluralize("player") // "players"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func plural(
    +    _ pattern: String,
    +    options: NSRegularExpression.Options = [.caseInsensitive],
    +    _ template: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + pattern + + +
    +

    A regular expression pattern.

    +
    +
    + + options + + +
    +

    Regular expression options (defaults to +[.caseInsensitive]).

    +
    +
    + + template + + +
    +

    A replacement template string.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Appends a singularization rule.

    +
    var inflections = Inflections()
    +inflections.singular("s$", "")
    +inflections.singularize("players") // "player"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func singular(
    +    _ pattern: String,
    +    options: NSRegularExpression.Options = [.caseInsensitive],
    +    _ template: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + pattern + + +
    +

    A regular expression pattern.

    +
    +
    + + options + + +
    +

    Regular expression options (defaults to +[.caseInsensitive]).

    +
    +
    + + template + + +
    +

    A replacement template string.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + uncountableWords(_:) + +
    +
    +
    +
    +
    +
    +

    Appends uncountable words.

    +
    var inflections = Inflections()
    +inflections.plural("$", "s")
    +inflections.uncountableWords(["foo"])
    +inflections.pluralize("foo") // "foo"
    +inflections.pluralize("bar") // "bars"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func uncountableWords(_ words: [String])
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + irregularSuffix(_:_:) + +
    +
    +
    +
    +
    +
    +

    Appends an irregular singular/plural pair.

    +
    var inflections = Inflections()
    +inflections.plural("$", "s")
    +inflections.irregularSuffix("man", "men")
    +inflections.pluralize("man")      // "men"
    +inflections.singularizes("women") // "woman"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func irregularSuffix(_ singular: String, _ plural: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + singular + + +
    +

    The singular form.

    +
    +
    + + plural + + +
    +

    The plural form.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Inflections +

+
+
+
    +
  • +
    + + + + pluralize(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a pluralized string.

    +
    Inflections.default.pluralize("player") // "players"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func pluralize(_ string: String) -> String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + singularize(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a singularized string.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func singularize(_ string: String) -> String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + default + +
    +
    +
    +
    +
    +
    +

    The default inflections

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var `default`: Inflections
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/PersistenceConflictPolicy.html b/docs/5.16/Structs/PersistenceConflictPolicy.html new file mode 100644 index 000000000..e19a5765f --- /dev/null +++ b/docs/5.16/Structs/PersistenceConflictPolicy.html @@ -0,0 +1,1211 @@ + + + + PersistenceConflictPolicy Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistenceConflictPolicy

+
+
+ +
public struct PersistenceConflictPolicy
+ +
+
+

The MutablePersistableRecord protocol uses this type in order to handle +SQLite conflicts when records are inserted or updated.

+ +

See MutablePersistableRecord.persistenceConflictPolicy.

+ +

See https://www.sqlite.org/lang_conflict.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/PersistenceContainer.html b/docs/5.16/Structs/PersistenceContainer.html new file mode 100644 index 000000000..fe67e7dd4 --- /dev/null +++ b/docs/5.16/Structs/PersistenceContainer.html @@ -0,0 +1,1195 @@ + + + + PersistenceContainer Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistenceContainer

+
+
+ +
public struct PersistenceContainer
+ +
+
+

Use persistence containers in the encode(to:) method of your +encodable records:

+
struct Player: EncodableRecord {
+    var id: Int64?
+    var name: String?
+
+    func encode(to container: inout PersistenceContainer) {
+        container["id"] = id
+        container["name"] = name
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Accesses the value associated with the given column.

    + +

    It is undefined behavior to set different values for the same column. +Column names are case insensitive, so defining both “name” and “NAME” +is considered undefined behavior.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(column: String) -> DatabaseValueConvertible? { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Accesses the value associated with the given column.

    + +

    It is undefined behavior to set different values for the same column. +Column names are case insensitive, so defining both “name” and “NAME” +is considered undefined behavior.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Column>(column: Column) -> DatabaseValueConvertible? where Column : ColumnExpression { get set }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/PreparedRequest.html b/docs/5.16/Structs/PreparedRequest.html new file mode 100644 index 000000000..2fde21956 --- /dev/null +++ b/docs/5.16/Structs/PreparedRequest.html @@ -0,0 +1,1176 @@ + + + + PreparedRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PreparedRequest

+
+
+ +
public struct PreparedRequest
+ +
+
+

A PreparedRequest is a request that is ready to be executed.

+ + +
+
+
+
    +
  • +
    + + + + statement + +
    +
    +
    +
    +
    +
    +

    A prepared statement

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var statement: Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + adapter + +
    +
    +
    +
    +
    +
    +

    An eventual adapter for rows fetched by the select statement

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var adapter: RowAdapter?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/PrimaryKeyInfo.html b/docs/5.16/Structs/PrimaryKeyInfo.html new file mode 100644 index 000000000..e09523ebe --- /dev/null +++ b/docs/5.16/Structs/PrimaryKeyInfo.html @@ -0,0 +1,1244 @@ + + + + PrimaryKeyInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PrimaryKeyInfo

+
+
+ +
public struct PrimaryKeyInfo
+ +
+
+

Primary keys are returned from the Database.primaryKey(_:) method.

+ +

When the table’s primary key is the rowid:

+
// CREATE TABLE item (name TEXT)
+let pk = try db.primaryKey("item")
+pk.columns     // ["rowid"]
+pk.rowIDColumn // nil
+pk.isRowID     // true
+
+// CREATE TABLE citizen (
+//   id INTEGER PRIMARY KEY,
+//   name TEXT
+// )
+let pk = try db.primaryKey("citizen")!
+pk.columns     // ["id"]
+pk.rowIDColumn // "id"
+pk.isRowID     // true
+
+ +

When the table’s primary key is not the rowid:

+
// CREATE TABLE country (
+//   isoCode TEXT NOT NULL PRIMARY KEY
+//   name TEXT
+// )
+let pk = db.primaryKey("country")!
+pk.columns     // ["isoCode"]
+pk.rowIDColumn // nil
+pk.isRowID     // false
+
+// CREATE TABLE citizenship (
+//   citizenID INTEGER NOT NULL REFERENCES citizen(id)
+//   countryIsoCode TEXT NOT NULL REFERENCES country(isoCode)
+//   PRIMARY KEY (citizenID, countryIsoCode)
+// )
+let pk = db.primaryKey("citizenship")!
+pk.columns     // ["citizenID", "countryIsoCode"]
+pk.rowIDColumn // nil
+pk.isRowID     // false
+
+ + +
+
+
+
    +
  • +
    + + + + columns + +
    +
    +
    +
    +
    +
    +

    The columns in the primary key; this array is never empty.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var columns: [String] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rowIDColumn + +
    +
    +
    +
    +
    +
    +

    When not nil, the name of the column that contains the INTEGER PRIMARY KEY.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var rowIDColumn: String? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isRowID + +
    +
    +
    +
    +
    +
    +

    When true, the primary key is the rowid:

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isRowID: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/QueryInterfaceRequest.html b/docs/5.16/Structs/QueryInterfaceRequest.html new file mode 100644 index 000000000..19987b78a --- /dev/null +++ b/docs/5.16/Structs/QueryInterfaceRequest.html @@ -0,0 +1,2336 @@ + + + + QueryInterfaceRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

QueryInterfaceRequest

+
+
+ +
public struct QueryInterfaceRequest<RowDecoder>
+
extension QueryInterfaceRequest: FetchRequest
+
extension QueryInterfaceRequest: SelectionRequest
+
extension QueryInterfaceRequest: FilteredRequest
+
extension QueryInterfaceRequest: OrderedRequest
+
extension QueryInterfaceRequest: AggregatingRequest
+
extension QueryInterfaceRequest: JoinableRequest
+
extension QueryInterfaceRequest: TableRequest
+
extension QueryInterfaceRequest: DerivableRequest
+ +
+
+

QueryInterfaceRequest is a request that generates SQL for you.

+ +

For example:

+
try dbQueue.read { db in
+    let request = Player
+        .filter(Column("score") > 1000)
+        .order(Column("name"))
+    let players = try request.fetchAll(db) // [Player]
+}
+
+ +

See https://github.com/groue/GRDB.swift#the-query-interface

+ + +
+
+
+ +
+
+
+ + +
+ +

Request Derivation +

+
+
+
    +
  • +
    + + + + select(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection promise.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select { db in [Column("id"), Column("email")] }
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select { db in [Column("id")] }
    +    .select { db in [Column("email")] }
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.all().select([max(Column("score"))], as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(_ selection: [SQLSelectable], as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.all().select(max(Column("score")), as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(_ selection: SQLSelectable..., as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which selects sql, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.all().select(sql: "max(score)", as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal, and fetches values of +type type.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +let defaultName = "Anonymous"
    +let request = Player.all().select(
    +    literal: "IFNULL(name, \(defaultName))",
    +    as: String.self)
    +let name: String? = try request.fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    literal sqlLiteral: SQL,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection promise.

    +
    // SELECT id, email, name FROM player
    +var request = Player.all()
    +request = request
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: { db in [Column("name")] })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: @escaping (Database) throws -> [SQLSelectable]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE 1
    +var request = Player.all()
    +request = request.filter { db in true }
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided orderings promise.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order { _ in [Column("name")] }
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order{ _ in [Column("email")] }
    +    .reversed()
    +    .order{ _ in [Column("name")] }
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reversed() + +
    +
    +
    +
    +
    +
    +

    Creates a request that reverses applied orderings.

    +
    // SELECT * FROM player ORDER BY name DESC
    +var request = Player.all().order(Column("name"))
    +request = request.reversed()
    +
    + +

    If no ordering was applied, the returned request is identical.

    +
    // SELECT * FROM player
    +var request = Player.all()
    +request = request.reversed()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reversed() -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unordered() + +
    +
    +
    +
    +
    +
    +

    Creates a request without any ordering.

    +
    // SELECT * FROM player
    +var request = Player.all().order(Column("name"))
    +request = request.unordered()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unordered() -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + group(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request grouped according to expressions promise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: @escaping (Database) throws -> SQLExpressible) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.avgScore < player.score” condition in +the ON clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ... AND team.avgScore < player.score
    +let playerAlias = TableAlias()
    +let request = Player
    +    .all()
    +    .aliased(playerAlias)
    +    .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func aliased(_ alias: TableAlias) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + distinct() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func distinct() -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + limit(_:offset:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches limit rows, starting at offset.

    +
    // SELECT * FROM player LIMIT 10 OFFSET 20
    +var request = Player.all()
    +request = request.limit(10, offset: 20)
    +
    + +

    Any previous limit is replaced.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func limit(_ limit: Int, offset: Int?) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + asRequest(of:) + +
    +
    +
    +
    +
    +
    +

    Creates a request bound to type RowDecoder.

    + +

    The returned request can fetch if the type RowDecoder is fetchable (Row, +value, record).

    +
    // Int?
    +let maxScore = try Player
    +    .select(max(scoreColumn))
    +    .asRequest(of: Int.self)    // <--
    +    .fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asRequest<RowDecoder>(of type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + type + + +
    +

    The fetched type RowDecoder

    +
    +
    +
    +
    +

    Return Value

    +

    A request bound to type RowDecoder.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence +

+
+
+
    +
  • +
    + + + + isEmpty(_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the request matches no row in the database.

    +
    try Player.filter(Column("name") == "Arthur").isEmpty(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isEmpty(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the request matches no row in the database.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Delete +

+
+
+
    +
  • +
    + + + + deleteAll(_:) + +
    +
    +
    +
    +
    +
    +

    Deletes matching rows; returns the number of deleted rows.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Update +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Updates matching rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.all().updateAll(db, [Column("score").set(to: 0)])
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignments: [ColumnAssignment]) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignments + + +
    +

    An array of column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Updates matching rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.all().updateAll(db, Column("score").set(to: 0))
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignment: ColumnAssignment,
    +    _ otherAssignments: ColumnAssignment...)
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignment + + +
    +

    A column assignment.

    +
    +
    + + otherAssignments + + +
    +

    Eventual other column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player WHERE ...
    +let request = try Player.filter(...).selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player WHERE ...
    +let request = try Player.filter(...).selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID.Wrapped>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/RangeRowAdapter.html b/docs/5.16/Structs/RangeRowAdapter.html new file mode 100644 index 000000000..1109ab50a --- /dev/null +++ b/docs/5.16/Structs/RangeRowAdapter.html @@ -0,0 +1,1182 @@ + + + + RangeRowAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RangeRowAdapter

+
+
+ +
public struct RangeRowAdapter : RowAdapter
+ +
+
+

RangeRowAdapter is a row adapter that only exposes a range of columns.

+
let adapter = RangeRowAdapter(1..<3)
+let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz, 4 as qux"
+
+// [bar:2 baz:3]
+try Row.fetchOne(db, sql: sql, adapter: adapter)
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a RangeRowAdapter that only exposes a range of columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ range: CountableRange<Int>)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a RangeRowAdapter that only exposes a range of columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ range: CountableClosedRange<Int>)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/RenameColumnAdapter.html b/docs/5.16/Structs/RenameColumnAdapter.html new file mode 100644 index 000000000..ec49a1990 --- /dev/null +++ b/docs/5.16/Structs/RenameColumnAdapter.html @@ -0,0 +1,1155 @@ + + + + RenameColumnAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RenameColumnAdapter

+
+
+ +
public struct RenameColumnAdapter : RowAdapter
+ +
+
+

RenameColumnAdapter is a row adapter that renames columns.

+ +

For example:

+
let adapter = RenameColumnAdapter { $0 + "rrr" }
+let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
+
+// [foorrr:"foo", barrrr:"bar", bazrrr:"baz"]
+try Row.fetchOne(db, sql: sql, adapter: adapter)
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a RenameColumnAdapter adapter that renames columns according to the +provided transform function.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ transform: @escaping (String) -> String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ResultCode.html b/docs/5.16/Structs/ResultCode.html new file mode 100644 index 000000000..8b703c352 --- /dev/null +++ b/docs/5.16/Structs/ResultCode.html @@ -0,0 +1,4234 @@ + + + + ResultCode Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ResultCode

+
+
+ +
public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible
+ +
+
+

An SQLite result code.

+ +

See https://www.sqlite.org/rescode.html

+ + +
+
+
+
    +
  • +
    + + + + rawValue + +
    +
    +
    +
    +
    +
    +

    The raw SQLite result code

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let rawValue: CInt
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    +

    Creates a ResultCode from a raw SQLite result code.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawValue: CInt)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + primaryResultCode + +
    +
    +
    +
    +
    +
    +

    A result code limited to the least significant 8 bits of the receiver. +See https://www.sqlite.org/rescode.html for more information.

    +
    let resultCode = .SQLITE_CONSTRAINT_FOREIGNKEY
    +resultCode.primaryResultCode == .SQLITE_CONSTRAINT // true
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var primaryResultCode: ResultCode { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ~=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the code on the left matches the code on the right.

    + +

    Primary result codes match themselves and their extended result codes, +while extended result codes match only themselves:

    +
    switch error.extendedResultCode {
    +case .SQLITE_CONSTRAINT_FOREIGNKEY: // foreign key constraint error
    +case .SQLITE_CONSTRAINT:            // any other constraint error
    +default:                            // any other database error
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func ~= (pattern: ResultCode, code: ResultCode) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_OK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_OK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ERROR + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_INTERNAL + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_INTERNAL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_PERM + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_PERM: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ABORT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ABORT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_BUSY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_BUSY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_LOCKED + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_LOCKED: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOMEM + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOMEM: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_READONLY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_INTERRUPT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_INTERRUPT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CORRUPT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CORRUPT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOTFOUND + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTFOUND: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_FULL + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_FULL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CANTOPEN + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_PROTOCOL + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_PROTOCOL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_EMPTY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_EMPTY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_SCHEMA + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_SCHEMA: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_TOOBIG + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_TOOBIG: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CONSTRAINT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_MISMATCH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_MISMATCH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_MISUSE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_MISUSE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOLFS + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOLFS: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_AUTH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_AUTH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_FORMAT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_FORMAT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_RANGE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_RANGE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOTADB + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTADB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOTICE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTICE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_WARNING + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_WARNING: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ROW + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ROW: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_DONE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_DONE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR_MISSING_COLLSEQ: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ERROR_RETRY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR_RETRY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ERROR_SNAPSHOT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR_SNAPSHOT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_READ + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_READ: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHORT_READ: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_WRITE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_WRITE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_FSYNC + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_FSYNC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DIR_FSYNC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_TRUNCATE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_TRUNCATE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_FSTAT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_FSTAT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_UNLOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_UNLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_RDLOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_RDLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_DELETE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DELETE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_BLOCKED + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_BLOCKED: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_NOMEM + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_NOMEM: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_ACCESS + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_ACCESS: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_CHECKRESERVEDLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_LOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_LOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_CLOSE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_CLOSE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DIR_CLOSE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMOPEN + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMOPEN: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMSIZE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMSIZE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMLOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMMAP + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMMAP: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SEEK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SEEK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DELETE_NOENT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_MMAP + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_MMAP: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_GETTEMPPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_CONVPATH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_CONVPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_VNODE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_VNODE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_AUTH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_AUTH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_BEGIN_ATOMIC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_COMMIT_ATOMIC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_ROLLBACK_ATOMIC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_LOCKED_SHAREDCACHE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_LOCKED_VTAB + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_LOCKED_VTAB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_BUSY_RECOVERY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_BUSY_RECOVERY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_BUSY_SNAPSHOT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_BUSY_SNAPSHOT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_NOTEMPDIR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CANTOPEN_ISDIR + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_ISDIR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_FULLPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_CONVPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_DIRTYWAL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CORRUPT_VTAB + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CORRUPT_VTAB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CORRUPT_SEQUENCE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_RECOVERY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_CANTLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_ROLLBACK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_DBMOVED: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_CANTINIT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_DIRECTORY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ABORT_ROLLBACK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ABORT_ROLLBACK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_CHECK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_COMMITHOOK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_FOREIGNKEY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_FUNCTION: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_NOTNULL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_PRIMARYKEY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_TRIGGER: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_UNIQUE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_VTAB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_ROWID: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTICE_RECOVER_WAL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTICE_RECOVER_ROLLBACK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_WARNING_AUTOINDEX: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_AUTH_USER + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_AUTH_USER: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_OK_LOAD_PERMANENTLY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ~=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the code on the left matches the error on the right.

    + +

    Primary result codes match themselves and their extended result codes, +while extended result codes match only themselves.

    +
    do {
    +    try ...
    +} catch ResultCode.SQLITE_CONSTRAINT_FOREIGNKEY {
    +    // foreign key constraint error
    +} catch ResultCode.SQLITE_CONSTRAINT {
    +    // any other constraint error
    +} catch {
    +    // any other database error
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func ~= (lhs: `Self`, rhs: Error) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQL.html b/docs/5.16/Structs/SQL.html new file mode 100644 index 000000000..321462bf2 --- /dev/null +++ b/docs/5.16/Structs/SQL.html @@ -0,0 +1,1567 @@ + + + + SQL Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQL

+
+
+ +
public struct SQL
+
extension SQL: SQLSpecificExpressible
+
extension SQL: SQLSelectable
+
extension SQL: SQLOrderingTerm
+
extension SQL: ExpressibleByStringInterpolation
+ +
+
+

SQL helps you build SQL literal with +SQL Interpolation.

+ +

For example:

+
try dbQueue.write { db in
+    let name: String = ...
+    let id: Int64 = ...
+    let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
+    try db.execute(literal: query)
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init(sql:arguments:) + +
    +
    +
    +
    +
    +
    +

    Creates an SQL literal from a plain SQL string, and +eventual arguments.

    + +

    For example:

    +
    let query = SQL(
    +    sql: "UPDATE player SET name = ? WHERE id = ?",
    +    arguments: [name, id])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sql: String, arguments: StatementArguments = StatementArguments())
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an SQL literal from an SQL expression.

    + +

    For example:

    +
    let columnLiteral = SQL(Column("username"))
    +let suffixLiteral = SQL("@example.com".databaseValue)
    +let emailLiteral = [columnLiteral, suffixLiteral].joined(separator: " || ")
    +let request = User.select(emailLiteral.sqlExpression)
    +let emails = try String.fetchAll(db, request)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ expression: SQLSpecificExpressible)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    Returns true if this literal generates an empty SQL string

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + build(_:) + +
    +
    +
    +
    +
    +
    +

    Turn a SQL literal into raw SQL and arguments.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func build(_ db: Database) throws -> (sql: String, arguments: StatementArguments)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A tuple made of a raw SQL string, and statement arguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns the SQL literal produced by the concatenation of two literals.

    +
    let name = "O'Brien"
    +let selection: SQL = "SELECT * FROM player "
    +let condition: SQL = "WHERE name = \(name)"
    +let query = selection + condition
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func + (lhs: SQL, rhs: SQL) -> SQL
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Appends an SQL literal to the receiver.

    +
    let name = "O'Brien"
    +var query: SQL = "SELECT * FROM player "
    +query += "WHERE name = \(name)"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func += (lhs: inout SQL, rhs: SQL)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + append(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends an SQL literal to the receiver.

    +
    let name = "O'Brien"
    +var query: SQL = "SELECT * FROM player "
    +query.append(literal: "WHERE name = \(name)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func append(literal sqlLiteral: SQL)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Appends a plain SQL string to the receiver, and eventual arguments.

    +
    let name = "O'Brien"
    +var query: SQL = "SELECT * FROM player "
    +query.append(sql: "WHERE name = ?", arguments: [name])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func append(sql: String, arguments: StatementArguments = StatementArguments())
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlExpression + +
    +
    +
    +
    +
    +
    +

    Creates a literal SQL expression.

    + +

    Use this property when you need an explicit SQLExpression. +For example:

    +
    func date(_ value: SQLExpressible) -> SQLExpression {
    +    SQL("DATE(\(value))").sqlExpression
    +}
    +
    +// SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
    +let createdAt = Column("createdAt")
    +let request = Player.filter(date(createdAt) == "2020-01-23")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSelection + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSelection: SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlOrdering + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlOrdering: SQLOrdering { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ExpressibleByStringInterpolation +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQLExpression.html b/docs/5.16/Structs/SQLExpression.html new file mode 100644 index 000000000..1efc214b0 --- /dev/null +++ b/docs/5.16/Structs/SQLExpression.html @@ -0,0 +1,1201 @@ + + + + SQLExpression Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLExpression

+
+
+ +
public struct SQLExpression
+
extension SQLExpression: SQLSpecificExpressible
+ +
+
+

SQLExpression is the type that represents an SQL expression, as +described at https://www.sqlite.org/lang_expr.html

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    AssociativeBinaryOperator is an associative binary operator, +such as +, *, AND, etc.

    + +

    Use it with the joined(operator:) method. For example:

    +
    // SELECT score + bonus + 1000 FROM player
    +let values = [
    +    scoreColumn,
    +    bonusColumn,
    +    1000.databaseValue]
    +Player.select(values.joined(operator: .add))
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AssociativeBinaryOperator : Hashable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQLExpressible +

+
+
+
    +
  • +
    + + + + sqlExpression + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQLExpression/AssociativeBinaryOperator.html b/docs/5.16/Structs/SQLExpression/AssociativeBinaryOperator.html new file mode 100644 index 000000000..2d8e902f8 --- /dev/null +++ b/docs/5.16/Structs/SQLExpression/AssociativeBinaryOperator.html @@ -0,0 +1,1301 @@ + + + + AssociativeBinaryOperator Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociativeBinaryOperator

+
+
+ +
public struct AssociativeBinaryOperator : Hashable
+ +
+
+

AssociativeBinaryOperator is an associative binary operator, +such as +, *, AND, etc.

+ +

Use it with the joined(operator:) method. For example:

+
// SELECT score + bonus + 1000 FROM player
+let values = [
+    scoreColumn,
+    bonusColumn,
+    1000.databaseValue]
+Player.select(values.joined(operator: .add))
+
+ + +
+
+
+
    +
  • +
    + + + + add + +
    +
    +
    +
    +
    +
    +

    The + binary operator

    + +

    For example:

    +
    // score + bonus
    +[Column("score"), Column("bonus")].joined(operator: .add)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let add: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + multiply + +
    +
    +
    +
    +
    +
    +

    The * binary operator

    + +

    For example:

    +
    // score * factor
    +[Column("score"), Column("factor")].joined(operator: .multiply)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let multiply: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + and + +
    +
    +
    +
    +
    +
    +

    The AND binary operator

    + +

    For example:

    +
    // isBlue AND isTall
    +[Column("isBlue"), Column("isTall")].joined(operator: .and)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let and: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + or + +
    +
    +
    +
    +
    +
    +

    The OR binary operator

    + +

    For example:

    +
    // isBlue OR isTall
    +[Column("isBlue"), Column("isTall")].joined(operator: .or)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let or: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + concat + +
    +
    +
    +
    +
    +
    +

    The || string concatenation operator

    + +

    For example:

    +
    // firstName || ' ' || lastName
    +[Column("firstName"), " ", Column("lastName")].joined(operator: .concat)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let concat: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQLOrdering.html b/docs/5.16/Structs/SQLOrdering.html new file mode 100644 index 000000000..0e6e7afaa --- /dev/null +++ b/docs/5.16/Structs/SQLOrdering.html @@ -0,0 +1,1156 @@ + + + + SQLOrdering Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLOrdering

+
+
+ +
public struct SQLOrdering
+
extension SQLOrdering: SQLOrderingTerm
+ +
+
+

The type that can be used as an SQL ordering term, as described at +https://www.sqlite.org/syntax/ordering-term.html

+ + +
+
+
+
+ + +
+ +

SQLOrderingTerm +

+
+
+
    +
  • +
    + + + + sqlOrdering + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlOrdering: SQLOrdering { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQLRequest.html b/docs/5.16/Structs/SQLRequest.html new file mode 100644 index 000000000..95a6ab5c8 --- /dev/null +++ b/docs/5.16/Structs/SQLRequest.html @@ -0,0 +1,1655 @@ + + + + SQLRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLRequest

+
+
+ +
public struct SQLRequest<RowDecoder>
+
extension SQLRequest: FetchRequest
+
extension SQLRequest: ExpressibleByStringInterpolation
+ +
+
+

A FetchRequest built from raw SQL.

+ + +
+
+
+
    +
  • +
    + + + + adapter + +
    +
    +
    +
    +
    +
    +

    The request adapter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var adapter: RowAdapter?
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL string, optional arguments, and +optional row adapter.

    +
    let request = SQLRequest<String>(sql: """
    +    SELECT name FROM player
    +    """)
    +let request = SQLRequest<Player>(sql: """
    +    SELECT * FROM player WHERE id = ?
    +    """, arguments: [1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil,
    +    cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL literal, and optional row adapter.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    let name = "O'brien"
    +let request = SQLRequest<Player>(literal: """
    +    SELECT * FROM player WHERE name = \(name)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(literal sqlLiteral: SQL, adapter: RowAdapter? = nil, cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSubquery + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSubquery: SQLSubquery { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCount(_ db: Database) throws -> Int
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makePreparedRequest(
    +    _ db: Database,
    +    forSingleResult singleResult: Bool = false)
    +throws -> PreparedRequest
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    :nodoc

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(unicodeScalarLiteral: String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL string, optional arguments, and +optional row adapter.

    +
    let request = SQLRequest(sql: """
    +    SELECT * FROM player WHERE id = ?
    +    """, arguments: [1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil,
    +    cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL literal, and optional row adapter.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    let name = "O'brien"
    +let request = SQLRequest(literal: """
    +    SELECT * FROM player WHERE name = \(name)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(literal sqlLiteral: SQL, adapter: RowAdapter? = nil, cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQLSelection.html b/docs/5.16/Structs/SQLSelection.html new file mode 100644 index 000000000..618fc8336 --- /dev/null +++ b/docs/5.16/Structs/SQLSelection.html @@ -0,0 +1,1156 @@ + + + + SQLSelection Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSelection

+
+
+ +
public struct SQLSelection
+
extension SQLSelection: SQLSelectable
+ +
+
+

The type that can be selected, as described at +https://www.sqlite.org/syntax/result-column.html

+ + +
+
+
+
+ + +
+ +

SQLSelectable +

+
+
+
    +
  • +
    + + + + sqlSelection + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSelection: SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SQLSubquery.html b/docs/5.16/Structs/SQLSubquery.html new file mode 100644 index 000000000..c04605b48 --- /dev/null +++ b/docs/5.16/Structs/SQLSubquery.html @@ -0,0 +1,1156 @@ + + + + SQLSubquery Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSubquery

+
+
+ +
public struct SQLSubquery
+
extension SQLSubquery: SQLSubqueryable
+ +
+
+

The type that can be embedded as a subquery.

+ + +
+
+
+
+ + +
+ +

SQLSubqueryable +

+
+
+
    +
  • +
    + + + + sqlSubquery + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSubquery: SQLSubquery { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ScopeAdapter.html b/docs/5.16/Structs/ScopeAdapter.html new file mode 100644 index 000000000..07beaf5d9 --- /dev/null +++ b/docs/5.16/Structs/ScopeAdapter.html @@ -0,0 +1,1270 @@ + + + + ScopeAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ScopeAdapter

+
+
+ +
public struct ScopeAdapter : RowAdapter
+ +
+
+

ScopeAdapter is a row adapter that lets you define scopes on rows.

+
// Two adapters
+let fooAdapter = ColumnMapping(["value": "foo"])
+let barAdapter = ColumnMapping(["value": "bar"])
+
+// Define scopes
+let adapter = ScopeAdapter([
+    "foo": fooAdapter,
+    "bar": barAdapter])
+
+// Fetch
+let sql = "SELECT 'foo' AS foo, 'bar' AS bar"
+let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+
+// Scoped rows:
+if let fooRow = row.scopes["foo"] {
+    fooRow["value"]    // "foo"
+}
+if let barRow = row.scopes["bar"] {
+    barRow["value"]    // "bar"
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an adapter that preserves row contents and add scoped rows.

    + +

    For example:

    +
    let adapter = ScopeAdapter(["suffix": SuffixRowAdapter(fromIndex: 1)])
    +let row = try Row.fetchOne(db, sql: "SELECT 1, 2, 3", adapter: adapter)!
    +row                  // [1, 2, 3]
    +row.scopes["suffix"] // [2, 3]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ scopes: [String : RowAdapter])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + scopes + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(base:scopes:) + +
    +
    +
    +
    +
    +
    +

    Creates an adapter based on the base adapter, and add scoped rows.

    + +

    For example:

    +
    let baseAdapter = RangeRowAdapter(0..<1)
    +let adapter = ScopeAdapter(base: baseAdapter, scopes: ["suffix": SuffixRowAdapter(fromIndex: 1)])
    +let row = try Row.fetchOne(db, sql: "SELECT 1, 2, 3", adapter: adapter)!
    +row                   // [1]
    +row.scopes["initial"] // [2, 3]
    +
    + +

    If the base adapter already defines scopes, the given scopes replace +eventual existing scopes with the same name.

    + +

    This initializer is equivalent to baseAdapter.addingScopes(scopes).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(base: RowAdapter, scopes: [String : RowAdapter])
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + base + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    + + scopes + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/StatementArguments.html b/docs/5.16/Structs/StatementArguments.html new file mode 100644 index 000000000..376a60a8c --- /dev/null +++ b/docs/5.16/Structs/StatementArguments.html @@ -0,0 +1,1963 @@ + + + + StatementArguments Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

StatementArguments

+
+
+ +
public struct StatementArguments: CustomStringConvertible, Equatable,
+                                  ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
+ +
+
+

StatementArguments provide values to argument placeholders in raw +SQL queries.

+ +

Placeholders can take several forms (see https://www.sqlite.org/lang_expr.html#varparam +for more information):

+ +
    +
  • ?NNN (e.g. ?2): the NNN-th argument (starts at 1)
  • +
  • ?: the N-th argument, where N is one greater than the largest argument +number already assigned
  • +
  • :AAAA (e.g. :name): named argument

  • +
  • $AAAA (e.g. $name): named argument

  • +
+

Positional Arguments

+ +

To fill question marks placeholders, feed StatementArguments with an array:

+
db.execute(
+    sql: "INSERT ... (?, ?)",
+    arguments: StatementArguments(["Arthur", 41]))
+
+// Array literals are automatically converted:
+db.execute(
+    sql: "INSERT ... (?, ?)",
+    arguments: ["Arthur", 41])
+
+

Named Arguments

+ +

To fill named arguments, feed StatementArguments with a dictionary:

+
db.execute(
+    sql: "INSERT ... (:name, :score)",
+    arguments: StatementArguments(["name": "Arthur", "score": 41]))
+
+// Dictionary literals are automatically converted:
+db.execute(
+    sql: "INSERT ... (:name, :score)",
+    arguments: ["name": "Arthur", "score": 41])
+
+

Concatenating Arguments

+ +

Several arguments can be concatenated and mixed with the +append(contentsOf:) method and the +, &+, += operators:

+
var arguments: StatementArguments = ["Arthur"]
+arguments += [41]
+db.execute(sql: "INSERT ... (?, ?)", arguments: arguments)
+
+ +

+ and += operators consider that overriding named arguments is a +programmer error:

+
var arguments: StatementArguments = ["name": "Arthur"]
+arguments += ["name": "Barbara"]
+// fatal error: already defined statement argument: name
+
+ +

&+ and append(contentsOf:) allow overriding named arguments:

+
var arguments: StatementArguments = ["name": "Arthur"]
+arguments = arguments &+ ["name": "Barbara"]
+print(arguments)
+// Prints ["name": "Barbara"]
+
+

Mixed Arguments

+ +

It is possible to mix named and positional arguments. Yet this is usually +confusing, and it is best to avoid this practice:

+
let sql = "SELECT ?2 AS two, :foo AS foo, ?1 AS one, :foo AS foo2, :bar AS bar"
+var arguments: StatementArguments = [1, 2, "bar"] + ["foo": "foo"]
+let row = try Row.fetchOne(db, sql: sql, arguments: arguments)!
+print(row)
+// Prints [two:2 foo:"foo" one:1 foo2:"foo" bar:"bar"]
+
+ +

Mixed arguments exist as a support for requests like the following:

+
let players = try Player
+    .filter(sql: "team = :team", arguments: ["team": "Blue"])
+    .filter(sql: "score > ?", arguments: [1000])
+    .fetchAll(db)
+
+ + +
+
+
+
    +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Empty Arguments +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates empty StatementArguments.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Positional Arguments +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of optional values.

    +
    let values: [DatabaseValueConvertible?] = ["foo", 1, nil]
    +db.execute(sql: "INSERT ... (?,?,?)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Sequence>(_ sequence: Sequence) where Sequence : Sequence, Sequence.Element == DatabaseValueConvertible?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of DatabaseValueConvertible values.

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of optional values.

    +
    let values: [String] = ["foo", "bar"]
    +db.execute(sql: "INSERT ... (?,?)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Sequence>(_ sequence: Sequence) where Sequence : Sequence, Sequence.Element : DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of DatabaseValueConvertible values.

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from any array. The result is nil unless all +array elements adopt DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(_ array: [Any])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + array + + +
    +

    An array

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Named Arguments +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of (key, value) dictionary, +such as a dictionary.

    +
    let values: [String: DatabaseValueConvertible?] = ["firstName": nil, "lastName": "Miller"]
    +db.execute(sql: "INSERT ... (:firstName, :lastName)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ dictionary: [String : DatabaseValueConvertible?])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of (key, value) pairs

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of (key, value) pairs, such +as a dictionary.

    +
    let values: [String: DatabaseValueConvertible?] = ["firstName": nil, "lastName": "Miller"]
    +db.execute(sql: "INSERT ... (:firstName, :lastName)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Sequence>(_ sequence: Sequence)
    +where Sequence: Swift.Sequence, Sequence.Element == (String, DatabaseValueConvertible?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of (key, value) pairs

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from [AnyHashable: Any].

    + +

    The result is nil unless all dictionary keys are strings, and values +adopt DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(_ dictionary: [AnyHashable : Any])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + dictionary + + +
    +

    A dictionary.

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Adding arguments +

+
+
+
    +
  • +
    + + + + append(contentsOf:) + +
    +
    +
    +
    +
    +
    +

    Extends statement arguments with other arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    var arguments: StatementArguments = [1]
    +arguments.append(contentsOf: [2, 3])
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments.append(contentsOf: ["bar": 2])
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    Arguments that were replaced, if any, are returned:

    +
    var arguments: StatementArguments = ["foo": 1, "bar": 2]
    +let replacedValues = arguments.append(contentsOf: ["foo": 3])
    +print(arguments)
    +// Prints ["foo": 3, "bar": 2]
    +print(replacedValues)
    +// Prints ["foo": 1]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments.append(contentsOf: [2, 3])
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func append(contentsOf arguments: StatementArguments) -> [String : DatabaseValue]
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates a new StatementArguments by extending the left-hand size +arguments with the right-hand side arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    let arguments: StatementArguments = [1] + [2, 3]
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    let arguments: StatementArguments = ["foo": 1] + ["bar": 2]
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    let arguments: StatementArguments = ["foo": 1] + [2, 3]
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +

    If the arguments on the right-hand side has named parameters that are +already defined on the left, a fatal error is raised:

    +
    let arguments: StatementArguments = ["foo": 1] + ["foo": 2]
    +// fatal error: already defined statement argument: foo
    +
    + +

    This fatal error can be avoided with the &+ operator, or the +append(contentsOf:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func + (lhs: StatementArguments, rhs: StatementArguments) -> StatementArguments
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + &+(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates a new StatementArguments by extending the left-hand size +arguments with the right-hand side arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    let arguments: StatementArguments = [1] &+ [2, 3]
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    let arguments: StatementArguments = ["foo": 1] &+ ["bar": 2]
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    let arguments: StatementArguments = ["foo": 1] &+ [2, 3]
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +

    If a named arguments is defined in both arguments, the right-hand +side wins:

    +
    let arguments: StatementArguments = ["foo": 1] &+ ["foo": 2]
    +print(arguments)
    +// Prints ["foo": 2]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func &+ (lhs: StatementArguments, rhs: StatementArguments) -> StatementArguments
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Extends the left-hand size arguments with the right-hand side arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    var arguments: StatementArguments = [1]
    +arguments += [2, 3]
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments += ["bar": 2]
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments.append(contentsOf: [2, 3])
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +

    If the arguments on the right-hand side has named parameters that are +already defined on the left, a fatal error is raised:

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments += ["foo": 2]
    +// fatal error: already defined statement argument: foo
    +
    + +

    This fatal error can be avoided with the &+ operator, or the +append(contentsOf:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func += (lhs: inout StatementArguments, rhs: StatementArguments)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementArguments +

+
+
+
    +
  • +
    + + + + init(arrayLiteral:) + +
    +
    +
    +
    +
    +
    +

    Returns a StatementArguments from an array literal:

    +
    let arguments: StatementArguments = ["Arthur", 41]
    +try db.execute(
    +    sql: "INSERT INTO player (name, score) VALUES (?, ?)"
    +    arguments: arguments)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(arrayLiteral elements: DatabaseValueConvertible?...)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a StatementArguments from a dictionary literal:

    +
    let arguments: StatementArguments = ["name": "Arthur", "score": 41]
    +try db.execute(
    +    sql: "INSERT INTO player (name, score) VALUES (:name, :score)"
    +    arguments: arguments)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/SuffixRowAdapter.html b/docs/5.16/Structs/SuffixRowAdapter.html new file mode 100644 index 000000000..fe6aa7231 --- /dev/null +++ b/docs/5.16/Structs/SuffixRowAdapter.html @@ -0,0 +1,1155 @@ + + + + SuffixRowAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SuffixRowAdapter

+
+
+ +
public struct SuffixRowAdapter : RowAdapter
+ +
+
+

SuffixRowAdapter is a row adapter that hides the first columns in a row.

+
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)
+
+ + +
+
+
+
    +
  • +
    + + + + init(fromIndex:) + +
    +
    +
    +
    +
    +
    +

    Creates a SuffixRowAdapter that hides all columns before the +provided index.

    + +

    If index is 0, the layout row is identical to the base row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(fromIndex index: Int)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/Table.html b/docs/5.16/Structs/Table.html new file mode 100644 index 000000000..521012080 --- /dev/null +++ b/docs/5.16/Structs/Table.html @@ -0,0 +1,6936 @@ + + + + Table Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Table

+
+
+ +
public struct Table<RowDecoder>
+
extension Table: DatabaseRegionConvertible
+ +
+
+

Table can build query interface requests.

+
// SELECT * FROM player WHERE score >= 1000
+let table = Table("player")
+let rows: [Row] = try dbQueue.read { db in
+    table.all()
+        .filter(Column("score") >= 1000)
+        .fetchAll(db)
+}
+
+ + +
+
+
+
    +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Create a Table

    +
    let table = Table<Row>("player")
    +let table = Table<Player>("player")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ tableName: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseRegion(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseRegion(_ db: Database) throws -> DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Request Derivation +

+
+
+
    +
  • +
    + + + + all() + +
    +
    +
    +
    +
    +
    +

    Creates a request for all rows of the table.

    +
    // Fetch all players
    +let table = Table<Player>("player")
    +let request = table.all()
    +let players: [Player] = try request.fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func all() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + none() + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches no row.

    +
    // Fetch no players
    +let table = Table<Player>("player")
    +let request = table.none()
    +let players: [Player] = try request.fetchAll(db) // Empty array
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func none() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let table = Table("player")
    +let request = table.select(Column("id"), Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: SQLSelectable...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let table = Table("player")
    +let request = table.select([Column("id"), Column("email")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: [SQLSelectable]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which selects sql.

    +
    // SELECT id, email FROM player
    +let table = Table("player")
    +let request = table.select(sql: "id, email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT id, email, score + 1000 FROM player
    +let table = Table("player")
    +let bonus = 1000
    +let request = table.select(literal: """
    +    id, email, score + \(bonus)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(literal sqlLiteral: SQL) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let table = Table("player")
    +    let request = table.select([max(Column("score"))], as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    _ selection: [SQLSelectable],
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let table = Table("player")
    +    let request = table.select(max(Column("score")), as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    _ selection: SQLSelectable...,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which selects sql, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let table = Table("player")
    +    let request = table.select(sql: "max(score)", as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal, and fetches values of +type type.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +let table = Table("player")
    +let defaultName = "Anonymous"
    +let request = table.select(
    +    literal: "IFNULL(name, \(defaultName))",
    +    as: String.self)
    +let name: String? = try request.fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    literal sqlLiteral: SQL,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let table = Table("player")
    +let request = table
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: [Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let table = Table("player")
    +let request = table
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: SQLSelectable...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let table = Table<Player>("player")
    +let request = table.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ predicate: SQLSpecificExpressible) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id = 1
    +let table = Table<Player>("player")
    +let request = table.filter(key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<PrimaryKeyType>(key: PrimaryKeyType?)
    +-> QueryInterfaceRequest<RowDecoder>
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let table = Table<Player>("player")
    +let request = table.filter(keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Sequence>(keys: Sequence)
    +-> QueryInterfaceRequest<RowDecoder>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE personId = 1 AND countryCode = 'FR'
    +let table = Table<Passport>("passport")
    +let request = table.filter(key: ["personId": 1, "countryCode": "FR"])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(key: [String : DatabaseValueConvertible?]?) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE (personId = 1 AND countryCode = 'FR') OR ...
    +let table = Table<Passport>("passport")
    +let request = table.filter(keys: [["personId": 1, "countryCode": "FR"], ...])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(keys: [[String : DatabaseValueConvertible?]]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let table = Table<Player>("player")
    +let request = table.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(literal:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT * FROM player WHERE name = 'O''Brien'
    +let table = Table<Player>("player")
    +let name = "O'Brien"
    +let request = table.filter(literal: "email = \(email)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(literal sqlLiteral: SQL) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: SQLOrderingTerm...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order([Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: [SQLOrderingTerm]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + orderByPrimaryKey() + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted by primary key.

    +
    // SELECT * FROM player ORDER BY id
    +let table = Table<Player>("player")
    +let request = table.orderByPrimaryKey()
    +
    +// SELECT * FROM country ORDER BY code
    +let request = Country.orderByPrimaryKey()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func orderByPrimaryKey() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(sql:arguments:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to sql.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order(sql: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(literal:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to an SQL literal.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order(literal: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(literal sqlLiteral: SQL) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + limit(_:offset:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches limit rows, starting at +offset.

    +
    // SELECT * FROM player LIMIT 1
    +let table = Table<Player>("player")
    +let request = table.limit(1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func limit(_ limit: Int, offset: Int? = nil) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    See TableRecord.aliased(_:) for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func aliased(_ alias: TableAlias) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a request which embeds the common table expression.

    + +

    See TableRecord.with(_:) for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func with<T>(_ cte: CommonTableExpression<T>) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    A request.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Counting All +

+
+
+
    +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    +

    The number of rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCount(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to TableRecord +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +type, based on a database foreign key.

    + +

    For more information, see TableRecord.belongsTo(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func belongsTo<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination type, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasMany(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasMany<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination type, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasOne(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasOne<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to Table +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +table, based on a database foreign key.

    + +

    For more information, see TableRecord.belongsTo(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func belongsTo<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasMany(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasMany<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasOne(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasOne<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to CommonTableExpression +

+
+
+
    +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    For more information, see TableRecord.association(to:on:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

“Through” Associations +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a “Has Many Through” association between Self and the +destination type.

    + +

    For more information, see TableRecord.hasMany(_:through:using:key:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasMany<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasManyThroughAssociation<RowDecoder, Target.RowDecoder>
    +where Pivot: Association,
    +      Target: Association,
    +      Pivot.OriginRowDecoder == RowDecoder,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a “Has One Through” association between Self and the +destination type.

    + +

    For more information, see TableRecord.hasOne(_:through:using:key:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasOne<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasOneThroughAssociation<RowDecoder, Target.RowDecoder>
    +where Pivot: AssociationToOne,
    +      Target: AssociationToOne,
    +      Pivot.OriginRowDecoder == RowDecoder,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Joining Methods +

+
+
+
    +
  • +
    + + + + including(all:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that prefetches an association.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A: AssociationToMany>(all association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(optional:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(required:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A: Association>(required association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(optional:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(required:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A: Association>(required association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the columns of the table.

    +
    let playerTable = Table("player")
    +let teamTable = Table("team")
    +let playerTeam = playerTable.belongsTo(teamTable)
    +
    +// SELECT player.*, team.color
    +// FROM player LEFT JOIN team ...
    +let teamColor = playerTeam.select(Column("color")
    +let request = playerTable.annotated(withOptional: teamColor))
    +
    + +

    This method performs the same SQL request as including(optional:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String?
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(optional:):

    +
    let teamAlias = TableAlias()
    +let request = playerTable
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(optional: playerTeam.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A: Association>(withOptional association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the columns of the table.

    +
    let playerTable = Table("player")
    +let teamTable = Table("team")
    +let playerTeam = playerTable.belongsTo(teamTable)
    +
    +// SELECT player.*, team.color
    +// FROM player JOIN team ...
    +let teamColor = playerTeam.select(Column("color")
    +let request = playerTable.annotated(withRequired: teamColor))
    +
    + +

    This method performs the same SQL request as including(required:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(required:):

    +
    let teamAlias = TableAlias()
    +let request = playerTable
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(required: playerTeam.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A: Association>(withRequired association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Association Aggregates +

+
+
+
    +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let table = Table<Player>("player")
    +let request = table.annotated(with: Player.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: AssociationAggregate<RowDecoder>...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let table = Table<Player>("player")
    +let request = table.annotated(with: [Player.books.count])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided aggregate predicate.

    +
    // SELECT player.*
    +// FROM player LEFT JOIN book ...
    +// HAVING COUNT(DISTINCT book.id) = 0
    +let table = Table<Player>("player")
    +var request = table.all()
    +request = request.having(Player.books.isEmpty)
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: AssociationAggregate<RowDecoder>) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Delete +

+
+
+
    +
  • +
    + + + + deleteAll(_:) + +
    +
    +
    +
    +
    +
    +

    Deletes all rows; returns the number of deleted rows.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Table("player").exists(db, key: 123)
    +try Table("country").exists(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Table("document").exists(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this unique key (primary key or any key +with a unique index on it).

    +
    Table("player").exists(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Table("player").deleteAll(db, keys: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Table("country").deleteAll(db, keys: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Table("document").deleteAll(db, keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll<Sequence>(_ db: Database, keys: Sequence)
    +throws -> Int
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Table("player").deleteOne(db, key: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Table("country").deleteOne(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Table("document").deleteOne(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType?)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by the provided unique keys (primary key or +any key with a unique index on it); returns the number of deleted rows.

    +
    try Table("player").deleteAll(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by a unique key (the primary key or any key +with a unique index on it); returns whether a database row was deleted.

    +
    Table("player").deleteOne(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Update +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Updates all rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Table("player").updateAll(db, [Column("score").set(to: 0)])
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignments: [ColumnAssignment])
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignments + + +
    +

    An array of column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Updates all rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Table("player").updateAll(db, Column("score").set(to: 0))
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignment: ColumnAssignment,
    +    _ otherAssignments: ColumnAssignment...)
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignment + + +
    +

    A column assignment.

    +
    +
    + + otherAssignments + + +
    +

    Eventual other column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Create a Table of Row.

    +
    let table = Table("player") // Table<Row>
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ tableName: String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let table = Table<Player>("player")
    +let request = table.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let table = Table<Player>("player")
    +let request = table.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<RowDecoder>
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let table = Table("player")
    +let request = try table.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let table = Table<Player>("player")
    +let request = table.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID.Wrapped) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let table = Table<Player>("player")
    +let request = table.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<RowDecoder>
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let table = Table("player")
    +let request = try table.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID.Wrapped>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: FetchableRecord +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all records fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table<Player>("player")
    +let players = try table.fetchCursor(db) // Cursor of Player
    +while let player = try players.next() {  // Player
    +    ...
    +}
    +
    + +

    Records are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RecordCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all records fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table<Player>("player")
    +let players = try table.fetchAll(db) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The first found record.

    +
    // SELECT * FROM player LIMIT 1
    +let table = Table<Player>("player")
    +let player = try table.fetchOne(db) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: FetchableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all records fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table<Player>("player")
    +let players = try table.fetchSet(db) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all rows fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table("player")
    +let rows = try table.fetchCursor(db) // Cursor of Row
    +while let row = try rows.next() {    // Row
    +    ...
    +}
    +
    + +

    Rows are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all rows fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table("player")
    +let players = try table.fetchAll(db) // [Row]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The first found row.

    +
    // SELECT * FROM player LIMIT 1
    +let table = Table("player")
    +let row = try table.fetchOne(db) // Row?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all rows fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table("player")
    +let rows = try table.fetchSet(db) // Set<Row>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchCursor(db) // Cursor of String
    +while let name = try names.next() {   // String
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> DatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String>("name")
    +let name = try table.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchCursor(db) // Cursor of String?
    +while let name = try names.next() {   // String?
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> NullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String?>("name")
    +let name = try table.fetchOne(db) // String?
    +
    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchCursor(db) // Cursor of String
    +while let name = try names.next() {   // String
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastDatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String>("name")
    +let name = try table.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & StatementColumnConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchCursor(db) // Cursor of String?
    +while let name = try names.next() {   // String?
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastNullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String?>("name")
    +let name = try table.fetchOne(db) // String?
    +
    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Table<Player>("player").exists(db, id: 123)
    +try Table<Country>("player").exists(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Table<Document>("document").exists(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists(_ db: Database, id: RowDecoder.ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Table<Player>("player").exists(db, id: 123)
    +try Table<Country>("country").exists(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Table<Document>("document").exists(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists(_ db: Database, id: RowDecoder.ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Table<Player>("player").deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Table<Country>("country").deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Table<Document>("document").deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Table<Player>("player").deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Table<Country>("country").deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Table<Document>("document").deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne(_ db: Database, id: RowDecoder.ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Table<Player>("player").deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Table<Country>("country").deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Table<Document>("document").deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Table<Player>("player").deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Table<Country>("country").deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Table<Document>("document").deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne(_ db: Database, id: RowDecoder.ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Structs/ValueObservation.html b/docs/5.16/Structs/ValueObservation.html new file mode 100644 index 000000000..973e0949c --- /dev/null +++ b/docs/5.16/Structs/ValueObservation.html @@ -0,0 +1,2281 @@ + + + + ValueObservation Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ValueObservation

+
+
+ +
public struct ValueObservation<Reducer> where Reducer : ValueReducer
+ +
+
+

ValueObservation tracks changes in the results of database requests, and +notifies fresh values whenever the database changes.

+ +

For example:

+
let observation = ValueObservation.tracking { db in
+    try Player.fetchAll(db)
+}
+
+let cancellable = try observation.start(
+    in: dbQueue,
+    onError: { error in ... },
+    onChange: { players: [Player] in
+        print("Players have changed.")
+    })
+
+ + +
+
+
+
    +
  • +
    + + + + requiresWriteAccess + +
    +
    +
    +
    +
    +
    +

    Default is false. Set this property to true when the observation +requires write access in order to fetch fresh values. Fetches are then +wrapped inside a savepoint.

    + +

    Don’t set this flag to true unless you really need it. A read/write +observation is less efficient than a read-only observation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var requiresWriteAccess: Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a shared value observation that shares a single underlying +database observation for all subscriptions, and thus spares +database resources.

    + +

    Experimental

    + +

    For example:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +
    + +

    The sharing only applies if you start observing the database from the +same SharedValueObservation instance:

    +
    // NOT shared
    +let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +
    +// Shared
    +let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
    +let cancellable1 = sharedObservation.start(...)
    +let cancellable2 = sharedObservation.start(...)
    +
    + +

    By default, fresh values are dispatched asynchronously on the +main queue. You can change this behavior by providing a scheduler. +For example, .immediate notifies all values on the main queue as well, +and the first one is immediately notified when the start() method +is called:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(
    +        in: dbQueue,
    +        scheduling: .immediate) // <-
    +
    +let cancellable = try sharedObservation.start(
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +// <- here "fresh players" is already printed.
    +
    + +

    Note that the .immediate scheduler requires that the observation is +subscribed from the main thread. It raises a fatal error otherwise.

    + +

    A shared observation starts observing the database as soon as it is +subscribed. You can choose if database observation should stop, or not, +when its number of subscriptions drops down to zero, with the extent +parameter. See SharedValueObservationExtent for available options.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func shared(
    +    in reader: DatabaseReader,
    +    scheduling scheduler: ValueObservationScheduler = .async(onQueue: .main),
    +    extent: SharedValueObservationExtent = .whileObserved)
    +-> SharedValueObservation<Reducer.Value>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseReader.

    +
    +
    + + scheduler + + +
    +

    A Scheduler. By default, fresh values are +dispatched asynchronously on the main queue.

    +
    +
    + + extent + + +
    +

    The extent of the shared database observation.

    +
    +
    +
    +
    +

    Return Value

    +

    A SharedValueObservation

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Starting Observation +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Starts the value observation in the provided database reader (such as +a database queue or database pool).

    + +

    The observation lasts until the returned cancellable is cancelled +or deallocated.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +

    By default, fresh values are dispatched asynchronously on the +main queue. You can change this behavior by providing a scheduler. +For example, .immediate notifies all values on the main queue as well, +and the first one is immediately notified when the start() method +is called:

    +
    let cancellable = try observation.start(
    +    in: dbQueue,
    +    scheduling: .immediate, // <-
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +// <- here "fresh players" is already printed.
    +
    + +

    Note that the .immediate scheduler requires that the observation is +subscribed from the main thread. It raises a fatal error otherwise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func start(
    +    in reader: DatabaseReader,
    +    scheduling scheduler: ValueObservationScheduler = .async(onQueue: .main),
    +    onError: @escaping (Error) -> Void,
    +    onChange: @escaping (Reducer.Value) -> Void) -> DatabaseCancellable
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseReader.

    +
    +
    + + scheduler + + +
    +

    A Scheduler. By default, fresh values are +dispatched asynchronously on the main queue.

    +
    +
    + + onError + + +
    +

    A closure that is provided eventual errors that +happen during observation

    +
    +
    + + onChange + + +
    +

    A closure that is provided fresh values

    +
    +
    +
    +
    +

    Return Value

    +

    a DatabaseCancellable

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Debugging +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Performs the specified closures when ValueObservation events occur.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func handleEvents(
    +    willStart: (() -> Void)? = nil,
    +    willFetch: (() -> Void)? = nil,
    +    willTrackRegion: ((DatabaseRegion) -> Void)? = nil,
    +    databaseDidChange: (() -> Void)? = nil,
    +    didReceiveValue: ((Reducer.Value) -> Void)? = nil,
    +    didFail: ((Error) -> Void)? = nil,
    +    didCancel: (() -> Void)? = nil)
    +-> ValueObservation<ValueReducers.Trace<Reducer>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + willStart + + +
    +

    A closure that executes when the observation starts. +Defaults to nil.

    +
    +
    + + willFetch + + +
    +

    A closure that executes when the observed value is +about to be fetched. Defaults to nil.

    +
    +
    + + willTrackRegion + + +
    +

    A closure that executes when the observation +starts tracking a database region. Defaults to nil.

    +
    +
    + + databaseDidChange + + +
    +

    A closure that executes after the observation +was impacted by a database change. Defaults to nil.

    +
    +
    + + didReceiveValue + + +
    +

    A closure that executes on fresh values. Defaults +to nil.

    +
    +
    + + didFail + + +
    +

    A closure that executes when the observation fails. +Defaults to nil.

    +
    +
    + + didCancel + + +
    +

    A closure that executes when the observation is +cancelled. Defaults to nil.

    +
    +
    +
    +
    +

    Return Value

    +

    A ValueObservation that performs the specified closures +when ValueObservation events occur.

    +
    + +
    +
    +
  • +
  • +
    + + + + print(_:to:) + +
    +
    +
    +
    +
    +
    +

    Prints log messages for all ValueObservation events.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func print(
    +    _ prefix: String = "",
    +    to stream: TextOutputStream? = nil)
    +-> ValueObservation<ValueReducers.Trace<Reducer>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Observed Values +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a publisher which tracks changes in database values.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +let cancellable = observation
    +    .publisher(in: dbQueue)
    +    .sink(
    +        receiveCompletion: { completion in ... },
    +        receiveValue: { players: [Player] in
    +            print("fresh players: \(players)")
    +        })
    +
    + +

    By default, fresh values are dispatched asynchronously on the +main queue. You can change this behavior by by providing a scheduler.

    + +

    For example, .immediate notifies all values on the main queue as well, +and the first one is immediately notified when the publisher +is subscribed:

    +
    let cancellable = observation
    +    .publisher(
    +        in: dbQueue,
    +        scheduling: .immediate) // <-
    +    .sink(
    +        receiveCompletion: { completion in ... },
    +        receiveValue: { players: [Player] in
    +            print("fresh players: \(players)")
    +        })
    +// <- here "fresh players" is already printed.
    +
    + +

    Note that the .immediate scheduler requires that the publisher is +subscribed from the main thread. It raises a fatal error otherwise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func publisher(
    +    in reader: DatabaseReader,
    +    scheduling scheduler: ValueObservationScheduler = .async(onQueue: .main))
    +-> DatabasePublishers.Value<Reducer.Value>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseReader.

    +
    +
    + + scheduler + + +
    +

    A Scheduler. By default, fresh values are +dispatched asynchronously on the main queue.

    +
    +
    +
    +
    +

    Return Value

    +

    A Combine publisher

    +
    + +
    +
    +
  • +
  • +
    + + + + map(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a ValueObservation which notifies the results of calling the +given transformation which each element notified by this +value observation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func map<T>(_ transform: @escaping (Reducer.Value) -> T)
    +-> ValueObservation<ValueReducers.Map<Reducer, T>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Creating ValueObservation +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates an optimized ValueObservation that notifies the values +returned by the fetch function whenever a database transaction +changes them.

    + +

    The optimization only kicks in when the observation is started from a +DatabasePool: fresh values are fetched concurrently, and do not block +database writes.

    +
    +

    Precondition

    + The fetch function must perform requests that fetch +from a single and constant database region. The tracked region is made +of tables, columns, and, when possible, rowids of individual rows. All +changes that happen outside of this region do not impact +the observation. + +
    + +

    For example:

    +
    // Tracks the full 'player' table
    +let observation = ValueObservation.trackingConstantRegion { db -> [Player] in
    +    try Player.fetchAll(db)
    +}
    +
    +// Tracks the row with id 42 in the 'player' table
    +let observation = ValueObservation.trackingConstantRegion { db -> Player? in
    +    try Player.fetchOne(db, key: 42)
    +}
    +
    +// Tracks the 'score' column in the 'player' table
    +let observation = ValueObservation.trackingConstantRegion { db -> Int? in
    +    try Player.select(max(Column("score"))).fetchOne(db)
    +}
    +
    +// Tracks both the 'player' and 'team' tables
    +let observation = ValueObservation.trackingConstantRegion { db -> ([Team], [Player]) in
    +    let teams = try Team.fetchAll(db)
    +    let players = try Player.fetchAll(db)
    +    return (teams, players)
    +}
    +
    + +

    When you want to observe a varying database region, make sure you use +the ValueObservation.tracking(_:) method instead, or else some changes +will not be notified.

    + +

    For example, consider those three observations below that depend on some +user preference. They all track a varying region, and must +use ValueObservation.tracking(_:):

    +
    // Does not always track the same row in the player table.
    +let observation = ValueObservation.tracking { db -> Player? in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    return try Player.fetchOne(db, key: pref.favoritePlayerId)
    +}
    +
    +// Only tracks the 'user' table if there are some blocked emails.
    +let observation = ValueObservation.tracking { db -> [User] in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    let blockedEmails = pref.blockedEmails
    +    return try User.filter(blockedEmails.contains(Column("email"))).fetchAll(db)
    +}
    +
    +// Sometimes tracks the 'food' table, and sometimes the 'beverage' table.
    +let observation = ValueObservation.tracking { db -> Int in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    switch pref.selection {
    +    case .food: return try Food.fetchCount(db)
    +    case .beverage: return try Beverage.fetchCount(db)
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func trackingConstantRegion<Value>(
    +    _ fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction has an impact on the +given regions.

    + +

    The tracked region is not automatically inferred from the requests +performed in the fetch function.

    + +

    For example:

    +
    // Tracks the full database
    +let observation = ValueObservation.tracking
    +    region: .fullDatabase,
    +    fetch: { db in ... })
    +
    +// Tracks the full 'player' table
    +let observation = ValueObservation.tracking
    +    region: Player.all(),
    +    fetch: { db in ... })
    +
    +// Tracks the row with id 42 in the 'player' table
    +let observation = ValueObservation.tracking
    +    region: Player.filter(id: 42),
    +    fetch: { db in ... })
    +
    +// Tracks the 'score' column in the 'player' table
    +let observation = ValueObservation.tracking
    +    region: Player.select(max(Column("score")),
    +    fetch: { db in ... })
    +
    +// Tracks both the 'player' and 'team' tables
    +let observation = ValueObservation.tracking
    +    region: Player.all(), Team.all(),
    +    fetch: { db in ... })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tracking<Value>(
    +    region: DatabaseRegionConvertible...,
    +    fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + region + + +
    +

    A list of observed regions.

    +
    +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction has an impact on the +given regions.

    + +

    The tracked region is not automatically inferred from the requests +performed in the fetch function.

    + +

    For example:

    +
    // Tracks the full database
    +let observation = ValueObservation.tracking
    +    regions: [.fullDatabase],
    +    fetch: { db in ... })
    +
    +// Tracks the full 'player' table
    +let observation = ValueObservation.tracking
    +    regions: [Player.all()],
    +    fetch: { db in ... })
    +
    +// Tracks the row with id 42 in the 'player' table
    +let observation = ValueObservation.tracking
    +    regions: [Player.filter(id: 42)],
    +    fetch: { db in ... })
    +
    +// Tracks the 'score' column in the 'player' table
    +let observation = ValueObservation.tracking
    +    regions: [Player.select(max(Column("score"))],
    +    fetch: { db in ... })
    +
    +// Tracks both the 'player' and 'team' tables
    +let observation = ValueObservation.tracking
    +    regions: [Player.all(), Team.all()],
    +    fetch: { db in ... })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tracking<Value>(
    +    regions: [DatabaseRegionConvertible],
    +    fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + regions + + +
    +

    A list of observed regions.

    +
    +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + tracking(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction changes them.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tracking<Value>(
    +    _ fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction changes them.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "tracking(_:﹚")
    +public static func trackingVaryingRegion<Value>(
    +    _ fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Reducer.Value: Equatable +

+
+
+
    +
  • +
    + + + + removeDuplicates() + +
    +
    +
    +
    +
    +
    +

    Returns a ValueObservation which filters out consecutive equal values.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func removeDuplicates()
    +-> ValueObservation<ValueReducers.RemoveDuplicates<Reducer>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/Typealiases.html b/docs/5.16/Typealiases.html new file mode 100644 index 000000000..a306b3ce4 --- /dev/null +++ b/docs/5.16/Typealiases.html @@ -0,0 +1,1358 @@ + + + + Type Aliases Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Type Aliases

+

The following type aliases are available globally.

+ +
+
+
+
    +
  • +
    + + + + SQLiteConnection + +
    +
    +
    +
    +
    +
    +

    A raw SQLite connection, suitable for the SQLite C API.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLiteConnection = OpaquePointer
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLiteStatement + +
    +
    +
    +
    +
    +
    +

    A raw SQLite statement, suitable for the SQLite C API.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLiteStatement = OpaquePointer
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SelectStatement + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SelectStatement = Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + UpdateStatement + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias UpdateStatement = Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5TokenCallback + +
    +
    +
    +
    +
    +
    +

    A low-level SQLite function that lets FTS5Tokenizer notify tokens.

    + +

    See FTS5Tokenizer.tokenize(context:flags:pText:nText:tokenCallback:)

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A function that lets FTS5WrapperTokenizer notify tokens.

    + +

    See FTS5WrapperTokenizer.accept(token:flags:tokenCallback:)

    + +
    +
    +
    +
  • +
  • +
    + + + + SQLLiteral + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLLiteral = SQL
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLiteral + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLiteral = SQL
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLAssociativeBinaryOperator = SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/badge.svg b/docs/5.16/badge.svg new file mode 100644 index 000000000..b28dab66c --- /dev/null +++ b/docs/5.16/badge.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + documentation + + + documentation + + + 89% + + + 89% + + + diff --git a/docs/5.16/css/highlight.css b/docs/5.16/css/highlight.css new file mode 100644 index 000000000..c170357ce --- /dev/null +++ b/docs/5.16/css/highlight.css @@ -0,0 +1,202 @@ +/*! Jazzy - https://github.com/realm/jazzy + * Copyright Realm Inc. + * SPDX-License-Identifier: MIT + */ +/* Credit to https://gist.github.com/wataru420/2048287 */ +.highlight .c { + color: #999988; + font-style: italic; } + +.highlight .err { + color: #a61717; + background-color: #e3d2d2; } + +.highlight .k { + color: #000000; + font-weight: bold; } + +.highlight .o { + color: #000000; + font-weight: bold; } + +.highlight .cm { + color: #999988; + font-style: italic; } + +.highlight .cp { + color: #999999; + font-weight: bold; } + +.highlight .c1 { + color: #999988; + font-style: italic; } + +.highlight .cs { + color: #999999; + font-weight: bold; + font-style: italic; } + +.highlight .gd { + color: #000000; + background-color: #ffdddd; } + +.highlight .gd .x { + color: #000000; + background-color: #ffaaaa; } + +.highlight .ge { + color: #000000; + font-style: italic; } + +.highlight .gr { + color: #aa0000; } + +.highlight .gh { + color: #999999; } + +.highlight .gi { + color: #000000; + background-color: #ddffdd; } + +.highlight .gi .x { + color: #000000; + background-color: #aaffaa; } + +.highlight .go { + color: #888888; } + +.highlight .gp { + color: #555555; } + +.highlight .gs { + font-weight: bold; } + +.highlight .gu { + color: #aaaaaa; } + +.highlight .gt { + color: #aa0000; } + +.highlight .kc { + color: #000000; + font-weight: bold; } + +.highlight .kd { + color: #000000; + font-weight: bold; } + +.highlight .kp { + color: #000000; + font-weight: bold; } + +.highlight .kr { + color: #000000; + font-weight: bold; } + +.highlight .kt { + color: #445588; } + +.highlight .m { + color: #009999; } + +.highlight .s { + color: #d14; } + +.highlight .na { + color: #008080; } + +.highlight .nb { + color: #0086B3; } + +.highlight .nc { + color: #445588; + font-weight: bold; } + +.highlight .no { + color: #008080; } + +.highlight .ni { + color: #800080; } + +.highlight .ne { + color: #990000; + font-weight: bold; } + +.highlight .nf { + color: #990000; } + +.highlight .nn { + color: #555555; } + +.highlight .nt { + color: #000080; } + +.highlight .nv { + color: #008080; } + +.highlight .ow { + color: #000000; + font-weight: bold; } + +.highlight .w { + color: #bbbbbb; } + +.highlight .mf { + color: #009999; } + +.highlight .mh { + color: #009999; } + +.highlight .mi { + color: #009999; } + +.highlight .mo { + color: #009999; } + +.highlight .sb { + color: #d14; } + +.highlight .sc { + color: #d14; } + +.highlight .sd { + color: #d14; } + +.highlight .s2 { + color: #d14; } + +.highlight .se { + color: #d14; } + +.highlight .sh { + color: #d14; } + +.highlight .si { + color: #d14; } + +.highlight .sx { + color: #d14; } + +.highlight .sr { + color: #009926; } + +.highlight .s1 { + color: #d14; } + +.highlight .ss { + color: #990073; } + +.highlight .bp { + color: #999999; } + +.highlight .vc { + color: #008080; } + +.highlight .vg { + color: #008080; } + +.highlight .vi { + color: #008080; } + +.highlight .il { + color: #009999; } diff --git a/docs/5.16/css/jazzy.css b/docs/5.16/css/jazzy.css new file mode 100644 index 000000000..2e3871391 --- /dev/null +++ b/docs/5.16/css/jazzy.css @@ -0,0 +1,439 @@ +/*! Jazzy - https://github.com/realm/jazzy + * Copyright Realm Inc. + * SPDX-License-Identifier: MIT + */ +html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td { + background: transparent; + border: 0; + margin: 0; + outline: 0; + padding: 0; + vertical-align: baseline; } + +body { + background-color: #f2f2f2; + font-family: Helvetica, freesans, Arial, sans-serif; + font-size: 14px; + -webkit-font-smoothing: subpixel-antialiased; + word-wrap: break-word; } + +h1, h2, h3 { + margin-top: 0.8em; + margin-bottom: 0.3em; + font-weight: 100; + color: black; } + +h1 { + font-size: 2.5em; } + +h2 { + font-size: 2em; + border-bottom: 1px solid #e2e2e2; } + +h4 { + font-size: 13px; + line-height: 1.5; + margin-top: 21px; } + +h5 { + font-size: 1.1em; } + +h6 { + font-size: 1.1em; + color: #777; } + +.section-name { + color: gray; + display: block; + font-family: Helvetica; + font-size: 22px; + font-weight: 100; + margin-bottom: 15px; } + +pre, code { + font: 0.95em Menlo, monospace; + color: #777; + word-wrap: normal; } + +p code, li code { + background-color: #eee; + padding: 2px 4px; + border-radius: 4px; } + +pre > code { + padding: 0; } + +a { + color: #0088cc; + text-decoration: none; } + a code { + color: inherit; } + +ul { + padding-left: 15px; } + +li { + line-height: 1.8em; } + +img { + max-width: 100%; } + +blockquote { + margin-left: 0; + padding: 0 10px; + border-left: 4px solid #ccc; } + +hr { + height: 1px; + border: none; + background-color: #e2e2e2; } + +.footnote-ref { + display: inline-block; + scroll-margin-top: 70px; } + +.footnote-def { + scroll-margin-top: 70px; } + +.content-wrapper { + margin: 0 auto; + width: 980px; } + +header { + font-size: 0.85em; + line-height: 32px; + background-color: #414141; + position: fixed; + width: 100%; + z-index: 3; } + header img { + padding-right: 6px; + vertical-align: -3px; + height: 16px; } + header a { + color: #fff; } + header p { + float: left; + color: #999; } + header .header-right { + float: right; + margin-left: 16px; } + +#breadcrumbs { + background-color: #f2f2f2; + height: 21px; + padding-top: 17px; + position: fixed; + width: 100%; + z-index: 2; + margin-top: 32px; } + #breadcrumbs #carat { + height: 10px; + margin: 0 5px; } + +.sidebar { + background-color: #f9f9f9; + border: 1px solid #e2e2e2; + overflow-y: auto; + overflow-x: hidden; + position: fixed; + top: 70px; + bottom: 0; + width: 230px; + word-wrap: normal; } + +.nav-groups { + list-style-type: none; + background: #fff; + padding-left: 0; } + +.nav-group-name { + border-bottom: 1px solid #e2e2e2; + font-size: 1.1em; + font-weight: 100; + padding: 15px 0 15px 20px; } + .nav-group-name > a { + color: #333; } + +.nav-group-tasks { + margin-top: 5px; } + +.nav-group-task { + font-size: 0.9em; + list-style-type: none; + white-space: nowrap; } + .nav-group-task a { + color: #888; } + +.main-content { + background-color: #fff; + border: 1px solid #e2e2e2; + margin-left: 246px; + position: absolute; + overflow: hidden; + padding-bottom: 20px; + top: 70px; + width: 734px; } + .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote { + margin-bottom: 1em; } + .main-content p { + line-height: 1.8em; } + .main-content section .section:first-child { + margin-top: 0; + padding-top: 0; } + .main-content section .task-group-section .task-group:first-of-type { + padding-top: 10px; } + .main-content section .task-group-section .task-group:first-of-type .section-name { + padding-top: 15px; } + .main-content section .heading:before { + content: ""; + display: block; + padding-top: 70px; + margin: -70px 0 0; } + .main-content .section-name p { + margin-bottom: inherit; + line-height: inherit; } + .main-content .section-name code { + background-color: inherit; + padding: inherit; + color: inherit; } + +.section { + padding: 0 25px; } + +.highlight { + background-color: #eee; + padding: 10px 12px; + border: 1px solid #e2e2e2; + border-radius: 4px; + overflow-x: auto; } + +.declaration .highlight { + overflow-x: initial; + padding: 0 40px 40px 0; + margin-bottom: -25px; + background-color: transparent; + border: none; } + +.section-name { + margin: 0; + margin-left: 18px; } + +.task-group-section { + margin-top: 10px; + padding-left: 6px; + border-top: 1px solid #e2e2e2; } + +.task-group { + padding-top: 0px; } + +.task-name-container a[name]:before { + content: ""; + display: block; + padding-top: 70px; + margin: -70px 0 0; } + +.section-name-container { + position: relative; + display: inline-block; } + .section-name-container .section-name-link { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + margin-bottom: 0; } + .section-name-container .section-name { + position: relative; + pointer-events: none; + z-index: 1; } + .section-name-container .section-name a { + pointer-events: auto; } + +.item { + padding-top: 8px; + width: 100%; + list-style-type: none; } + .item a[name]:before { + content: ""; + display: block; + padding-top: 70px; + margin: -70px 0 0; } + .item code { + background-color: transparent; + padding: 0; } + .item .token, .item .direct-link { + display: inline-block; + text-indent: -20px; + padding-left: 3px; + margin-left: 35px; + font-size: 11.9px; + transition: all 300ms; } + .item .token-open { + margin-left: 20px; } + .item .discouraged { + text-decoration: line-through; } + .item .declaration-note { + font-size: .85em; + color: gray; + font-style: italic; } + +.pointer-container { + border-bottom: 1px solid #e2e2e2; + left: -23px; + padding-bottom: 13px; + position: relative; + width: 110%; } + +.pointer { + background: #f9f9f9; + border-left: 1px solid #e2e2e2; + border-top: 1px solid #e2e2e2; + height: 12px; + left: 21px; + top: -7px; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + position: absolute; + width: 12px; } + +.height-container { + display: none; + left: -25px; + padding: 0 25px; + position: relative; + width: 100%; + overflow: hidden; } + .height-container .section { + background: #f9f9f9; + border-bottom: 1px solid #e2e2e2; + left: -25px; + position: relative; + width: 100%; + padding-top: 10px; + padding-bottom: 5px; } + +.aside, .language { + padding: 6px 12px; + margin: 12px 0; + border-left: 5px solid #dddddd; + overflow-y: hidden; } + .aside .aside-title, .language .aside-title { + font-size: 9px; + letter-spacing: 2px; + text-transform: uppercase; + padding-bottom: 0; + margin: 0; + color: #aaa; + -webkit-user-select: none; } + .aside p:last-child, .language p:last-child { + margin-bottom: 0; } + +.language { + border-left: 5px solid #cde9f4; } + .language .aside-title { + color: #4b8afb; } + +.aside-warning, .aside-deprecated, .aside-unavailable { + border-left: 5px solid #ff6666; } + .aside-warning .aside-title, .aside-deprecated .aside-title, .aside-unavailable .aside-title { + color: #ff0000; } + +.graybox { + border-collapse: collapse; + width: 100%; } + .graybox p { + margin: 0; + word-break: break-word; + min-width: 50px; } + .graybox td { + border: 1px solid #e2e2e2; + padding: 5px 25px 5px 10px; + vertical-align: middle; } + .graybox tr td:first-of-type { + text-align: right; + padding: 7px; + vertical-align: top; + word-break: normal; + width: 40px; } + +.slightly-smaller { + font-size: 0.9em; } + +#footer { + position: relative; + top: 10px; + bottom: 0px; + margin-left: 25px; } + #footer p { + margin: 0; + color: #aaa; + font-size: 0.8em; } + +html.dash header, html.dash #breadcrumbs, html.dash .sidebar { + display: none; } + +html.dash .main-content { + width: 980px; + margin-left: 0; + border: none; + width: 100%; + top: 0; + padding-bottom: 0; } + +html.dash .height-container { + display: block; } + +html.dash .item .token { + margin-left: 0; } + +html.dash .content-wrapper { + width: auto; } + +html.dash #footer { + position: static; } + +form[role=search] { + float: right; } + form[role=search] input { + font: Helvetica, freesans, Arial, sans-serif; + margin-top: 6px; + font-size: 13px; + line-height: 20px; + padding: 0px 10px; + border: none; + border-radius: 1em; } + .loading form[role=search] input { + background: white url(../img/spinner.gif) center right 4px no-repeat; } + form[role=search] .tt-menu { + margin: 0; + min-width: 300px; + background: #fff; + color: #333; + border: 1px solid #e2e2e2; + z-index: 4; } + form[role=search] .tt-highlight { + font-weight: bold; } + form[role=search] .tt-suggestion { + font: Helvetica, freesans, Arial, sans-serif; + font-size: 14px; + padding: 0 8px; } + form[role=search] .tt-suggestion span { + display: table-cell; + white-space: nowrap; } + form[role=search] .tt-suggestion .doc-parent-name { + width: 100%; + text-align: right; + font-weight: normal; + font-size: 0.9em; + padding-left: 16px; } + form[role=search] .tt-suggestion:hover, + form[role=search] .tt-suggestion.tt-cursor { + cursor: pointer; + background-color: #4183c4; + color: #fff; } + form[role=search] .tt-suggestion:hover .doc-parent-name, + form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { + color: #fff; } diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Info.plist b/docs/5.16/docsets/GRDB.docset/Contents/Info.plist new file mode 100644 index 000000000..cef6e7d04 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleIdentifier + com.jazzy.grdb + CFBundleName + GRDB + DocSetPlatformFamily + grdb + isDashDocset + + dashIndexFilePath + index.html + isJavaScriptEnabled + + DashDocSetFamily + dashtoc + DashDocSetFallbackURL + http://groue.github.io/GRDB.swift/docs/5.16/ + + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes.html new file mode 100644 index 000000000..a2c145259 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes.html @@ -0,0 +1,2358 @@ + + + + Classes Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Classes

+

The following classes are available globally.

+ +
+
+
+
+ + +
+ +

Specialized Cursors +

+
+
+
    +
  • +
    + + + + AnyCursor + +
    +
    +
    +
    +
    +
    +

    A type-erased cursor of Element.

    + +

    This cursor forwards its next() method to an arbitrary underlying cursor +having the same Element type, hiding the specifics of the underlying +cursor.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class AnyCursor<Element> : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Database + +
    +
    +
    +
    +
    +
    +

    A Database connection.

    + +

    You don’t create a database directly. Instead, you use a DatabaseQueue, or +a DatabasePool:

    +
    let dbQueue = DatabaseQueue(...)
    +
    +// The Database is the `db` in the closure:
    +try dbQueue.write { db in
    +    try Player(...).insert(db)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class Database : CustomStringConvertible, CustomDebugStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLStatementCursor + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class SQLStatementCursor : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseCollation + +
    +
    +
    +
    +
    +
    +

    A Collation is a string comparison function used by SQLite.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseCollation
    +
    extension DatabaseCollation: Hashable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseFunction + +
    +
    +
    +
    +
    +
    +

    An SQL function or aggregate.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseFunction : Hashable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabasePool + +
    +
    +
    +
    +
    +
    +

    A DatabasePool grants concurrent accesses to an SQLite database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabasePool : DatabaseWriter
    +
    extension DatabasePool: DatabaseReader
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseQueue + +
    +
    +
    +
    +
    +
    +

    A DatabaseQueue serializes access to an SQLite database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseQueue : DatabaseWriter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + AnyDatabaseReader + +
    +
    +
    +
    +
    +
    +

    A type-erased DatabaseReader

    + +

    Instances of AnyDatabaseReader forward their methods to an arbitrary +underlying database reader.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class AnyDatabaseReader : DatabaseReader
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseSnapshot + +
    +
    +
    +
    +
    +
    +

    A DatabaseSnapshot sees an unchanging database content, as it existed at the +moment it was created.

    + +

    See DatabasePool.makeSnapshot()

    + +

    For more information, read about “snapshot isolation” at https://sqlite.org/isolation.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class DatabaseSnapshot : DatabaseReader
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Cursors +

+
+
+
    +
  • +
    + + + + DatabaseValueCursor + +
    +
    +
    +
    +
    +
    +

    A cursor of database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let urls: DatabaseValueCursor<URL> = try URL.fetchCursor(db, sql: "SELECT url FROM link")
    +    while let url = urls.next() { // URL
    +        print(url)
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class DatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A cursor of optional database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let urls: NullableDatabaseValueCursor<URL> = try Optional<URL>.fetchCursor(db, sql: "SELECT url FROM link")
    +    while let url = urls.next() { // URL?
    +        print(url)
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class NullableDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseFuture + +
    +
    +
    +
    +
    +
    +

    A future database value, returned by the DatabaseWriter.concurrentRead(_:) +method.

    +
    let futureCount: Future<Int> = try writer.writeWithoutTransaction { db in
    +    try Player(...).insert()
    +
    +    // Count players concurrently
    +    return writer.concurrentRead { db in
    +        return try Player.fetchCount()
    +    }
    +}
    +
    +let count: Int = try futureCount.wait()
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class DatabaseFuture<Value>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + AnyDatabaseWriter + +
    +
    +
    +
    +
    +
    +

    A type-erased DatabaseWriter

    + +

    Instances of AnyDatabaseWriter forward their methods to an arbitrary +underlying database writer.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class AnyDatabaseWriter : DatabaseWriter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Row + +
    +
    +
    +
    +
    +
    +

    A database row.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class Row: Equatable, Hashable, RandomAccessCollection,
    +                        ExpressibleByDictionaryLiteral, CustomStringConvertible,
    +                        CustomDebugStringConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

RowCursor +

+
+
+
    +
  • +
    + + + + RowCursor + +
    +
    +
    +
    +
    +
    +

    A cursor of database rows. For example:

    +
    try dbQueue.read { db in
    +    let rows: RowCursor = try Row.fetchCursor(db, sql: "SELECT * FROM player")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class RowCursor : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Statement + +
    +
    +
    +
    +
    +
    +

    A statement represents an SQL query.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class Statement
    +
    extension Statement: _RowLayout
    +
    extension Statement: CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Cursors +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    A cursor of database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let names: ColumnCursor<String> = try String.fetchCursor(db, sql: "SELECT name FROM player")
    +    while let name = names.next() { // String
    +        print(name)
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FastDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible, Value : StatementColumnConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A cursor of optional database values extracted from a single column. +For example:

    +
    try dbQueue.read { db in
    +    let emails: FastNullableDatabaseValueCursor<String> =
    +        try Optional<String>.fetchCursor(db, sql: "SELECT email FROM player")
    +    while let email = emails.next() { // String?
    +        print(email ?? "<NULL>")
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FastNullableDatabaseValueCursor<Value>: Cursor
    +where Value: DatabaseValueConvertible & StatementColumnConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS3TableDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS3TableDefinition class lets you define columns of a FTS3 virtual table.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "document", using: FTS3()) { t in // t is FTS3TableDefinition
    +    t.column("content")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FTS3TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS4TableDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS4TableDefinition class lets you define columns of a FTS4 virtual table.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in // t is FTS4TableDefinition
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FTS4TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS4ColumnDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS4ColumnDefinition class lets you refine a column of an FTS4 +virtual table.

    + +

    You get instances of this class when you create an FTS4 table:

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("content")      // FTS4ColumnDefinition
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class FTS4ColumnDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5TableDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "document", using: FTS5()) { t in // t is FTS5TableDefinition
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5ColumnDefinition + +
    +
    +
    +
    +
    +
    +

    The FTS5ColumnDefinition class lets you refine a column of an FTS5 +virtual table.

    + +

    You get instances of this class when you create an FTS5 table:

    +
    try db.create(virtualTable: "document", using: FTS5()) { t in
    +    t.column("content")      // FTS5ColumnDefinition
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

TableAlias +

+
+
+
    +
  • +
    + + + + TableAlias + +
    +
    +
    +
    +
    +
    +

    Experimental

    + +

    A TableAlias identifies a table in a request.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class TableAlias : Hashable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + TableDefinition + +
    +
    +
    +
    +
    +
    +

    The TableDefinition class lets you define table columns and constraints.

    + +

    You don’t create instances of this class. Instead, you use the Database +create(table:) method:

    +
    try db.create(table: "player") { t in // t is TableDefinition
    +    t.column(...)
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + TableAlteration + +
    +
    +
    +
    +
    +
    +

    The TableAlteration class lets you alter database tables.

    + +

    You don’t create instances of this class. Instead, you use the Database +alter(table:) method:

    +
    try db.alter(table: "player") { t in // t is TableAlteration
    +    t.add(column: ...)
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class TableAlteration
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnDefinition + +
    +
    +
    +
    +
    +
    +

    The ColumnDefinition class lets you refine a table column.

    + +

    You get instances of this class when you create or alter a database table:

    +
    try db.create(table: "player") { t in
    +    t.column(...)      // ColumnDefinition
    +}
    +
    +try db.alter(table: "player") { t in
    +    t.add(column: ...) // ColumnDefinition
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html and +https://www.sqlite.org/lang_altertable.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class ColumnDefinition
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

RecordCursor +

+
+
+
    +
  • +
    + + + + RecordCursor + +
    +
    +
    +
    +
    +
    +

    A cursor of records. For example:

    +
    struct Player : FetchableRecord { ... }
    +try dbQueue.read { db in
    +    let players: RecordCursor<Player> = try Player.fetchCursor(db, sql: "SELECT * FROM player")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class RecordCursor<Record> : Cursor where Record : FetchableRecord
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Record +

+
+
+
    +
  • +
    + + + + Record + +
    +
    +
    +
    +
    +
    +

    Record is a class that wraps a table row, or the result of any query. It is +designed to be subclassed.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class Record : FetchableRecord, TableRecord, PersistableRecord
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A type-erasing cancellable object that executes a provided closure +when canceled.

    + +

    An AnyDatabaseCancellable instance automatically calls cancel() + when deinitialized.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class AnyDatabaseCancellable : DatabaseCancellable
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Experimental

    + +

    A shared value observation that shares a single underlying database +observation for all subscriptions, and thus spares database resources.

    + +

    For example:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +
    +let cancellable = try sharedObservation.start(
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed.")
    +    })
    +
    + +

    The sharing only applies if you start observing the database from the +same SharedValueObservation instance:

    +
    // NOT shared
    +let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +
    +// Shared
    +let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
    +let cancellable1 = sharedObservation.start(...)
    +let cancellable2 = sharedObservation.start(...)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final class SharedValueObservation<Element>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    ValueObservationScheduler determines how ValueObservation notifies its +fresh values.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public class ValueObservationScheduler
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyCursor.html new file mode 100644 index 000000000..2e21577bf --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyCursor.html @@ -0,0 +1,1272 @@ + + + + AnyCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyCursor

+
+
+ +
public final class AnyCursor<Element> : Cursor
+ +
+
+

A type-erased cursor of Element.

+ +

This cursor forwards its next() method to an arbitrary underlying cursor +having the same Element type, hiding the specifics of the underlying +cursor.

+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps a base cursor but whose type depends only on +the base cursor’s element type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ base: C) where Element == C.Element, C : Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(iterator:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps a base iterator but whose type depends only +on the base iterator’s element type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init<I>(iterator: I) where Element == I.Element, I : IteratorProtocol
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps a base sequence but whose type depends only +on the base sequence’s element type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init<S>(_ s: S) where Element == S.Element, S : Sequence
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a cursor that wraps the given closure in its next() method

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ body: @escaping () throws -> Element?)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Element?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseCancellable.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseCancellable.html new file mode 100644 index 000000000..2c25ee310 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseCancellable.html @@ -0,0 +1,1210 @@ + + + + AnyDatabaseCancellable Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseCancellable

+
+
+ +
public class AnyDatabaseCancellable : DatabaseCancellable
+ +
+
+

A type-erasing cancellable object that executes a provided closure +when canceled.

+ +

An AnyDatabaseCancellable instance automatically calls cancel() + when deinitialized.

+ + +
+
+
+
    +
  • +
    + + + + init(cancel:) + +
    +
    +
    +
    +
    +
    +

    Initializes the cancellable object with the given cancel-time closure.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(cancel: @escaping () -> Void)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Initializes a cancellable object that forwards cancellation to the +provided cancellable.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(_ cancellable: DatabaseCancellable)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + cancel() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func cancel()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseReader.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseReader.html new file mode 100644 index 000000000..235518ed8 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseReader.html @@ -0,0 +1,1378 @@ + + + + AnyDatabaseReader Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseReader

+
+
+ +
public final class AnyDatabaseReader : DatabaseReader
+ +
+
+

A type-erased DatabaseReader

+ +

Instances of AnyDatabaseReader forward their methods to an arbitrary +underlying database reader.

+ + +
+
+
+ +
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseWriter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseWriter.html new file mode 100644 index 000000000..832069807 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/AnyDatabaseWriter.html @@ -0,0 +1,1625 @@ + + + + AnyDatabaseWriter Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseWriter

+
+
+ +
public final class AnyDatabaseWriter : DatabaseWriter
+ +
+
+

A type-erased DatabaseWriter

+ +

Instances of AnyDatabaseWriter forward their methods to an arbitrary +underlying database writer.

+ + +
+
+
+ +
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ + +
+ +

Writing in Database +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ColumnDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ColumnDefinition.html new file mode 100644 index 000000000..03f13d8a6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ColumnDefinition.html @@ -0,0 +1,1868 @@ + + + + ColumnDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnDefinition

+
+
+ +
public final class ColumnDefinition
+ +
+
+

The ColumnDefinition class lets you refine a table column.

+ +

You get instances of this class when you create or alter a database table:

+
try db.create(table: "player") { t in
+    t.column(...)      // ColumnDefinition
+}
+
+try db.alter(table: "player") { t in
+    t.add(column: ...) // ColumnDefinition
+}
+
+ +

See https://www.sqlite.org/lang_createtable.html and +https://www.sqlite.org/lang_altertable.html

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    The GeneratedColumnQualification enum defines whether a generated +column sis virtual or stored.

    + +

    See https://sqlite.org/gencol.html#virtual_versus_stored_columns

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum GeneratedColumnQualification
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Adds a primary key constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("id", .integer).primaryKey()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#primkeyconst and +https://www.sqlite.org/lang_createtable.html#rowid

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func primaryKey(
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    autoincrement: Bool = false)
    +-> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    + + autoincrement + + +
    +

    If true, the primary key is autoincremented.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + notNull(onConflict:) + +
    +
    +
    +
    +
    +
    +

    Adds a NOT NULL constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).notNull()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#notnullconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func notNull(onConflict conflictResolution: Database.ConflictResolution? = nil) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + unique(onConflict:) + +
    +
    +
    +
    +
    +
    +

    Adds a UNIQUE constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("email", .text).unique()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#uniqueconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func unique(onConflict conflictResolution: Database.ConflictResolution? = nil) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + indexed() + +
    +
    +
    +
    +
    +
    +

    Adds an index of the column.

    +
    try db.create(table: "player") { t in
    +    t.column("email", .text).indexed()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#uniqueconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func indexed() -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + check(_:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).check { length($0) > 0 }
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func check(_ condition: (Column) -> SQLExpressible) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + condition + + +
    +

    A closure whose argument is an Column that +represents the defined column, and returns the expression to check.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + check(sql:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint on the column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).check(sql: "LENGTH(name) > 0")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func check(sql: String) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL snippet.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + defaults(to:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column value.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).defaults(to: "Anonymous")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#dfltval

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func defaults(to value: DatabaseValueConvertible) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A DatabaseValueConvertible value.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + defaults(sql:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column value.

    +
    try db.create(table: "player") { t in
    +    t.column("creationDate", .DateTime).defaults(sql: "CURRENT_TIMESTAMP")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#dfltval

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func defaults(sql: String) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL snippet.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + collate(_:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column collation.

    +
    try db.create(table: "player") { t in
    +    t.column("email", .text).collate(.nocase)
    +}
    +
    + +

    See https://www.sqlite.org/datatype3.html#collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func collate(_ collation: Database.CollationName) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + collation + + +
    +

    An Database.CollationName.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + collate(_:) + +
    +
    +
    +
    +
    +
    +

    Defines the default column collation.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text).collate(.localizedCaseInsensitiveCompare)
    +}
    +
    + +

    See https://www.sqlite.org/datatype3.html#collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func collate(_ collation: DatabaseCollation) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + collation + + +
    +

    A custom DatabaseCollation.

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + generatedAs(sql:_:) + +
    +
    +
    +
    +
    +
    +

    Defines the column as a generated column.

    +
    try db.create(table: "player") { t in
    +    t.column("id", .integer).primaryKey()
    +    t.column("score", .integer).notNull()
    +    t.column("bonus", .integer).notNull()
    +    t.column("totalScore", .integer).generatedAs(sql: "score + bonus", .stored)
    +}
    +
    + +

    See https://sqlite.org/gencol.html. Note particularly the limitations of +generated columns, e.g. they may not have a default value.

    + +
    +
    +
    +
  • +
  • +
    + + + + generatedAs(_:_:) + +
    +
    +
    +
    +
    +
    +

    Defines the column as a generated column.

    +
    try db.create(table: "player") { t in
    +    t.column("id", .integer).primaryKey()
    +    t.column("score", .integer).notNull()
    +    t.column("bonus", .integer).notNull()
    +    t.column("totalScore", .integer).generatedAs(Column("score") + Column("bonus"), .stored)
    +}
    +
    + +

    See https://sqlite.org/gencol.html. Note particularly the limitations of +generated columns, e.g. they may not have a default value.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Defines a foreign key.

    +
    try db.create(table: "book") { t in
    +    t.column("authorId", .integer).references("author", onDelete: .cascade)
    +}
    +
    + +

    See https://www.sqlite.org/foreignkeys.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func references(
    +    _ table: String,
    +    column: String? = nil,
    +    onDelete deleteAction: Database.ForeignKeyAction? = nil,
    +    onUpdate updateAction: Database.ForeignKeyAction? = nil,
    +    deferred: Bool = false) -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ColumnDefinition/GeneratedColumnQualification.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ColumnDefinition/GeneratedColumnQualification.html new file mode 100644 index 000000000..32aa23d3c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ColumnDefinition/GeneratedColumnQualification.html @@ -0,0 +1,1179 @@ + + + + GeneratedColumnQualification Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

GeneratedColumnQualification

+
+
+ +
public enum GeneratedColumnQualification
+ +
+
+

The GeneratedColumnQualification enum defines whether a generated +column sis virtual or stored.

+ +

See https://sqlite.org/gencol.html#virtual_versus_stored_columns

+ + +
+
+
+
    +
  • +
    + + + + virtual + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case virtual
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + stored + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case stored
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database.html new file mode 100644 index 000000000..f67c67674 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database.html @@ -0,0 +1,5443 @@ + + + + Database Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Database

+
+
+ +
public final class Database : CustomStringConvertible, CustomDebugStringConvertible
+ +
+
+

A Database connection.

+ +

You don’t create a database directly. Instead, you use a DatabaseQueue, or +a DatabasePool:

+
let dbQueue = DatabaseQueue(...)
+
+// The Database is the `db` in the closure:
+try dbQueue.write { db in
+    try Player(...).insert(db)
+}
+
+ + +
+
+
+
+ + +
+ +

SQLite C API +

+
+
+
    +
  • +
    + + + + sqliteConnection + +
    +
    +
    +
    +
    +
    +

    The raw SQLite connection, suitable for the SQLite C API. +It is constant, until close() sets it to nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqliteConnection: SQLiteConnection?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Configuration +

+
+
+
    +
  • +
    + + + + logError + +
    +
    +
    +
    +
    +
    +

    The error logging function.

    + +

    Quoting https://www.sqlite.org/errlog.html:

    + +
    +

    SQLite can be configured to invoke a callback function containing an +error code and a terse error message whenever anomalies occur. This +mechanism is very helpful in tracking obscure problems that occur +rarely and in the field. Application developers are encouraged to take +advantage of the error logging facility of SQLite in their products, +as it is very low CPU and memory cost but can be a huge aid +for debugging.

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var logError: LogErrorFunction? { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let configuration: Configuration
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + description + +
    +
    +
    +
    +
    + +
    +

    Declaration

    +
    +

    Swift

    +
    public let description: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + debugDescription + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var debugDescription: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Information +

+
+
+
    +
  • +
    + + + + lastInsertedRowID + +
    +
    +
    +
    +
    +
    +

    The rowID of the most recently inserted row.

    + +

    If no row has ever been inserted using this database connection, +returns zero.

    + +

    For more detailed information, see https://www.sqlite.org/c3ref/last_insert_rowid.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var lastInsertedRowID: Int64 { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + changesCount + +
    +
    +
    +
    +
    +
    +

    The number of rows modified, inserted or deleted by the most recent +successful INSERT, UPDATE or DELETE statement.

    + +

    For more detailed information, see https://www.sqlite.org/c3ref/changes.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var changesCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + totalChangesCount + +
    +
    +
    +
    +
    +
    +

    The total number of rows modified, inserted or deleted by all successful +INSERT, UPDATE or DELETE statements since the database connection was +opened.

    + +

    For more detailed information, see https://www.sqlite.org/c3ref/total_changes.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var totalChangesCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isInsideTransaction + +
    +
    +
    +
    +
    +
    +

    True if the database connection is currently in a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isInsideTransaction: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lastErrorCode + +
    +
    +
    +
    +
    +
    +

    The last error code

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var lastErrorCode: ResultCode { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lastErrorMessage + +
    +
    +
    +
    +
    +
    +

    The last error message

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var lastErrorMessage: String? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Limits +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    The maximum number of arguments accepted by an SQLite statement.

    + +

    For example, requests such as the one below must make sure the ids +array does not contain more than maximumStatementArgumentCount +elements:

    +
    let ids: [Int] = ...
    +try dbQueue.write { db in
    +    try Player.deleteAll(db, keys: ids)
    +}
    +
    + +

    See https://www.sqlite.org/limits.html +and SQLITE_LIMIT_VARIABLE_NUMBER.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var maximumStatementArgumentCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Functions +

+
+
+
    +
  • +
    + + + + add(function:) + +
    +
    +
    +
    +
    +
    +

    Add or redefine an SQL function.

    +
    let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
    +    guard let int = Int.fromDatabaseValue(dbValues[0]) else {
    +        return nil
    +    }
    +    return int + 1
    +}
    +db.add(function: fn)
    +try Int.fetchOne(db, sql: "SELECT succ(1)")! // 2
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(function: DatabaseFunction)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove(function:) + +
    +
    +
    +
    +
    +
    +

    Remove an SQL function.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(function: DatabaseFunction)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Collations +

+
+
+
    +
  • +
    + + + + add(collation:) + +
    +
    +
    +
    +
    +
    +

    Add or redefine a collation.

    +
    let collation = DatabaseCollation("localized_standard") { (string1, string2) in
    +    return (string1 as NSString).localizedStandardCompare(string2)
    +}
    +db.add(collation: collation)
    +try db.execute(sql: "CREATE TABLE files (name TEXT COLLATE localized_standard")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(collation: DatabaseCollation)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove(collation:) + +
    +
    +
    +
    +
    +
    +

    Remove a collation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(collation: DatabaseCollation)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Trace +

+
+
+
    +
  • +
    + + + + trace(options:_:) + +
    +
    +
    +
    +
    +
    +

    Registers a tracing function.

    + +

    For example:

    +
    // Trace all SQL statements executed by the database
    +var configuration = Configuration()
    +configuration.prepareDatabase { db in
    +    db.trace(options: .statement) { event in
    +        print("SQL: \(event)")
    +    }
    +}
    +let dbQueue = try DatabaseQueue(path: "...", configuration: configuration)
    +
    + +

    Pass an empty options set in order to stop database tracing:

    +
    // Stop tracing
    +db.trace(options: [])
    +
    + +

    See https://www.sqlite.org/c3ref/trace_v2.html for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func trace(options: TracingOptions = .statement, _ trace: ((TraceEvent) -> Void)? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + options + + +
    +

    The set of desired event kinds. Defaults to +.statement, which notifies all executed database statements.

    +
    +
    + + trace + + +
    +

    the tracing function.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

WAL Checkpoints +

+
+
+
    +
  • +
    + + + + checkpoint(_:on:) + +
    +
    +
    +
    +
    +
    +

    Runs a WAL checkpoint.

    + +

    See https://www.sqlite.org/wal.html and +https://www.sqlite.org/c3ref/wal_checkpoint_v2.html for +more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func checkpoint(_ kind: Database.CheckpointMode = .passive, on dbName: String? = "main") throws
    +-> (walFrameCount: Int, checkpointedFrameCount: Int)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The checkpoint mode (default passive)

    +
    +
    + + dbName + + +
    +

    The database name (default “main”)

    +
    +
    +
    +
    +

    Return Value

    +

    A tuple: + +

      +
    • walFrameCount: the total number of frames in the log file
    • +
    • checkpointedFrameCount: the total number of checkpointed frames +in the log file
    • +

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Suspension +

+
+
+ +
+
+
+ + +
+ +

Transactions & Savepoint +

+
+
+
    +
  • +
    + + + + inTransaction(_:_:) + +
    +
    +
    +
    +
    +
    +

    Executes a block inside a database transaction.

    +
    try dbQueue.inDatabase do {
    +    try db.inTransaction {
    +        try db.execute(sql: "INSERT ...")
    +        return .commit
    +    }
    +}
    +
    + +

    If the block throws an error, the transaction is rollbacked and the +error is rethrown.

    + +

    This method is not reentrant: you can’t nest transactions.

    +
    +

    Throws

    + The error thrown by the block. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inTransaction(_ kind: TransactionKind? = nil, _ block: () throws -> TransactionCompletion) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the transaction +type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    + + block + + +
    +

    A block that executes SQL statements and return either +.commit or .rollback.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + inSavepoint(_:) + +
    +
    +
    +
    +
    +
    +

    Executes a block inside a savepoint.

    +
    try dbQueue.inDatabase do {
    +    try db.inSavepoint {
    +        try db.execute(sql: "INSERT ...")
    +        return .commit
    +    }
    +}
    +
    + +

    If the block throws an error, the savepoint is rollbacked and the +error is rethrown.

    + +

    This method is reentrant: you can nest savepoints.

    +
    +

    Throws

    + The error thrown by the block. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inSavepoint(_ block: () throws -> TransactionCompletion) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + block + + +
    +

    A block that executes SQL statements and return +either .commit or .rollback.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + beginTransaction(_:) + +
    +
    +
    +
    +
    +
    +

    Begins a database transaction.

    +
    +

    Throws

    + The error thrown by the block. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func beginTransaction(_ kind: TransactionKind? = nil) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the +transaction type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + rollback() + +
    +
    +
    +
    +
    +
    +

    Rollbacks a database transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func rollback() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + commit() + +
    +
    +
    +
    +
    +
    +

    Commits a database transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func commit() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Schema +

+
+
+
    +
  • +
    + + + + clearSchemaCache() + +
    +
    +
    +
    +
    +
    +

    Clears the database schema cache.

    + +

    You may need to clear the cache manually if the database schema is +modified by another connection.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func clearSchemaCache()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + tableExists(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a table exists in the main or temp schema.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func tableExists(_ name: String) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal SQLite table.

    + +

    Those are tables whose name begins with sqlite_ and pragma_.

    + +

    For more information, see https://www.sqlite.org/fileformat2.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func isSQLiteInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal SQLite table.

    + +

    Those are tables whose name begins with sqlite_ and pragma_.

    + +

    For more information, see https://www.sqlite.org/fileformat2.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Use Database.isSQLiteInternalTable(_:﹚ static method instead.")
    +public func isSQLiteInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal GRDB table.

    + +

    Those are tables whose name begins with “grdb_”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func isGRDBInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns whether a table is an internal GRDB table.

    + +

    Those are tables whose name begins with “grdb_”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Use Database.isGRDBInternalTable(_:﹚ static method instead.")
    +public func isGRDBInternalTable(_ tableName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + viewExists(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a view exists in the main or temp schema.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func viewExists(_ name: String) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + triggerExists(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a trigger exists in the main or temp schema.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func triggerExists(_ name: String) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + primaryKey(_:) + +
    +
    +
    +
    +
    +
    +

    The primary key for table named tableName.

    + +

    All tables have a primary key, even when it is not explicit. When a +table has no explicit primary key, the result is the hidden +“rowid” column.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func primaryKey(_ tableName: String) throws -> PrimaryKeyInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + indexes(on:) + +
    +
    +
    +
    +
    +
    +

    The indexes on table named tableName.

    + +

    Only indexes on columns are returned. Indexes on expressions are +not returned.

    + +

    SQLite does not define any index for INTEGER PRIMARY KEY columns: this +method does not return any index that represents the primary key.

    + +

    If you want to know if a set of columns uniquely identify a row, prefer +table(_:hasUniqueKey:) instead.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func indexes(on tableName: String) throws -> [IndexInfo]
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    True if a sequence of columns uniquely identifies a row, that is to say +if the columns are the primary key, or if there is a unique index on them.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func table<T: Sequence>(
    +    _ tableName: String,
    +    hasUniqueKey columns: T)
    +throws -> Bool
    +where T.Iterator.Element == String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + foreignKeys(on:) + +
    +
    +
    +
    +
    +
    +

    The foreign keys defined on table named tableName.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKeys(on tableName: String) throws -> [ForeignKeyInfo]
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over foreign key violations in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKeyViolations() throws -> RecordCursor<ForeignKeyViolation>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over foreign key violations in the table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKeyViolations(in tableName: String) throws -> RecordCursor<ForeignKeyViolation>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + checkForeignKeys() + +
    +
    +
    +
    +
    +
    +

    Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY +if there exists a foreign key violation in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func checkForeignKeys() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + checkForeignKeys(in:) + +
    +
    +
    +
    +
    +
    +

    Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY +if there exists a foreign key violation in the table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func checkForeignKeys(in tableName: String) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + columns(in:) + +
    +
    +
    +
    +
    +
    +

    The columns in the table named tableName.

    +
    +

    Throws

    + A DatabaseError if table does not exist. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func columns(in tableName: String) throws -> [ColumnInfo]
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Statements +

+
+
+
    +
  • +
    + + + + makeStatement(sql:) + +
    +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.makeStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makeStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeStatement(literal: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.makeStatement(literal: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try makeStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try makeStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try makeStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makeStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeSelectStatement(sql: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(sql:﹚")
    +public func makeSelectStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try makeSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try makeSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try makeSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(literal:﹚")
    +public func makeSelectStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • +
    + + + + cachedStatement(sql:) + +
    +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedStatement(sql: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.cachedStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    + +

    The returned statement may have already been used: it may or may not +contain values for its eventual arguments.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func cachedStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedStatement(literal: "SELECT * FROM player WHERE id = ?")
    +let player1 = try Player.fetchOne(statement, arguments: [1])!
    +let player2 = try Player.fetchOne(statement, arguments: [2])!
    +
    +let statement = try db.cachedStatement(literal: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try cachedStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try cachedStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try cachedStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func cachedStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedSelectStatement(sql: "SELECT COUNT(*) FROM player WHERE score > ?")
    +let moreThanTwentyCount = try Int.fetchOne(statement, arguments: [20])!
    +let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
    +
    + +

    The returned statement may have already been used: it may or may not +contain values for its eventual arguments.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(sql:﹚")
    +public func cachedSelectStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedSelectStatement(literal: "SELECT COUNT(*) FROM player WHERE score > \(20)")
    +let moreThanTwentyCount = try Int.fetchOne(statement)!
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try cachedSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > ?
    +    """)
    +try cachedSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player WHERE score > \(1000)
    +    """)
    +
    +// NOT OK
    +try cachedSelectStatement(literal: """
    +    SELECT COUNT(*) FROM player
    +    WHERE color = ? AND score > \(1000)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(literal:﹚")
    +public func cachedSelectStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    let statement = try db.makeUpdateStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(sql:﹚")
    +public func makeUpdateStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    An UpdateStatement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try makeUpdateStatement(literal: """
    +    UPDATE player SET name = ?
    +    """)
    +try makeUpdateStatement(literal: """
    +    UPDATE player SET name = \("O'Brien")
    +    """)
    +
    +// NOT OK
    +try makeUpdateStatement(literal: """
    +    UPDATE player SET name = ?, score = \(10)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "makeStatement(literal:﹚")
    +public func makeUpdateStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a prepared statement that can be reused.

    +
    let statement = try db.cachedUpdateStatement(sql: "INSERT INTO player (name) VALUES (?)")
    +try statement.execute(arguments: ["Arthur"])
    +try statement.execute(arguments: ["Barbara"])
    +
    + +

    The returned statement may have already been used: it may or may not +contain values for its eventual arguments.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(sql:﹚")
    +public func cachedUpdateStatement(sql: String) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a new prepared statement that can be reused.

    +
    +

    Throws

    + A DatabaseError whenever SQLite could not parse the sql query. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +An error is raised otherwise.

    +
    // OK
    +try cachedUpdateStatement(literal: """
    +    UPDATE player SET name = ?
    +    """)
    +try cachedUpdateStatement(literal: """
    +    UPDATE player SET name = \("O'Brien")
    +    """)
    +
    +// NOT OK
    +try cachedUpdateStatement(literal: """
    +    UPDATE player SET name = ?, score = \(10)
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "cachedStatement(sql:﹚")
    +public func cachedUpdateStatement(literal sqlLiteral: SQL) throws -> Statement
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A Statement.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor of all SQL statements separated by semi-colons.

    +
    let statements = try db.allStatements(sql: """
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    """, arguments: ["Arthur", "Barbara", "O'Brien"])
    +while let statement = try statements.next() {
    +    try statement.execute()
    +}
    +
    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    +

    Precondition

    +

    Arguments must be nil, or all arguments must be set. +The returned cursor will throw an error otherwise.

    +
    // OK
    +try allStatements(sql: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """)
    +try allStatements(sql: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """, arguments: [1000, 1000])
    +
    +// NOT OK
    +try allStatements(sql: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """, arguments: [1000])
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func allStatements(sql: String, arguments: StatementArguments? = nil)
    +throws -> SQLStatementCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor of Statement

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor of all SQL statements separated by semi-colons.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    let statements = try db.allStatements(literal: """
    +    INSERT INTO player (name) VALUES (\("Arthur"));
    +    INSERT INTO player (name) VALUES (\("Barbara"));
    +    INSERT INTO player (name) VALUES (\("O'Brien"));
    +    """)
    +while let statement = try statements.next() {
    +    try statement.execute()
    +}
    +
    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    +

    Precondition

    +

    No argument must be set, or all arguments must be set. +The returned cursor will throw an error otherwise.

    +
    // OK
    +try allStatements(literal: """
    +    SELECT COUNT(*) FROM player WHERE score < ?;
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """)
    +try allStatements(literal: """
    +    SELECT COUNT(*) FROM player WHERE score < \(1000);
    +    SELECT COUNT(*) FROM player WHERE score > \(1000);
    +    """)
    +
    +// NOT OK
    +try allStatements(literal: """
    +    SELECT COUNT(*) FROM player WHERE score < \(1000);
    +    SELECT COUNT(*) FROM player WHERE score > ?;
    +    """)
    +
    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func allStatements(literal sqlLiteral: SQL) throws -> SQLStatementCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor of Statement

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Executes one or several SQL statements, separated by semi-colons.

    +
    try db.execute(
    +    sql: "INSERT INTO player (name) VALUES (:name)",
    +    arguments: ["name": "Arthur"])
    +
    +try db.execute(sql: """
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    INSERT INTO player (name) VALUES (?);
    +    """, arguments: ["Arthur", "Barbara", "O'Brien"])
    +
    + +

    This method may throw a DatabaseError.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func execute(sql: String, arguments: StatementArguments = StatementArguments()) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + execute(literal:) + +
    +
    +
    +
    +
    +
    +

    Executes one or several SQL statements, separated by semi-colons.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    try db.execute(literal: """
    +    INSERT INTO player (name) VALUES (\("Arthur"))
    +    """)
    +
    +try db.execute(literal: """
    +    INSERT INTO player (name) VALUES (\("Arthur"));
    +    INSERT INTO player (name) VALUES (\("Barbara"));
    +    INSERT INTO player (name) VALUES (\("O'Brien"));
    +    """)
    +
    + +

    This method may throw a DatabaseError.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func execute(literal sqlLiteral: SQL) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database-Related Types +

+
+
+ +
+
+
+ + +
+ +

Database Observation +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Add a transaction observer, so that it gets notified of +database changes.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(
    +    transactionObserver: TransactionObserver,
    +    extent: TransactionObservationExtent = .observerLifetime)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + transactionObserver + + +
    +

    A transaction observer.

    +
    +
    + + extent + + +
    +

    The duration of the observation. The default is +the observer lifetime (observation lasts until observer +is deallocated).

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Remove a transaction observer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(transactionObserver: TransactionObserver)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Registers a closure to be executed after the next or current +transaction completion.

    +
    try dbQueue.write { db in
    +    db.afterNextTransactionCommit { _ in
    +        print("success")
    +    }
    +    ...
    +} // prints "success"
    +
    + +

    If the transaction is rollbacked, the closure is not executed.

    + +

    If the transaction is committed, the closure is executed in a protected +dispatch queue, serialized will all database updates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func afterNextTransactionCommit(_ closure: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The extent of a transaction observation

    + +

    See Database.add(transactionObserver:extent:)

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum TransactionObservationExtent
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Deletes the synchronization triggers for a synchronized FTS4 table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropFTS4SynchronizationTriggers(forTable tableName: String) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Schema +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a database table.

    +
    try db.create(table: "place") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("title", .text)
    +    t.column("favorite", .boolean).notNull().default(false)
    +    t.column("longitude", .double).notNull()
    +    t.column("latitude", .double).notNull()
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html and +https://www.sqlite.org/withoutrowid.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(
    +    table name: String,
    +    temporary: Bool = false,
    +    ifNotExists: Bool = false,
    +    withoutRowID: Bool = false,
    +    body: (TableDefinition) -> Void)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + temporary + + +
    +

    If true, creates a temporary table.

    +
    +
    + + ifNotExists + + +
    +

    If false (the default), an error is thrown if the +table already exists. Otherwise, the table is created unless it +already exists.

    +
    +
    + + withoutRowID + + +
    +

    If true, uses WITHOUT ROWID optimization.

    +
    +
    + + body + + +
    +

    A closure that defines table columns and constraints.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + rename(table:to:) + +
    +
    +
    +
    +
    +
    +

    Renames a database table.

    + +

    See https://www.sqlite.org/lang_altertable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func rename(table name: String, to newName: String) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + alter(table:body:) + +
    +
    +
    +
    +
    +
    +

    Modifies a database table.

    +
    try db.alter(table: "player") { t in
    +    t.add(column: "url", .text)
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func alter(table name: String, body: (TableAlteration) -> Void) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + body + + +
    +

    A closure that defines table alterations.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + drop(table:) + +
    +
    +
    +
    +
    +
    +

    Deletes a database table.

    + +

    See https://www.sqlite.org/lang_droptable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func drop(table name: String) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates an index.

    +
    try db.create(index: "playerByEmail", on: "player", columns: ["email"])
    +
    + +

    SQLite can also index expressions (https://www.sqlite.org/expridx.html) +and use specific collations. To create such an index, use a raw SQL +query.

    +
    try db.execute(sql: "CREATE INDEX ...")
    +
    + +

    See https://www.sqlite.org/lang_createindex.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(
    +    index name: String,
    +    on table: String,
    +    columns: [String],
    +    unique: Bool = false,
    +    ifNotExists: Bool = false,
    +    condition: SQLExpressible? = nil)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The index name.

    +
    +
    + + table + + +
    +

    The name of the indexed table.

    +
    +
    + + columns + + +
    +

    The indexed columns.

    +
    +
    + + unique + + +
    +

    If true, creates a unique index.

    +
    +
    + + ifNotExists + + +
    +

    If false, no error is thrown if index already exists.

    +
    +
    + + condition + + +
    +

    If not nil, creates a partial index +(see https://www.sqlite.org/partialindex.html).

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + drop(index:) + +
    +
    +
    +
    +
    +
    +

    Deletes a database index.

    + +

    See https://www.sqlite.org/lang_dropindex.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func drop(index name: String) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reindex(collation:) + +
    +
    +
    +
    +
    +
    +

    Delete and recreate from scratch all indices that use this collation.

    + +

    This method is useful when the definition of a collation sequence +has changed.

    + +

    See https://www.sqlite.org/lang_reindex.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reindex(collation: Database.CollationName) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reindex(collation:) + +
    +
    +
    +
    +
    +
    +

    Delete and recreate from scratch all indices that use this collation.

    + +

    This method is useful when the definition of a collation sequence +has changed.

    + +

    See https://www.sqlite.org/lang_reindex.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reindex(collation: DatabaseCollation) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a virtual database table.

    +
    try db.create(virtualTable: "vocabulary", using: "spellfix1")
    +
    + +

    See https://www.sqlite.org/lang_createtable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(virtualTable name: String, ifNotExists: Bool = false, using module: String) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + ifNotExists + + +
    +

    If false (the default), an error is thrown if the +table already exists. Otherwise, the table is created unless it +already exists.

    +
    +
    + + module + + +
    +

    The name of an SQLite virtual table module.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a virtual database table.

    +
    let module = ...
    +try db.create(virtualTable: "book", using: module) { t in
    +    ...
    +}
    +
    + +

    The type of the closure argument t depends on the type of the module +argument: refer to this module’s documentation.

    + +

    Use this method to create full-text tables using the FTS3, FTS4, or +FTS5 modules:

    +
    try db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.column("title")
    +    t.column("author")
    +    t.column("body")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create<Module: VirtualTableModule>(
    +    virtualTable tableName: String,
    +    ifNotExists: Bool = false,
    +    using module: Module,
    +    _ body: ((Module.TableDefinition) -> Void)? = nil)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The table name.

    +
    +
    + + ifNotExists + + +
    +

    If false (the default), an error is thrown if the +table already exists. Otherwise, the table is created unless it +already exists.

    +
    +
    + + module + + +
    +

    a VirtualTableModule

    +
    +
    + + body + + +
    +

    An optional closure that defines the virtual table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/BusyMode.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/BusyMode.html new file mode 100644 index 000000000..de3d87727 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/BusyMode.html @@ -0,0 +1,1236 @@ + + + + BusyMode Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

BusyMode

+
+
+ +
public enum BusyMode
+ +
+
+

When there are several connections to a database, a connection may try +to access the database while it is locked by another connection.

+ +

The BusyMode enum describes the behavior of GRDB when such a situation +occurs:

+ +
    +
  • .immediateError: The SQLITE_BUSY error is immediately returned to the +connection that tries to access the locked database.

  • +
  • .timeout: The SQLITE_BUSY error will be returned only if the database +remains locked for more than the specified duration.

  • +
  • .callback: Perform your custom lock handling.

  • +
+ +

To set the busy mode of a database, use Configuration:

+
// Wait 1 second before failing with SQLITE_BUSY
+let configuration = Configuration(busyMode: .timeout(1))
+let dbQueue = DatabaseQueue(path: "...", configuration: configuration)
+
+ +

Relevant SQLite documentation:

+ + + + +
+
+
+
    +
  • +
    + + + + immediateError + +
    +
    +
    +
    +
    +
    +

    The SQLITE_BUSY error is immediately returned to the connection that +tries to access the locked database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case immediateError
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + timeout(_:) + +
    +
    +
    +
    +
    +
    +

    The SQLITE_BUSY error will be returned only if the database remains +locked for more than the specified duration (in seconds).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeout(TimeInterval)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + callback(_:) + +
    +
    +
    +
    +
    +
    +

    A custom callback that is called when a database is locked. +See https://www.sqlite.org/c3ref/busy_handler.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case callback(BusyCallback)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/CheckpointMode.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/CheckpointMode.html new file mode 100644 index 000000000..8a110e1ca --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/CheckpointMode.html @@ -0,0 +1,1236 @@ + + + + CheckpointMode Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CheckpointMode

+
+
+ +
public enum CheckpointMode : Int32
+ +
+
+

The available checkpoint modes.

+ + +
+
+
+
    +
  • +
    + + + + passive + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_PASSIVE mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case passive = 0
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + full + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_FULL mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case full = 1
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + restart + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_RESTART mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case restart = 2
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + truncate + +
    +
    +
    +
    +
    +
    +

    The SQLITE_CHECKPOINT_TRUNCATE mode

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case truncate = 3
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/CollationName.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/CollationName.html new file mode 100644 index 000000000..5d89a1199 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/CollationName.html @@ -0,0 +1,1238 @@ + + + + CollationName Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CollationName

+
+
+ +
public struct CollationName : RawRepresentable, Hashable
+ +
+
+

A built-in SQLite collation.

+ +

See https://www.sqlite.org/datatype3.html#collation

+ + +
+
+
+
    +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    +

    Creates a built-in collation name.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawValue: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + binary + +
    +
    +
    +
    +
    +
    +

    The BINARY built-in SQL collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let binary: Database.CollationName
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + nocase + +
    +
    +
    +
    +
    +
    +

    The NOCASE built-in SQL collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let nocase: Database.CollationName
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rtrim + +
    +
    +
    +
    +
    +
    +

    The RTRIM built-in SQL collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let rtrim: Database.CollationName
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ColumnType.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ColumnType.html new file mode 100644 index 000000000..59d399e88 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ColumnType.html @@ -0,0 +1,1393 @@ + + + + ColumnType Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnType

+
+
+ +
public struct ColumnType : RawRepresentable, Hashable
+ +
+
+

An SQL column type.

+
try db.create(table: "player") { t in
+    t.autoIncrementedPrimaryKey("id")
+    t.column("title", .text)
+}
+
+ +

See https://www.sqlite.org/datatype3.html

+ + +
+
+
+
    +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    +

    Creates an SQL column type.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawValue: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + text + +
    +
    +
    +
    +
    +
    +

    The TEXT SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let text: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + integer + +
    +
    +
    +
    +
    +
    +

    The INTEGER SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let integer: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + double + +
    +
    +
    +
    +
    +
    +

    The DOUBLE SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let double: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + numeric + +
    +
    +
    +
    +
    +
    +

    The NUMERIC SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let numeric: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + boolean + +
    +
    +
    +
    +
    +
    +

    The BOOLEAN SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let boolean: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + blob + +
    +
    +
    +
    +
    +
    +

    The BLOB SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let blob: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + date + +
    +
    +
    +
    +
    +
    +

    The DATE SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let date: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + datetime + +
    +
    +
    +
    +
    +
    +

    The DATETIME SQL column type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let datetime: Database.ColumnType
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ConflictResolution.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ConflictResolution.html new file mode 100644 index 000000000..7767badf2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ConflictResolution.html @@ -0,0 +1,1268 @@ + + + + ConflictResolution Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ConflictResolution

+
+
+ +
public enum ConflictResolution : String
+ +
+
+

An SQLite conflict resolution.

+ +

See https://www.sqlite.org/lang_conflict.html

+ + +
+
+
+
    +
  • +
    + + + + rollback + +
    +
    +
    +
    +
    +
    +

    The ROLLBACK conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case rollback = "ROLLBACK"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + abort + +
    +
    +
    +
    +
    +
    +

    The ABORT conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case abort = "ABORT"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fail + +
    +
    +
    +
    +
    +
    +

    The FAIL conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case fail = "FAIL"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ignore + +
    +
    +
    +
    +
    +
    +

    The IGNORE conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case ignore = "IGNORE"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + replace + +
    +
    +
    +
    +
    +
    +

    The REPLACE conflict resolution

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case replace = "REPLACE"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ForeignKeyAction.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ForeignKeyAction.html new file mode 100644 index 000000000..5530afa7c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/ForeignKeyAction.html @@ -0,0 +1,1238 @@ + + + + ForeignKeyAction Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyAction

+
+
+ +
public enum ForeignKeyAction : String
+ +
+
+

A foreign key action.

+ +

See https://www.sqlite.org/foreignkeys.html

+ + +
+
+
+
    +
  • +
    + + + + cascade + +
    +
    +
    +
    +
    +
    +

    The CASCADE foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case cascade = "CASCADE"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + restrict + +
    +
    +
    +
    +
    +
    +

    The RESTRICT foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case restrict = "RESTRICT"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + setNull + +
    +
    +
    +
    +
    +
    +

    The SET NULL foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case setNull = "SET NULL"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + setDefault + +
    +
    +
    +
    +
    +
    +

    The SET DEFAULT foreign key action

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case setDefault = "SET DEFAULT"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TraceEvent.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TraceEvent.html new file mode 100644 index 000000000..7a9ff89da --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TraceEvent.html @@ -0,0 +1,1236 @@ + + + + TraceEvent Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TraceEvent

+
+
+ +
public enum TraceEvent : CustomStringConvertible
+ +
+
+

An event reported by Database.trace(options:_:)

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TraceEvent/Statement.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TraceEvent/Statement.html new file mode 100644 index 000000000..5dded6227 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TraceEvent/Statement.html @@ -0,0 +1,1184 @@ + + + + Statement Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Statement

+
+
+ +
public struct Statement
+ +
+
+

Information about a statement reported by Database.trace(options:_:)

+ + +
+
+
+
    +
  • +
    + + + + sql + +
    +
    +
    +
    +
    +
    +

    The executed SQL, where bound parameters are not expanded.

    + +

    For example:

    +
    UPDATE player SET score = ? WHERE id = ?
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sql: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + expandedSQL + +
    +
    +
    +
    +
    +
    +

    The executed SQL, where bound parameters are expanded.

    + +

    For example:

    +
    UPDATE player SET score = 1000 WHERE id = 1
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var expandedSQL: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TracingOptions.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TracingOptions.html new file mode 100644 index 000000000..976c0a216 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TracingOptions.html @@ -0,0 +1,1250 @@ + + + + TracingOptions Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TracingOptions

+
+
+ +
public struct TracingOptions : OptionSet
+ +
+
+

An option for Database.trace(options:_:)

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionCompletion.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionCompletion.html new file mode 100644 index 000000000..3cd356236 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionCompletion.html @@ -0,0 +1,1177 @@ + + + + TransactionCompletion Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionCompletion

+
+
+ +
@frozen
+public enum TransactionCompletion
+ +
+
+

Confirms or cancels the changes performed by a transaction or savepoint.

+ + +
+
+
+
    +
  • +
    + + + + commit + +
    +
    +
    +
    +
    +
    +

    Confirms changes

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case commit
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rollback + +
    +
    +
    +
    +
    +
    +

    Cancel changes

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case rollback
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionKind.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionKind.html new file mode 100644 index 000000000..a48aaa97c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionKind.html @@ -0,0 +1,1206 @@ + + + + TransactionKind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionKind

+
+
+ +
public enum TransactionKind : String
+ +
+
+

An SQLite transaction kind. See https://www.sqlite.org/lang_transaction.html

+ + +
+
+
+
    +
  • +
    + + + + deferred + +
    +
    +
    +
    +
    +
    +

    The DEFERRED transaction kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferred = "DEFERRED"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + immediate + +
    +
    +
    +
    +
    +
    +

    The IMMEDIATE transaction kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case immediate = "IMMEDIATE"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + exclusive + +
    +
    +
    +
    +
    +
    +

    The EXCLUSIVE transaction kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case exclusive = "EXCLUSIVE"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionObservationExtent.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionObservationExtent.html new file mode 100644 index 000000000..072db12d7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Database/TransactionObservationExtent.html @@ -0,0 +1,1208 @@ + + + + TransactionObservationExtent Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionObservationExtent

+
+
+ +
public enum TransactionObservationExtent
+ +
+
+

The extent of a transaction observation

+ +

See Database.add(transactionObserver:extent:)

+ + +
+
+
+
    +
  • +
    + + + + observerLifetime + +
    +
    +
    +
    +
    +
    +

    Observation lasts until observer is deallocated

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case observerLifetime
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + nextTransaction + +
    +
    +
    +
    +
    +
    +

    Observation lasts until the next transaction

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case nextTransaction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseLifetime + +
    +
    +
    +
    +
    +
    +

    Observation lasts until the database is closed

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case databaseLifetime
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseCollation.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseCollation.html new file mode 100644 index 000000000..75241c576 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseCollation.html @@ -0,0 +1,1442 @@ + + + + DatabaseCollation Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseCollation

+
+
+ +
public final class DatabaseCollation
+
extension DatabaseCollation: Hashable
+ +
+
+

A Collation is a string comparison function used by SQLite.

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the collation

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:function:) + +
    +
    +
    +
    +
    +
    +

    Creates a collation.

    +
    let collation = DatabaseCollation("localized_standard") { (string1, string2) in
    +    return (string1 as NSString).localizedStandardCompare(string2)
    +}
    +db.add(collation: collation)
    +try db.execute(sql: "CREATE TABLE file (name TEXT COLLATE localized_standard")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ name: String, function: @escaping (String, String) -> ComparisonResult)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    The function name.

    +
    +
    + + function + + +
    +

    A function that compares two strings.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQLite Collations +

+
+
+
    +
  • +
    + + + + unicodeCompare + +
    +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in == and <= operators.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.caseInsensitiveCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let unicodeCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in caseInsensitiveCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.caseInsensitiveCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let caseInsensitiveCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in localizedCaseInsensitiveCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.localizedCaseInsensitiveCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let localizedCaseInsensitiveCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedCompare + +
    +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in localizedCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.localizedCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let localizedCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A collation, or SQL string comparison function, that compares strings +according to the the Swift built-in localizedStandardCompare(_:) method.

    + +

    This collation is automatically added by GRDB to your database +connections.

    + +

    You can use it when creating database tables:

    +
    let collationName = DatabaseCollation.localizedStandardCompare.name
    +dbQueue.execute(sql: """
    +    CREATE TABLE players (
    +      name TEXT COLLATE \(collationName)
    +    )
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let localizedStandardCompare: DatabaseCollation
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseFunction.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseFunction.html new file mode 100644 index 000000000..4e29f3ff7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseFunction.html @@ -0,0 +1,1671 @@ + + + + DatabaseFunction Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseFunction

+
+
+ +
public final class DatabaseFunction : Hashable
+ +
+
+

An SQL function or aggregate.

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the SQL function

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var name: String { get }
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates an SQL function.

    + +

    For example:

    +
    let fn = DatabaseFunction("succ", argumentCount: 1) { dbValues in
    +    guard let int = Int.fromDatabaseValue(dbValues[0]) else {
    +        return nil
    +    }
    +    return int + 1
    +}
    +db.add(function: fn)
    +try Int.fetchOne(db, sql: "SELECT succ(1)")! // 2
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    _ name: String,
    +    argumentCount: Int32? = nil,
    +    pure: Bool = false,
    +    function: @escaping ([DatabaseValue]) throws -> DatabaseValueConvertible?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The function name.

    +
    +
    + + argumentCount + + +
    +

    The number of arguments of the function. If +omitted, or nil, the function accepts any number of arguments.

    +
    +
    + + pure + + +
    +

    Whether the function is “pure”, which means that its results +only depends on its inputs. When a function is pure, SQLite has +the opportunity to perform additional optimizations. Default value +is false.

    +
    +
    + + function + + +
    +

    A function that takes an array of DatabaseValue +arguments, and returns an optional DatabaseValueConvertible such +as Int, String, NSDate, etc. The array is guaranteed to have +exactly argumentCount elements, provided argumentCount is +not nil.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates an SQL aggregate function.

    + +

    For example:

    +
    struct MySum: DatabaseAggregate {
    +    var sum: Int = 0
    +
    +    mutating func step(_ dbValues: [DatabaseValue]) {
    +        if let int = Int.fromDatabaseValue(dbValues[0]) {
    +            sum += int
    +        }
    +    }
    +
    +    func finalize() -> DatabaseValueConvertible? {
    +        return sum
    +    }
    +}
    +
    +let dbQueue = DatabaseQueue()
    +let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
    +try dbQueue.write { db in
    +    db.add(function: fn)
    +    try db.execute(sql: "CREATE TABLE test(i)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (1)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (2)")
    +    try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Aggregate: DatabaseAggregate>(
    +    _ name: String,
    +    argumentCount: Int32? = nil,
    +    pure: Bool = false,
    +    aggregate: Aggregate.Type)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The function name.

    +
    +
    + + argumentCount + + +
    +

    The number of arguments of the aggregate. If +omitted, or nil, the aggregate accepts any number of arguments.

    +
    +
    + + pure + + +
    +

    Whether the aggregate is “pure”, which means that its +results only depends on its inputs. When an aggregate is pure, +SQLite has the opportunity to perform additional optimizations. +Default value is false.

    +
    +
    + + aggregate + + +
    +

    A type that implements the DatabaseAggregate protocol. +For each step of the aggregation, its step method is called with +an array of DatabaseValue arguments. The array is guaranteed to +have exactly argumentCount elements, provided argumentCount is +not nil.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + callAsFunction(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an SQL expression that applies the function.

    + +

    See https://github.com/groue/GRDB.swift/#sql-functions

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func callAsFunction(_ arguments: SQLExpressible...) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQL Functions +

+
+
+
    +
  • +
    + + + + capitalize + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in capitalized +String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +capitalized:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.capitalized)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let capitalize: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lowercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in lowercased +String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +lowercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.lowercased())
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let lowercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + uppercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in uppercased +String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +uppercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.uppercased())
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let uppercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedCapitalize + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in +localizedCapitalized String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +localizedCapitalized:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.localizedCapitalized)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.11, watchOS 3.0, *)
    +public static let localizedCapitalize: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedLowercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in +localizedLowercased String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +localizedLowercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.localizedLowercased)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.11, watchOS 3.0, *)
    +public static let localizedLowercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + localizedUppercase + +
    +
    +
    +
    +
    +
    +

    An SQL function that returns the Swift built-in +localizedUppercased String property.

    + +

    The function returns NULL for non-strings values.

    + +

    This function is automatically added by GRDB to your database +connections. It is the function used by the query interface’s +localizedUppercased:

    +
    let nameColumn = Column("name")
    +let request = Player.select(nameColumn.localizedUppercased)
    +let names = try String.fetchAll(dbQueue, request)   // [String]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.11, watchOS 3.0, *)
    +public static let localizedUppercase: DatabaseFunction
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseFuture.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseFuture.html new file mode 100644 index 000000000..e0948222f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseFuture.html @@ -0,0 +1,1165 @@ + + + + DatabaseFuture Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseFuture

+
+
+ +
public class DatabaseFuture<Value>
+ +
+
+

A future database value, returned by the DatabaseWriter.concurrentRead(_:) +method.

+
let futureCount: Future<Int> = try writer.writeWithoutTransaction { db in
+    try Player(...).insert()
+
+    // Count players concurrently
+    return writer.concurrentRead { db in
+        return try Player.fetchCount()
+    }
+}
+
+let count: Int = try futureCount.wait()
+
+ + +
+
+
+
    +
  • +
    + + + + wait() + +
    +
    +
    +
    +
    +
    +

    Blocks the current thread until the value is available, and returns it.

    + +

    It is a programmer error to call this method several times.

    +
    +

    Throws

    + Any error that prevented the value from becoming available. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func wait() throws -> Value
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabasePool.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabasePool.html new file mode 100644 index 000000000..d9c4849f0 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabasePool.html @@ -0,0 +1,2016 @@ + + + + DatabasePool Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabasePool

+
+
+ +
public final class DatabasePool : DatabaseWriter
+
extension DatabasePool: DatabaseReader
+ +
+
+

A DatabasePool grants concurrent accesses to an SQLite database.

+ + +
+
+
+
+ + +
+ +

Database Information +

+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + path + +
    +
    +
    +
    +
    +
    +

    The path to the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var path: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Initializer +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Opens the SQLite database at path path.

    +
    let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
    +
    + +

    Database connections get closed when the database pool gets deallocated.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(path: String, configuration: Configuration = Configuration()) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + path + + +
    +

    The path to the database file.

    +
    +
    + + configuration + + +
    +

    A configuration.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Memory management +

+
+
+
    +
  • +
    + + + + releaseMemory() + +
    +
    +
    +
    +
    +
    +

    Free as much memory as possible.

    + +

    This method blocks the current thread until all database accesses +are completed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func releaseMemory()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+
    +
  • +
    + + + + read(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func read<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + asyncRead(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unsafeRead(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + concurrentRead(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes a read-only function in a protected +dispatch queue.

    + +

    This method must be called from a writing dispatch queue, outside of any +transaction. You’ll get a fatal error otherwise.

    + +

    The value function is guaranteed to see the database in the last +committed state at the moment this method is called. Eventual +concurrent database updates are not visible from the function.

    + +

    This method returns as soon as the isolation guarantees described above +are established.

    + +

    In the example below, the number of players is fetched concurrently with +the player insertion. Yet the future is guaranteed to return zero:

    +
    try writer.asyncWriteWithoutTransaction { db in
    +    // Delete all players
    +    try Player.deleteAll()
    +
    +    // Count players concurrently
    +    writer.asyncConcurrentRead { dbResult in
    +        do {
    +            let db = try dbResult.get()
    +            // Guaranteed to be zero
    +            let count = try Player.fetchCount(db)
    +        } catch {
    +            // Handle error
    +        }
    +    }
    +
    +    // Insert a player
    +    try Player(...).insert(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncConcurrentRead(_ value: @escaping (Result<Database, Error>) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Invalidates open read-only SQLite connections.

    + +

    After this method is called, read-only database access methods will use +new SQLite connections.

    + +

    Eventual concurrent read-only accesses are not invalidated: they will +proceed until completion.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func invalidateReadOnlyConnections()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Writing in Database +

+
+
+
    +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction, and returns the result.

    + +

    If the updates throws an error, the transaction is rollbacked and the +error is rethrown. If the updates return .rollback, the transaction is +also rollbacked, but no error is thrown.

    + +

    Eventual concurrent database updates are postponed until the transaction +has completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    This method is not reentrant.

    +
    try dbPool.writeInTransaction { db in
    +    db.execute(...)
    +    return .commit
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates, or by the +wrapping transaction. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func writeInTransaction(
    +    _ kind: Database.TransactionKind? = nil,
    +    _ updates: (Database) throws -> Database.TransactionCompletion)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the transaction +type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +outside of any transaction.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Snapshots +

+
+
+
    +
  • +
    + + + + makeSnapshot() + +
    +
    +
    +
    +
    +
    +

    Creates a database snapshot.

    + +

    The snapshot sees an unchanging database content, as it existed at the +moment it was created.

    + +

    When you want to control the latest committed changes seen by a +snapshot, create it from the pool’s writer protected dispatch queue:

    +
    let snapshot1 = try dbPool.write { db -> DatabaseSnapshot in
    +    try Player.deleteAll()
    +    return try dbPool.makeSnapshot()
    +}
    +// <- Other threads may modify the database here
    +let snapshot2 = try dbPool.makeSnapshot()
    +
    +try snapshot1.read { db in
    +    // Guaranteed to be zero
    +    try Player.fetchCount(db)
    +}
    +
    +try snapshot2.read { db in
    +    // Could be anything
    +    try Player.fetchCount(db)
    +}
    +
    + +

    It is forbidden to create a snapshot from the writer protected dispatch +queue when a transaction is opened, though, because it is likely a +programmer error:

    +
    try dbPool.write { db in
    +    try db.inTransaction {
    +        try Player.deleteAll()
    +        // fatal error: makeSnapshot() must not be called from inside a transaction
    +        let snapshot = try dbPool.makeSnapshot()
    +        return .commit
    +    }
    +}
    +
    + +

    To avoid this fatal error, create the snapshot before or after the +transaction:

    +
    try dbPool.writeWithoutTransaction { db in
    +    // OK
    +    let snapshot = try dbPool.makeSnapshot()
    +
    +    try db.inTransaction {
    +        try Player.deleteAll()
    +        return .commit
    +    }
    +
    +    // OK
    +    let snapshot = try dbPool.makeSnapshot()
    +}
    +
    + +

    You can create as many snapshots as you need, regardless of the maximum +number of reader connections in the pool.

    + +

    For more information, read about “snapshot isolation” at https://sqlite.org/isolation.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makeSnapshot() throws -> DatabaseSnapshot
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseQueue.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseQueue.html new file mode 100644 index 000000000..704ea210c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseQueue.html @@ -0,0 +1,1904 @@ + + + + DatabaseQueue Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseQueue

+
+
+ +
public final class DatabaseQueue : DatabaseWriter
+ +
+
+

A DatabaseQueue serializes access to an SQLite database.

+ + +
+
+
+
+ + +
+ +

Configuration +

+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + path + +
    +
    +
    +
    +
    +
    +

    The path to the database file; it is “:memory:” for in-memory databases.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var path: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Initializers +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Opens the SQLite database at path path.

    +
    let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
    +
    + +

    Database connections get closed when the database queue gets deallocated.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(path: String, configuration: Configuration = Configuration()) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + path + + +
    +

    The path to the database file.

    +
    +
    + + configuration + + +
    +

    A configuration.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(configuration:) + +
    +
    +
    +
    +
    +
    +

    Opens an in-memory SQLite database.

    +
    let dbQueue = DatabaseQueue()
    +
    + +

    Database memory is released when the database queue gets deallocated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(configuration: Configuration = Configuration())
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + configuration + + +
    +

    A configuration.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Memory management +

+
+
+
    +
  • +
    + + + + releaseMemory() + +
    +
    +
    +
    +
    +
    +

    Free as much memory as possible.

    + +

    This method blocks the current thread until all database accesses are completed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func releaseMemory()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ + +
+ +

Writing in Database +

+
+
+
    +
  • +
    + + + + inTransaction(_:_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction, and returns the result.

    + +

    If the updates throws an error, the transaction is rollbacked and the +error is rethrown. If the updates return .rollback, the transaction is +also rollbacked, but no error is thrown.

    + +

    Eventual concurrent database accesses are postponed until the +transaction has completed.

    + +

    This method is not reentrant.

    +
    try dbQueue.writeInTransaction { db in
    +    db.execute(...)
    +    return .commit
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates, or by the +wrapping transaction. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inTransaction(
    +    _ kind: Database.TransactionKind? = nil,
    +    _ updates: (Database) throws -> Database.TransactionCompletion)
    +throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + kind + + +
    +

    The transaction type (default nil). If nil, the transaction +type is configuration.defaultTransactionKind, which itself +defaults to .deferred. See https://www.sqlite.org/lang_transaction.html +for more information.

    +
    +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + inDatabase(_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Eventual concurrent database updates are postponed until the updates +are completed.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +

    This method is not reentrant.

    +
    +

    Throws

    + The error thrown by the updates. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inDatabase<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseSnapshot.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseSnapshot.html new file mode 100644 index 000000000..847e1126c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseSnapshot.html @@ -0,0 +1,1351 @@ + + + + DatabaseSnapshot Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseSnapshot

+
+
+ +
public class DatabaseSnapshot : DatabaseReader
+ +
+
+

A DatabaseSnapshot sees an unchanging database content, as it existed at the +moment it was created.

+ +

See DatabasePool.makeSnapshot()

+ +

For more information, read about “snapshot isolation” at https://sqlite.org/isolation.html

+ + +
+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseValueCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseValueCursor.html new file mode 100644 index 000000000..a41d876c4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/DatabaseValueCursor.html @@ -0,0 +1,1153 @@ + + + + DatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseValueCursor

+
+
+ +
public final class DatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
+ +
+
+

A cursor of database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let urls: DatabaseValueCursor<URL> = try URL.fetchCursor(db, sql: "SELECT url FROM link")
+    while let url = urls.next() { // URL
+        print(url)
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Value?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS3TableDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS3TableDefinition.html new file mode 100644 index 000000000..561893e23 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS3TableDefinition.html @@ -0,0 +1,1212 @@ + + + + FTS3TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3TableDefinition

+
+
+ +
public final class FTS3TableDefinition
+ +
+
+

The FTS3TableDefinition class lets you define columns of a FTS3 virtual table.

+ +

You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

+
try db.create(virtualTable: "document", using: FTS3()) { t in // t is FTS3TableDefinition
+    t.column("content")
+}
+
+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS4ColumnDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS4ColumnDefinition.html new file mode 100644 index 000000000..40a3ee99a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS4ColumnDefinition.html @@ -0,0 +1,1209 @@ + + + + FTS4ColumnDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS4ColumnDefinition

+
+
+ +
public final class FTS4ColumnDefinition
+ +
+
+

The FTS4ColumnDefinition class lets you refine a column of an FTS4 +virtual table.

+ +

You get instances of this class when you create an FTS4 table:

+
try db.create(virtualTable: "document", using: FTS4()) { t in
+    t.column("content")      // FTS4ColumnDefinition
+}
+
+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+
    +
  • +
    + + + + notIndexed() + +
    +
    +
    +
    +
    +
    +

    Excludes the column from the full-text index.

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("a")
    +    t.column("b").notIndexed()
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#the_notindexed_option

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func notIndexed() -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + asLanguageId() + +
    +
    +
    +
    +
    +
    +

    Uses the column as the Int32 language id hidden column.

    +
    try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("a")
    +    t.column("lid").asLanguageId()
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#the_languageid_option

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func asLanguageId() -> Self
    + +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS4TableDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS4TableDefinition.html new file mode 100644 index 000000000..53714df43 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS4TableDefinition.html @@ -0,0 +1,1425 @@ + + + + FTS4TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS4TableDefinition

+
+
+ +
public final class FTS4TableDefinition
+ +
+
+

The FTS4TableDefinition class lets you define columns of a FTS4 virtual table.

+ +

You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

+
try db.create(virtualTable: "document", using: FTS4()) { t in // t is FTS4TableDefinition
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS5ColumnDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS5ColumnDefinition.html new file mode 100644 index 000000000..c0b37e9f4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS5ColumnDefinition.html @@ -0,0 +1,1141 @@ + + + + FTS5ColumnDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5ColumnDefinition

+

The FTS5ColumnDefinition class lets you refine a column of an FTS5 +virtual table.

+ +

You get instances of this class when you create an FTS5 table:

+
try db.create(virtualTable: "document", using: FTS5()) { t in
+    t.column("content")      // FTS5ColumnDefinition
+}
+
+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS5TableDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS5TableDefinition.html new file mode 100644 index 000000000..959554718 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FTS5TableDefinition.html @@ -0,0 +1,1308 @@ + + + + FTS5TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5TableDefinition

+

The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.

+ +

You don’t create instances of this class. Instead, you use the Database +create(virtualTable:using:) method:

+
try db.create(virtualTable: "document", using: FTS5()) { t in // t is FTS5TableDefinition
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FastDatabaseValueCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FastDatabaseValueCursor.html new file mode 100644 index 000000000..014010654 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FastDatabaseValueCursor.html @@ -0,0 +1,1154 @@ + + + + FastDatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FastDatabaseValueCursor

+
+
+ +
public final class FastDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible, Value : StatementColumnConvertible
+ +
+
+

A cursor of database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let names: ColumnCursor<String> = try String.fetchCursor(db, sql: "SELECT name FROM player")
+    while let name = names.next() { // String
+        print(name)
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public func next() throws -> Value?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FastNullableDatabaseValueCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FastNullableDatabaseValueCursor.html new file mode 100644 index 000000000..e20558b2f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/FastNullableDatabaseValueCursor.html @@ -0,0 +1,1156 @@ + + + + FastNullableDatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FastNullableDatabaseValueCursor

+
+
+ +
public final class FastNullableDatabaseValueCursor<Value>: Cursor
+where Value: DatabaseValueConvertible & StatementColumnConvertible
+ +
+
+

A cursor of optional database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let emails: FastNullableDatabaseValueCursor<String> =
+        try Optional<String>.fetchCursor(db, sql: "SELECT email FROM player")
+    while let email = emails.next() { // String?
+        print(email ?? "<NULL>")
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public func next() throws -> Value??
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/NullableDatabaseValueCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/NullableDatabaseValueCursor.html new file mode 100644 index 000000000..95597d2de --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/NullableDatabaseValueCursor.html @@ -0,0 +1,1153 @@ + + + + NullableDatabaseValueCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NullableDatabaseValueCursor

+
+
+ +
public final class NullableDatabaseValueCursor<Value> : Cursor where Value : DatabaseValueConvertible
+ +
+
+

A cursor of optional database values extracted from a single column. +For example:

+
try dbQueue.read { db in
+    let urls: NullableDatabaseValueCursor<URL> = try Optional<URL>.fetchCursor(db, sql: "SELECT url FROM link")
+    while let url = urls.next() { // URL?
+        print(url)
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Value??
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Record.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Record.html new file mode 100644 index 000000000..a448dc67d --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Record.html @@ -0,0 +1,1972 @@ + + + + Record Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Record

+
+
+ +
open class Record : FetchableRecord, TableRecord, PersistableRecord
+ +
+
+

Record is a class that wraps a table row, or the result of any query. It is +designed to be subclassed.

+ + +
+
+
+
+ + +
+ +

Initializers +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a Record.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(row:) + +
    +
    +
    +
    +
    +
    +

    Creates a Record from a row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public required init(row: Row)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Core methods +

+
+
+
    +
  • +
    + + + + databaseTableName + +
    +
    +
    +
    +
    +
    +

    The name of a database table.

    + +

    This table name is required by the insert, update, save, delete, +and exists methods.

    +
    class Player : Record {
    +    override class var databaseTableName: String {
    +        return "player"
    +    }
    +}
    +
    + +

    The implementation of the base class Record raises a fatal error.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class var databaseTableName: String { get }
    + +
    +
    +
    +

    Return Value

    +

    The name of a database table.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The policy that handles SQLite conflicts when records are inserted +or updated.

    + +

    This property is optional: its default value uses the ABORT policy +for both insertions and updates, and has GRDB generate regular +INSERT and UPDATE queries.

    + +

    If insertions are resolved with .ignore policy, the +didInsert(with:for:) method is not called upon successful insertion, +even if a row was actually inserted without any conflict.

    + +

    See https://www.sqlite.org/lang_conflict.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class var persistenceConflictPolicy: PersistenceConflictPolicy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseSelection + +
    +
    +
    +
    +
    +
    +

    The default request selection.

    + +

    Unless this method is overriden, requests select all columns:

    +
    // SELECT * FROM player
    +try Player.fetchAll(db)
    +
    + +

    You can override this property and provide an explicit list +of columns:

    +
    class RestrictedPlayer : Record {
    +    override static var databaseSelection: [SQLSelectable] {
    +        return [Column("id"), Column("name")]
    +    }
    +}
    +
    +// SELECT id, name FROM player
    +try RestrictedPlayer.fetchAll(db)
    +
    + +

    You can also add extra columns such as the rowid column:

    +
    class ExtendedPlayer : Player {
    +    override static var databaseSelection: [SQLSelectable] {
    +        return [AllColumns(), Column.rowID]
    +    }
    +}
    +
    +// SELECT *, rowid FROM player
    +try ExtendedPlayer.fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open class var databaseSelection: [SQLSelectable] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + encode(to:) + +
    +
    +
    +
    +
    +
    +

    Defines the values persisted in the database.

    + +

    Store in the container argument all values that should be stored in +the columns of the database table (see Record.databaseTableName()).

    + +

    Primary key columns, if any, must be included.

    +
    class Player : Record {
    +    var id: Int64?
    +    var name: String?
    +
    +    override func encode(to container: inout PersistenceContainer) {
    +        container["id"] = id
    +        container["name"] = name
    +    }
    +}
    +
    + +

    The implementation of the base class Record does not store any value in +the container.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func encode(to container: inout PersistenceContainer)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + didInsert(with:for:) + +
    +
    +
    +
    +
    +
    +

    Notifies the record that it was successfully inserted.

    + +

    Do not call this method directly: it is called for you, in a protected +dispatch queue, with the inserted RowID and the eventual +INTEGER PRIMARY KEY column name.

    + +

    The implementation of the base Record class does nothing.

    +
    class Player : Record {
    +    var id: Int64?
    +    var name: String?
    +
    +    func didInsert(with rowID: Int64, for column: String?) {
    +        id = rowID
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func didInsert(with rowID: Int64, for column: String?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + rowID + + +
    +

    The inserted rowID.

    +
    +
    + + column + + +
    +

    The name of the eventual INTEGER PRIMARY KEY column.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Copy +

+
+
+
    +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns a copy of self, initialized from all values encoded in the +encode(to:) method.

    + +

    The eventual primary key is copied, as well as the +hasDatabaseChanges flag.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func copy() -> Self
    + +
    +
    +
    +

    Return Value

    +

    A copy of self.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Compare with Previous Versions +

+
+
+
    +
  • +
    + + + + hasDatabaseChanges + +
    +
    +
    +
    +
    +
    +

    A boolean that indicates whether the record has changes that have not +been saved.

    + +

    This flag is purely informative, and does not prevent insert(), +update(), and save() from performing their database queries.

    + +

    A record is edited if has been changed since last database +synchronization (fetch, update, insert). Comparison +is performed between values (values stored in the encode(to:) +method, and values loaded from the database). Property setters do not +trigger this flag.

    + +

    You can rely on the Record base class to compute this flag for you, or +you may set it to true or false when you know better. Setting it to +false does not prevent it from turning true on subsequent modifications +of the record.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var hasDatabaseChanges: Bool { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseChanges + +
    +
    +
    +
    +
    +
    +

    A dictionary of changes that have not been saved.

    + +

    Its keys are column names, and values the old values that have been +changed since last fetching or saving of the record.

    + +

    Unless the record has actually been fetched or saved, the old values +are nil.

    + +

    See hasDatabaseChanges for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseChanges: [String : DatabaseValue?] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

CRUD +

+
+
+
    +
  • +
    + + + + insert(_:) + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have inserted a row in the database if it +returns without error.

    + +

    Records whose primary key is declared as “INTEGER PRIMARY KEY” have +their id automatically set after successful insertion, if it was nil +before the insertion.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func insert(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + update(_:columns:) + +
    +
    +
    +
    +
    +
    +

    Executes an UPDATE statement.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have updated a row in the database if it +returns without error.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    open func update(_ db: Database, columns: Set<String>) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + updateChanges(_:) + +
    +
    +
    +
    +
    +
    +

    If the record has been changed, executes an UPDATE statement so that +those changes and only those changes are saved in the database.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have saved the eventual changes in the +database if it returns without error.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public final func updateChanges(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
  • +
    + + + + save(_:) + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    If the record has a non-nil primary key and a matching row in the +database, this method performs an update.

    + +

    Otherwise, performs an insert.

    + +

    On success, this method sets the hasDatabaseChanges flag to false.

    + +

    This method is guaranteed to have inserted or updated a row in the +database if it returns without error.

    + +

    You can’t override this method. Instead, override insert(_:) +or update(_:columns:).

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs, or errors +thrown by update(). + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public final func save(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete(_:) + +
    +
    +
    +
    +
    +
    +

    Executes a DELETE statement.

    + +

    On success, this method sets the hasDatabaseChanges flag to true.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +open func delete(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/RecordCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/RecordCursor.html new file mode 100644 index 000000000..9721abc1e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/RecordCursor.html @@ -0,0 +1,1150 @@ + + + + RecordCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RecordCursor

+
+
+ +
public final class RecordCursor<Record> : Cursor where Record : FetchableRecord
+ +
+
+

A cursor of records. For example:

+
struct Player : FetchableRecord { ... }
+try dbQueue.read { db in
+    let players: RecordCursor<Player> = try Player.fetchCursor(db, sql: "SELECT * FROM player")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Record?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row.html new file mode 100644 index 000000000..fef1cf046 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row.html @@ -0,0 +1,4091 @@ + + + + Row Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Row

+
+
+ +
public final class Row: Equatable, Hashable, RandomAccessCollection,
+                        ExpressibleByDictionaryLiteral, CustomStringConvertible,
+                        CustomDebugStringConvertible
+ +
+
+

A database row.

+ + +
+
+
+
    +
  • +
    + + + + count + +
    +
    +
    +
    +
    +
    +

    The number of columns in the row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let count: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + prefetchedRows + +
    +
    +
    +
    +
    +
    +

    A view on the prefetched associated rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:1 name:"Herman Melville"]
    +
    +let bookRows = row.prefetchedRows["books"]
    +print(bookRows[0])
    +// Prints [id:42 title:"Moby-Dick"]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public internal(set) var prefetchedRows: Row.PrefetchedRowsView { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Building rows +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an empty row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a row from a dictionary of values.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(_ dictionary: [String : DatabaseValueConvertible?])
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a row from [AnyHashable: Any].

    + +

    The result is nil unless all dictionary keys are strings, and values +adopt DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init?(_ dictionary: [AnyHashable : Any])
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a row initialized with elements. Column order is preserved, and +duplicated columns names are allowed.

    +
    let row: Row = ["foo": 1, "foo": "bar", "baz": nil]
    +print(row)
    +// Prints [foo:1 foo:"bar" baz:NULL]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns an immutable copy of the row.

    + +

    For performance reasons, rows fetched from a cursor are reused during +the iteration of a query: make sure to make a copy of it whenever you +want to keep a specific one: row.copy().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func copy() -> Row
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Columns +

+
+
+
    +
  • +
    + + + + columnNames + +
    +
    +
    +
    +
    +
    +

    The names of columns in the row.

    + +

    Columns appear in the same order as they occur as the .0 member +of column-value pairs in self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var columnNames: LazyMapCollection<Row, String> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasColumn(_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if the row has that column.

    + +

    This method is case-insensitive.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasColumn(_ columnName: String) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting Values +

+
+
+
    +
  • +
    + + + + containsNonNullValue + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if one column contains a non-null value, or if +the row was fetched with a row adapter that defines a scoped row that +contains a non-null value.

    + +

    For example:

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'foo', 1")!
    +row.containsNonNullValue // true
    +
    +let row = try Row.fetchOne(db, sql: "SELECT NULL, NULL")!
    +row.containsNonNullValue // false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var containsNonNullValue: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasNull(atIndex:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the row contains null at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    This method is equivalent to row[index] == nil, but may be preferred +in performance-critical code because it can avoid decoding database +values.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasNull(atIndex index: Int) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, Data or nil, depending on the value +stored at the given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(index: Int) -> DatabaseValueConvertible? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    If the SQLite value is NULL, the result is nil. Otherwise the SQLite +value is converted to the requested type Value. Should this conversion +fail, a fatal error is raised.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(index: Int) -> Value? where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    If the SQLite value is NULL, the result is nil. Otherwise the SQLite +value is converted to the requested type Value. Should this conversion +fail, a fatal error is raised.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public subscript<Value>(index: Int) -> Value? where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(index: Int) -> Value where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given index, converted to the requested type.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public subscript<Value>(index: Int) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, Data or nil, depending on the value +stored at the given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    The result is nil if the row does not contain the column.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(columnName: String) -> DatabaseValueConvertible? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value? where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value? where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value where Value : DatabaseValueConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value>(columnName: String) -> Value where Value : DatabaseValueConvertible, Value : StatementColumnConvertible { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, NSData or nil, depending on the value +stored at the given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    The result is nil if the row does not contain the column.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Column>(column: Column) -> DatabaseValueConvertible? where Column : ColumnExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(column: Column) -> Value? where Value : DatabaseValueConvertible, Column : ColumnExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. Otherwise the SQLite value is converted to the requested type +Value. Should this conversion fail, a fatal error is raised.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(_ column: Column)
    +-> Value?
    +where
    +    Value: DatabaseValueConvertible & StatementColumnConvertible,
    +    Column: ColumnExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(column: Column) -> Value where Value : DatabaseValueConvertible, Column : ColumnExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the value at given column, converted to the requested type.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the row does not contain the column, a fatal error is raised.

    + +

    This method crashes if the fetched SQLite value is NULL, or if the +SQLite value can not be converted to Value.

    + +

    This method exists as an optimization opportunity for types that adopt +StatementColumnConvertible. It may trigger SQLite built-in conversions +(see https://www.sqlite.org/datatype3.html).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inlinable
    +public subscript<Value, Column>(_ column: Column)
    +-> Value
    +where
    +    Value: DatabaseValueConvertible & StatementColumnConvertible,
    +    Column: ColumnExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + dataNoCopy(atIndex:) + +
    +
    +
    +
    +
    +
    +

    Returns the optional Data at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    If the SQLite value is NULL, the result is nil. If the SQLite value can +not be converted to Data, a fatal error is raised.

    + +

    The returned data does not owns its bytes: it must not be used longer +than the row’s lifetime.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dataNoCopy(atIndex index: Int) -> Data?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + dataNoCopy(named:) + +
    +
    +
    +
    +
    +
    +

    Returns the optional Data at given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. If the SQLite value can not be converted to Data, a fatal error +is raised.

    + +

    The returned data does not owns its bytes: it must not be used longer +than the row’s lifetime.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dataNoCopy(named columnName: String) -> Data?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + dataNoCopy(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the optional NSData at given column.

    + +

    Column name lookup is case-insensitive, and when several columns have +the same name, the leftmost column is considered.

    + +

    If the column is missing or if the SQLite value is NULL, the result is +nil. If the SQLite value can not be converted to NSData, a fatal error +is raised.

    + +

    The returned data does not owns its bytes: it must not be used longer +than the row’s lifetime.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dataNoCopy<Column>(_ column: Column) -> Data? where Column : ColumnExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting DatabaseValue +

+
+
+
    +
  • +
    + + + + databaseValues + +
    +
    +
    +
    +
    +
    +

    The database values in the row.

    + +

    Values appear in the same order as they occur as the .1 member +of column-value pairs in self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValues: LazyMapCollection<Row, DatabaseValue> { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting Records +

+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the record associated with the given scope.

    + +

    For example:

    +
    let request = Book.including(required: Book.author)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let author: Author = row["author"]
    +print(author.name)
    +// Prints "Herman Melville"
    +
    + +

    Associated records stored in nested associations are available, too:

    +
    let request = Book.including(required: Book.author.including(required: Author.country))
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let country: Country = row["country"]
    +print(country.name)
    +// Prints "United States"
    +
    + +

    A fatal error is raised if the scope is not available, or contains only +null values.

    + +

    See https://github.com/groue/GRDB.swift/blob/master/README.md#joined-queries-support +for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Record>(scope: String) -> Record where Record : FetchableRecord { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the eventual record associated with the given scope.

    + +

    For example:

    +
    let request = Book.including(optional: Book.author)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let author: Author? = row["author"]
    +print(author.name)
    +// Prints "Herman Melville"
    +
    + +

    Associated records stored in nested associations are available, too:

    +
    let request = Book.including(optional: Book.author.including(optional: Author.country))
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Book(row: row).title)
    +// Prints "Moby-Dick"
    +
    +let country: Country? = row["country"]
    +print(country.name)
    +// Prints "United States"
    +
    + +

    Nil is returned if the scope is not available, or contains only +null values.

    + +

    See https://github.com/groue/GRDB.swift/blob/master/README.md#joined-queries-support +for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Record>(scope: String) -> Record? where Record : FetchableRecord { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the records encoded in the given prefetched rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Author(row: row).name)
    +// Prints "Herman Melville"
    +
    +let books: [Book] = row["books"]
    +print(books[0].title)
    +// Prints "Moby-Dick"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Collection>(_ key: String)
    +-> Collection
    +where
    +    Collection: RangeReplaceableCollection,
    +    Collection.Element: FetchableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the set of records encoded in the given prefetched rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(Author(row: row).name)
    +// Prints "Herman Melville"
    +
    +let books: Set<Book> = row["books"]
    +print(books.first!.title)
    +// Prints "Moby-Dick"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Record>(key: String) -> Set<Record> where Record : FetchableRecord, Record : Hashable { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Scopes +

+
+
+
    +
  • +
    + + + + scopes + +
    +
    +
    +
    +
    +
    +

    Returns a view on the scopes defined by row adapters.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopes.count  // 2
    +row.scopes.names  // ["foo", "bar"]
    +
    +row.scopes["foo"] // [foo:1]
    +row.scopes["bar"] // [bar:2]
    +row.scopes["baz"] // nil
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var scopes: ScopesView { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + scopesTree + +
    +
    +
    +
    +
    +
    +

    Returns a view on the scopes tree defined by row adapters.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopesTree.names  // ["foo", "bar", "baz"]
    +
    +row.scopesTree["foo"] // [foo:1]
    +row.scopesTree["bar"] // [bar:2]
    +row.scopesTree["baz"] // [baz:3]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var scopesTree: ScopesTreeView { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unscoped + +
    +
    +
    +
    +
    +
    +

    Returns a copy of the row, without any scopes.

    + +

    This property can turn out useful when you want to test the content of +adapted rows, such as rows fetched from joined requests.

    +
    let row = ...
    +// Failure because row equality tests for row scopes:
    +XCTAssertEqual(row, ["id": 1, "name": "foo"])
    +// Success:
    +XCTAssertEqual(row.unscoped, ["id": 1, "name": "foo"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var unscoped: Row { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unadapted + +
    +
    +
    +
    +
    +
    +

    Return the raw row fetched from the database.

    + +

    This property can turn out useful when you debug the consumption of +adapted rows, such as rows fetched from joined requests.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var unadapted: Row { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over rows fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let rows = try Row.fetchCursor(statement) // RowCursor
    +while let row = try rows.next() { // Row
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of rows fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let rows = try Row.fetchAll(statement)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a set of rows fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let rows = try Row.fetchSet(statement)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a single row fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT ...")
    +let row = try Row.fetchOne(statement)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over rows fetched from an SQL query.

    +
    let rows = try Row.fetchCursor(db, sql: "SELECT id, name FROM player") // RowCursor
    +while let row = try rows.next() { // Row
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of rows fetched from an SQL query.

    +
    let rows = try Row.fetchAll(db, sql: "SELECT id, name FROM player") // [Row]
    +for row in rows {
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a set of rows fetched from an SQL query.

    +
    let rows = try Row.fetchSet(db, sql: "SELECT id, name FROM player") // Set<Row>
    +for row in rows {
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a single row fetched from an SQL query.

    +
    let row = try Row.fetchOne(db, sql: "SELECT id, name FROM player") // Row?
    +if let row = row {
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over rows fetched from a fetch request.

    +
    let request = Player.all()
    +let rows = try Row.fetchCursor(db, request) // RowCursor
    +while let row = try rows.next() { // Row
    +    let id: Int64 = row["id"]
    +    let name: String = row["name"]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R>(_ db: Database, _ request: R) throws -> RowCursor where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an array of rows fetched from a fetch request.

    +
    let request = Player.all()
    +let rows = try Row.fetchAll(db, request)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Row] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a set of rows fetched from a fetch request.

    +
    let request = Player.all()
    +let rows = try Row.fetchSet(db, request)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Row> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a single row fetched from a fetch request.

    +
    let request = Player.filter(key: 1)
    +let row = try Row.fetchOne(db, request)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Row? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row as a Collection of (ColumnName, DatabaseValue) Pairs +

+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Accesses the (ColumnName, DatabaseValue) pair at given index.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(position: RowIndex) -> (String, DatabaseValue) { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row.ScopesView +

+
+
+
    +
  • +
    + + + + ScopesView + +
    +
    +
    +
    +
    +
    +

    A view of the scopes defined by row adapters. It is a collection of +tuples made of a scope name and a scoped row, which behaves like a +dictionary.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopes.count  // 2
    +row.scopes.names  // ["foo", "bar"]
    +
    +row.scopes["foo"] // [foo:1]
    +row.scopes["bar"] // [bar:2]
    +row.scopes["baz"] // nil
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ScopesView : Collection
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row.ScopesTreeView +

+
+
+
    +
  • +
    + + + + ScopesTreeView + +
    +
    +
    +
    +
    +
    +

    A view on the scopes tree defined by row adapters.

    + +

    For example:

    +
    // Define a tree of nested scopes
    +let adapter = ScopeAdapter([
    +    "foo": RangeRowAdapter(0..<1),
    +    "bar": RangeRowAdapter(1..<2).addingScopes([
    +        "baz" : RangeRowAdapter(2..<3)])])
    +
    +// Fetch
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +row.scopesTree.names  // ["foo", "bar", "baz"]
    +
    +row.scopesTree["foo"] // [foo:1]
    +row.scopesTree["bar"] // [bar:2]
    +row.scopesTree["baz"] // [baz:3]
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ScopesTreeView
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Row.PrefetchedRowsView +

+
+
+
    +
  • +
    + + + + PrefetchedRowsView + +
    +
    +
    +
    +
    +
    +

    A view on the prefetched associated rows.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:1 name:"Herman Melville"]
    +
    +let bookRows = row.prefetchedRows["books"]
    +print(bookRows[0])
    +// Prints [id:42 title:"Moby-Dick"]
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PrefetchedRowsView : Equatable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/PrefetchedRowsView.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/PrefetchedRowsView.html new file mode 100644 index 000000000..7794d79cb --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/PrefetchedRowsView.html @@ -0,0 +1,1243 @@ + + + + PrefetchedRowsView Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PrefetchedRowsView

+
+
+ +
public struct PrefetchedRowsView : Equatable
+ +
+
+

A view on the prefetched associated rows.

+ +

For example:

+
let request = Author.including(all: Author.books)
+let row = try Row.fetchOne(db, request)!
+
+print(row)
+// Prints [id:1 name:"Herman Melville"]
+
+let bookRows = row.prefetchedRows["books"]
+print(bookRows[0])
+// Prints [id:42 title:"Moby-Dick"]
+
+ + +
+
+
+
    +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    True if there is no prefetched associated rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + keys + +
    +
    +
    +
    +
    +
    +

    The keys for available prefetched rows

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row.prefetchedRows.keys)
    +// Prints ["books"]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var keys: Set<String> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the prefetched rows associated with the given key.

    + +

    For example:

    +
    let request = Author.including(all: Author.books)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:1 name:"Herman Melville"]
    +
    +let bookRows = row.prefetchedRows["books"]
    +print(bookRows[0])
    +// Prints [id:42 title:"Moby-Dick"]
    +
    + +

    Prefetched rows stored in nested “to-one” associations are +available, too.

    + +

    Nil is returned if the key is not available.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(key: String) -> [Row]? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/ScopesTreeView.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/ScopesTreeView.html new file mode 100644 index 000000000..ecaa91dc5 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/ScopesTreeView.html @@ -0,0 +1,1220 @@ + + + + ScopesTreeView Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ScopesTreeView

+
+
+ +
public struct ScopesTreeView
+ +
+
+

A view on the scopes tree defined by row adapters.

+ +

For example:

+
// Define a tree of nested scopes
+let adapter = ScopeAdapter([
+    "foo": RangeRowAdapter(0..<1),
+    "bar": RangeRowAdapter(1..<2).addingScopes([
+        "baz" : RangeRowAdapter(2..<3)])])
+
+// Fetch
+let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
+let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+
+row.scopesTree.names  // ["foo", "bar", "baz"]
+
+row.scopesTree["foo"] // [foo:1]
+row.scopesTree["bar"] // [bar:2]
+row.scopesTree["baz"] // [baz:3]
+
+ + +
+
+
+
    +
  • +
    + + + + names + +
    +
    +
    +
    +
    +
    +

    The scopes defined on this row, recursively.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var names: Set<String> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the row associated with the given scope.

    + +

    For example:

    +
    let request = Book.including(required: Book.author)
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:42 title:"Moby-Dick"]
    +
    +let authorRow = row.scopesTree["author"]
    +print(authorRow)
    +// Prints [id:1 name:"Herman Melville"]
    +
    + +

    Associated rows stored in nested associations are available, too:

    +
    let request = Book.including(required: Book.author.including(required: Author.country))
    +let row = try Row.fetchOne(db, request)!
    +
    +print(row)
    +// Prints [id:42 title:"Moby-Dick"]
    +
    +let countryRow = row.scopesTree["country"]
    +print(countryRow)
    +// Prints [code:"US" name:"United States"]
    +
    + +

    Nil is returned if the scope is not available.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(name: String) -> Row? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/ScopesView.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/ScopesView.html new file mode 100644 index 000000000..858f211f9 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Row/ScopesView.html @@ -0,0 +1,1227 @@ + + + + ScopesView Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ScopesView

+
+
+ +
public struct ScopesView : Collection
+ +
+
+

A view of the scopes defined by row adapters. It is a collection of +tuples made of a scope name and a scoped row, which behaves like a +dictionary.

+ +

For example:

+
// Define a tree of nested scopes
+let adapter = ScopeAdapter([
+    "foo": RangeRowAdapter(0..<1),
+    "bar": RangeRowAdapter(1..<2).addingScopes([
+        "baz" : RangeRowAdapter(2..<3)])])
+
+// Fetch
+let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
+let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+
+row.scopes.count  // 2
+row.scopes.names  // ["foo", "bar"]
+
+row.scopes["foo"] // [foo:1]
+row.scopes["bar"] // [bar:2]
+row.scopes["baz"] // nil
+
+ + +
+
+
+
    +
  • +
    + + + + Index + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias Index = Dictionary<String, _LayoutedRowAdapter>.Index
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + names + +
    +
    +
    +
    +
    +
    +

    The scopes defined on this row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var names: Dictionary<String, _LayoutedRowAdapter>.Keys { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the row associated with the given scope, or nil if the +scope is not defined.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(name: String) -> Row? { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/RowCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/RowCursor.html new file mode 100644 index 000000000..6ee3db231 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/RowCursor.html @@ -0,0 +1,1179 @@ + + + + RowCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RowCursor

+
+
+ +
public final class RowCursor : Cursor
+ +
+
+

A cursor of database rows. For example:

+
try dbQueue.read { db in
+    let rows: RowCursor = try Row.fetchCursor(db, sql: "SELECT * FROM player")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + statement + +
    +
    +
    +
    +
    +
    +

    The statement iterated by this cursor

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let statement: Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func next() throws -> Row?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/SQLStatementCursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/SQLStatementCursor.html new file mode 100644 index 000000000..08f6c7519 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/SQLStatementCursor.html @@ -0,0 +1,1145 @@ + + + + SQLStatementCursor Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLStatementCursor

+
+
+ +
public class SQLStatementCursor : Cursor
+ +
+
+

Undocumented

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/SharedValueObservation.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/SharedValueObservation.html new file mode 100644 index 000000000..1df3f12ab --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/SharedValueObservation.html @@ -0,0 +1,1275 @@ + + + + SharedValueObservation Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SharedValueObservation

+
+
+ +
public final class SharedValueObservation<Element>
+ +
+
+

Experimental

+ +

A shared value observation that shares a single underlying database +observation for all subscriptions, and thus spares database resources.

+ +

For example:

+
let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue)
+
+let cancellable = try sharedObservation.start(
+    onError: { error in ... },
+    onChange: { players: [Player] in
+        print("Players have changed.")
+    })
+
+ +

The sharing only applies if you start observing the database from the +same SharedValueObservation instance:

+
// NOT shared
+let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+
+// Shared
+let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
+let cancellable1 = sharedObservation.start(...)
+let cancellable2 = sharedObservation.start(...)
+
+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Starts observing the database.

    + +

    The observation lasts until the returned cancellable is cancelled +or deallocated.

    + +

    For example:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +
    +let cancellable = try sharedObservation.start(
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func start(
    +    onError: @escaping (Error) -> Void,
    +    onChange: @escaping (Element) -> Void)
    +-> DatabaseCancellable
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + onError + + +
    +

    A closure that is provided eventual errors that +happen during observation

    +
    +
    + + onChange + + +
    +

    A closure that is provided fresh values

    +
    +
    +
    +
    +

    Return Value

    +

    a DatabaseCancellable

    +
    + +
    +
    +
  • +
  • +
    + + + + publisher() + +
    +
    +
    +
    +
    +
    +

    Creates a publisher which tracks changes in database values.

    + +

    For example:

    +
    let publisher = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +    .publisher()
    +
    +let cancellable = publisher.sink(
    +    receiveCompletion: { completion in ... },
    +    receiveValue: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func publisher() -> DatabasePublishers.Value<Element>
    + +
    +
    +
    +

    Return Value

    +

    A Combine publisher

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Statement.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Statement.html new file mode 100644 index 000000000..7bb14fe31 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/Statement.html @@ -0,0 +1,1622 @@ + + + + Statement Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Statement

+
+
+ +
public final class Statement
+
extension Statement: _RowLayout
+
extension Statement: CustomStringConvertible
+ +
+
+

A statement represents an SQL query.

+ + +
+
+
+
    +
  • +
    + + + + sqliteStatement + +
    +
    +
    +
    +
    +
    +

    The raw SQLite statement, suitable for the SQLite C API.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let sqliteStatement: SQLiteStatement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sql + +
    +
    +
    +
    +
    +
    +

    The SQL query

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sql: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + columnNames + +
    +
    +
    +
    +
    +
    +

    The column names, ordered from left to right.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public lazy var columnNames: [String] { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseRegion + +
    +
    +
    +
    +
    +
    +

    The database region that the statement looks into.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public internal(set) var databaseRegion: DatabaseRegion { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isReadonly + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if the prepared statement makes no direct +changes to the content of the database file.

    + +

    See https://www.sqlite.org/c3ref/stmt_readonly.html.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isReadonly: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Arguments +

+
+
+
    +
  • +
    + + + + arguments + +
    +
    +
    +
    +
    +
    +

    The statement arguments.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var arguments: StatementArguments { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + validateArguments(_:) + +
    +
    +
    +
    +
    +
    +

    Throws a DatabaseError of code SQLITE_ERROR if arguments don’t fill all +statement arguments.

    + +

    For example:

    +
    let statement = try db.makeUpdateArgument(sql: """
    +    INSERT INTO player (id, name) VALUES (?, ?)
    +    """)
    +
    +// OK
    +statement.validateArguments([1, "Arthur"])
    +
    +// Throws
    +statement.validateArguments([1])
    +
    + +

    See also setArguments(_:)

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func validateArguments(_ arguments: StatementArguments) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Set arguments without any validation. Trades safety for performance.

    + +

    Only call this method if you are sure input arguments match all expected +arguments of the statement.

    + +

    For example:

    +
    let statement = try db.makeUpdateArgument(sql: """
    +    INSERT INTO player (id, name) VALUES (?, ?)
    +    """)
    +
    +// OK
    +statement.setUncheckedArguments([1, "Arthur"])
    +
    +// OK
    +let arguments: StatementArguments = ... // some untrusted arguments
    +try statement.validateArguments(arguments)
    +statement.setUncheckedArguments(arguments)
    +
    +// NOT OK
    +statement.setUncheckedArguments([1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func setUncheckedArguments(_ arguments: StatementArguments)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + setArguments(_:) + +
    +
    +
    +
    +
    +
    +

    Set the statement arguments, or throws a DatabaseError of code +SQLITE_ERROR if arguments don’t fill all statement arguments.

    + +

    For example:

    +
    let statement = try db.makeUpdateArgument(sql: """
    +    INSERT INTO player (id, name) VALUES (?, ?)
    +    """)
    +
    +// OK
    +try statement.setArguments([1, "Arthur"])
    +
    +// Throws an error
    +try statement.setArguments([1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func setArguments(_ arguments: StatementArguments) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + description + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var description: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Select Statements +

+
+
+
    +
  • +
    + + + + columnCount + +
    +
    +
    +
    +
    +
    +

    The number of columns in the resulting rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var columnCount: Int { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + index(ofColumn:) + +
    +
    +
    +
    +
    +
    +

    Returns the index of the leftmost column named name, in a +case-insensitive way.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func index(ofColumn name: String) -> Int?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Update Statements +

+
+
+
    +
  • +
    + + + + execute(arguments:) + +
    +
    +
    +
    +
    +
    +

    Executes the prepared statement.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func execute(arguments: StatementArguments? = nil) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableAlias.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableAlias.html new file mode 100644 index 000000000..8c45814c9 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableAlias.html @@ -0,0 +1,1341 @@ + + + + TableAlias Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableAlias

+
+
+ +
public class TableAlias : Hashable
+ +
+
+

Experimental

+ +

A TableAlias identifies a table in a request.

+ + +
+
+
+
    +
  • +
    + + + + init(name:) + +
    +
    +
    +
    +
    +
    +

    Creates a TableAlias, suitable for qualifying requests or associations.

    + +

    For example:

    +
    // The request for all books published after their author has died
    +//
    +// SELECT book.*
    +// FROM book
    +// JOIN author ON author.id = book.authorId
    +// WHERE book.publishDate >= author.deathDate
    +let authorAlias = TableAlias()
    +let request = Book
    +    .joining(required: Book.author.aliased(authorAlias))
    +    .filter(Column("publishDate") >= authorAlias[Column("deathDate")])
    +
    + +

    When the alias is given a name, this name is guaranteed to be used as +the table alias in the SQL query:

    +
    // SELECT book.*
    +// FROM book
    +// JOIN author a ON a.id = book.authorId
    +// WHERE book.publishDate >= a.deathDate
    +let authorAlias = TableAlias(name: "a")
    +let request = Book
    +    .joining(required: Book.author.aliased(authorAlias))
    +    .filter(Column("publishDate") >= authorAlias[Column("deathDate")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(name: String? = nil)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified value that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(selectable: SQLSelectable) -> SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified expression that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(expression: SQLSpecificExpressible & SQLSelectable & SQLOrderingTerm) -> SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified ordering that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(ordering: SQLOrderingTerm) -> SQLOrdering { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a qualified columnn that is able to resolve ambiguities in +joined queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(column: String) -> SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + exists + +
    +
    +
    +
    +
    +
    +

    Experimental

    + +

    An expression that evaluates to true if the record refered by this +TableAlias exists.

    + +

    For example, here is how filter books and only keep those that are not +associated to any author:

    +
    let books: [Book] = try dbQueue.read { db in
    +    let authorAlias = TableAlias()
    +    let request = Book
    +        .joining(optional: Book.author.aliased(authorAlias))
    +        .filter(!authorAlias.exists)
    +    return try request.fetchAll(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var exists: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableAlteration.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableAlteration.html new file mode 100644 index 000000000..bbec2f4ec --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableAlteration.html @@ -0,0 +1,1365 @@ + + + + TableAlteration Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableAlteration

+
+
+ +
public final class TableAlteration
+ +
+
+

The TableAlteration class lets you alter database tables.

+ +

You don’t create instances of this class. Instead, you use the Database +alter(table:) method:

+
try db.alter(table: "player") { t in // t is TableAlteration
+    t.add(column: ...)
+}
+
+ +

See https://www.sqlite.org/lang_altertable.html

+ + +
+
+
+
    +
  • +
    + + + + add(column:_:) + +
    +
    +
    +
    +
    +
    +

    Appends a column to the table.

    +
    try db.alter(table: "player") { t in
    +    t.add(column: "url", .text)
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func add(column name: String, _ type: Database.ColumnType? = nil) -> ColumnDefinition
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    the column name.

    +
    +
    + + type + + +
    +

    the column type.

    +
    +
    +
    +
    +

    Return Value

    +

    An ColumnDefinition that allows you to refine the +column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + addColumn(sql:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with raw SQL.

    +
    // ALTER TABLE player ADD COLUMN name TEXT
    +try db.alter(table: "player") { t in
    +    t.addColumn(sql: "name TEXT")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func addColumn(sql: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + addColumn(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // ALTER TABLE player ADD COLUMN name TEXT DEFAULT 'Anonymous'
    +let defaultName = "Anonymous"
    +try db.alter(table: "player") { t in
    +    t.addColumn(literal: "name TEXT DEFAULT \(defaultName)")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func addColumn(literal: SQL)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rename(column:to:) + +
    +
    +
    +
    +
    +
    +

    Renames a column in a table.

    +
    try db.alter(table: "player") { t in
    +    t.rename(column: "url", to: "homeURL")
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + +
    +
    +
    +
  • +
  • +
    + + + + rename(column:to:) + +
    +
    +
    +
    +
    +
    +

    Renames a column in a table.

    +
    try db.alter(table: "player") { t in
    +    t.rename(column: "url", to: "homeURL")
    +}
    +
    + +

    See https://www.sqlite.org/lang_altertable.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    +public func rename(column name: String, to newName: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    the column name to rename.

    +
    +
    + + newName + + +
    +

    the new name of the column.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableDefinition.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableDefinition.html new file mode 100644 index 000000000..22ce124b0 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/TableDefinition.html @@ -0,0 +1,1819 @@ + + + + TableDefinition Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableDefinition

+
+
+ +
public final class TableDefinition
+ +
+
+

The TableDefinition class lets you define table columns and constraints.

+ +

You don’t create instances of this class. Instead, you use the Database +create(table:) method:

+
try db.create(table: "player") { t in // t is TableDefinition
+    t.column(...)
+}
+
+ +

See https://www.sqlite.org/lang_createtable.html

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Defines the auto-incremented primary key.

    +
    try db.create(table: "player") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +}
    +
    + +

    The auto-incremented primary key is an integer primary key that +automatically generates unused values when you do not explicitly +provide one, and prevents the reuse of ids over the lifetime of +the database.

    + +

    It is the preferred way to define a numeric primary key.

    + +

    The fact that an auto-incremented primary key prevents the reuse of +ids is an excellent guard against data races that could happen when your +application processes ids in an asynchronous way. The auto-incremented +primary key provides the guarantee that a given id can’t reference a row +that is different from the one it used to be at the beginning of the +asynchronous process, even if this row gets deleted and a new one is +inserted in between.

    + +

    See https://www.sqlite.org/lang_createtable.html#primkeyconst and +https://www.sqlite.org/lang_createtable.html#rowid

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func autoIncrementedPrimaryKey(
    +    _ name: String,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil)
    +-> ColumnDefinition
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    +
    +

    Return Value

    +

    Self so that you can further refine the column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + column(_:_:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column.

    +
    try db.create(table: "player") { t in
    +    t.column("name", .text)
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#tablecoldef

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func column(_ name: String, _ type: Database.ColumnType? = nil) -> ColumnDefinition
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    the column name.

    +
    +
    + + type + + +
    +

    the eventual column type.

    +
    +
    +
    +
    +

    Return Value

    +

    An ColumnDefinition that allows you to refine the +column definition.

    +
    + +
    +
    +
  • +
  • +
    + + + + column(sql:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with raw SQL.

    +
    try db.create(table: "player") { t in
    +    t.column(sql: "name TEXT")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func column(sql: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + column(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends a table column defined with an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // CREATE TABLE player (
    +//   name TEXT DEFAULT 'Anonymous'
    +// )
    +let defaultName = "Anonymous"
    +try db.create(table: "player") { t in
    +    t.column(literal: "name TEXT DEFAULT \(defaultName)")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func column(literal: SQL)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Defines the table primary key.

    +
    try db.create(table: "citizenship") { t in
    +    t.column("citizenID", .integer)
    +    t.column("countryCode", .text)
    +    t.primaryKey(["citizenID", "countryCode"])
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#primkeyconst and +https://www.sqlite.org/lang_createtable.html#rowid

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func primaryKey(_ columns: [String], onConflict conflictResolution: Database.ConflictResolution? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + columns + + +
    +

    The primary key columns.

    +
    +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Adds a unique key.

    +
    try db.create(table: "place") { t in
    +    t.column("latitude", .double)
    +    t.column("longitude", .double)
    +    t.uniqueKey(["latitude", "longitude"])
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#uniqueconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func uniqueKey(_ columns: [String], onConflict conflictResolution: Database.ConflictResolution? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + columns + + +
    +

    The unique key columns.

    +
    +
    + + conflictResolution + + +
    +

    An optional conflict resolution +(see https://www.sqlite.org/lang_conflict.html).

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Adds a foreign key.

    +
    try db.create(table: "passport") { t in
    +    t.column("issueDate", .date)
    +    t.column("citizenID", .integer)
    +    t.column("countryCode", .text)
    +    t.foreignKey(["citizenID", "countryCode"], references: "citizenship", onDelete: .cascade)
    +}
    +
    + +

    See https://www.sqlite.org/foreignkeys.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func foreignKey(
    +    _ columns: [String],
    +    references table: String,
    +    columns destinationColumns: [String]? = nil,
    +    onDelete deleteAction: Database.ForeignKeyAction? = nil,
    +    onUpdate updateAction: Database.ForeignKeyAction? = nil,
    +    deferred: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + columns + + +
    +

    The foreign key columns.

    +
    +
    + + table + + +
    +

    The referenced table.

    +
    +
    + + destinationColumns + + +
    +

    The columns in the referenced table. If not +specified, the columns of the primary key of the referenced table +are used.

    +
    +
    + + deleteAction + + +
    +

    Optional action when the referenced row is deleted.

    +
    +
    + + updateAction + + +
    +

    Optional action when the referenced row is updated.

    +
    +
    + + deferred + + +
    +

    If true, defines a deferred foreign key constraint. +See https://www.sqlite.org/foreignkeys.html#fk_deferred.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + check(_:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint.

    +
    try db.create(table: "player") { t in
    +    t.column("personalPhone", .text)
    +    t.column("workPhone", .text)
    +    let personalPhone = Column("personalPhone")
    +    let workPhone = Column("workPhone")
    +    t.check(personalPhone != nil || workPhone != nil)
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func check(_ condition: SQLExpressible)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + condition + + +
    +

    The checked condition

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + check(sql:) + +
    +
    +
    +
    +
    +
    +

    Adds a CHECK constraint.

    +
    try db.create(table: "player") { t in
    +    t.column("personalPhone", .text)
    +    t.column("workPhone", .text)
    +    t.check(sql: "personalPhone IS NOT NULL OR workPhone IS NOT NULL")
    +}
    +
    + +

    See https://www.sqlite.org/lang_createtable.html#ckconst

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func check(sql: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sql + + +
    +

    An SQL snippet

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + constraint(sql:) + +
    +
    +
    +
    +
    +
    +

    Appends a table constraint defined with raw SQL.

    +
    // CREATE TABLE player (
    +//   ...
    +//   CHECK (score >= 0)
    +// )
    +try db.create(table: "player") { t in
    +    ...
    +    t.constraint(sql: "CHECK (score >= 0)")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func constraint(sql: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + constraint(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends a table constraint defined with an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // CREATE TABLE player (
    +//   ...
    +//   CHECK (score >= 0)
    +// )
    +let minScore = 0
    +try db.create(table: "player") { t in
    +    ...
    +    t.constraint(literal: "CHECK (score >= \(minScore))")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func constraint(literal: SQL)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ValueObservationScheduler.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ValueObservationScheduler.html new file mode 100644 index 000000000..e85752437 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Classes/ValueObservationScheduler.html @@ -0,0 +1,1214 @@ + + + + ValueObservationScheduler Class Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ValueObservationScheduler

+
+
+ +
public class ValueObservationScheduler
+ +
+
+

ValueObservationScheduler determines how ValueObservation notifies its +fresh values.

+ + +
+
+
+
    +
  • +
    + + + + async(onQueue:) + +
    +
    +
    +
    +
    +
    +

    A scheduler which asynchronously notifies fresh value of the +given DispatchQueue.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    scheduling: .async(onQueue: .main),
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func async(onQueue queue: DispatchQueue) -> ValueObservationScheduler
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + immediate + +
    +
    +
    +
    +
    +
    +

    A scheduler which notifies all values on the main queue. The first one +is immediately notified when the start() method is called.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    scheduling: .immediate,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +// <- here "fresh players" is already printed.
    +
    +
    +

    Important

    + this scheduler requires that the observation is started +from the main queue. A fatal error is raised otherwise. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let immediate: ValueObservationScheduler
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums.html new file mode 100644 index 000000000..8e885dbde --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums.html @@ -0,0 +1,1598 @@ + + + + Enumerations Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Enumerations

+

The following enumerations are available globally.

+ +
+
+
+
    +
  • +
    + + + + DatabasePublishers + +
    +
    +
    +
    +
    +
    +

    A namespace for database Combine publishers.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public enum DatabasePublishers
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database events +

+
+
+ +
+
+
+ + +
+ +

Date functions +

+
+
+ +
+
+
+ + +
+ +

DatabaseDateEncodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseDateEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their Date properties.

    + +

    For example:

    +
    struct Player: EncodableRecord, Encodable {
    +    static let databaseDateEncodingStrategy = DatabaseDateEncodingStrategy.timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // encoded as an epoch timestamp
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseDateEncodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseUUIDEncodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their UUID properties.

    + +

    For example:

    +
    struct Player: EncodableProtocol, Encodable {
    +    static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
    +
    +    // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
    +    var uuid: UUID
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseUUIDEncodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseColumnEncodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseColumnEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their coding keys into +database columns.

    + +

    For example:

    +
    struct Player: EncodableProtocol, Encodable {
    +    static let databaseColumnEncodingStrategy = DatabaseColumnEncodingStrategy.convertToSnakeCase
    +
    +    // Encoded in the player_id column
    +    var playerID: String
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseColumnEncodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseDateDecodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseDateDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol decode their +Date properties.

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseDateDecodingStrategy = DatabaseDateDecodingStrategy.timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // decoded from epoch timestamp
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseDateDecodingStrategy
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseColumnDecodingStrategy +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseColumnDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol look for the database colums +that match their coding keys.

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase
    +
    +    // Decoded from the player_id column
    +    var playerID: Int
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum DatabaseColumnDecodingStrategy
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + PersistenceError + +
    +
    +
    +
    +
    +
    +

    An error thrown by a type that adopts MutablePersistableRecord.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum PersistenceError : Error, CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Controls the extent of the shared database observation +of SharedValueObservation.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum SharedValueObservationExtent
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ValueReducers + +
    +
    +
    +
    +
    +
    +

    A namespace for types related to the ValueReducer protocol.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum ValueReducers
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseColumnDecodingStrategy.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseColumnDecodingStrategy.html new file mode 100644 index 000000000..cf7ce3a9f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseColumnDecodingStrategy.html @@ -0,0 +1,1217 @@ + + + + DatabaseColumnDecodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseColumnDecodingStrategy

+
+
+ +
public enum DatabaseColumnDecodingStrategy
+ +
+
+

DatabaseColumnDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol look for the database colums +that match their coding keys.

+ +

For example:

+
struct Player: FetchableRecord, Decodable {
+    static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase
+
+    // Decoded from the player_id column
+    var playerID: Int
+}
+
+ + +
+
+
+
    +
  • +
    + + + + useDefaultKeys + +
    +
    +
    +
    +
    +
    +

    A key decoding strategy that doesn’t change key names during decoding.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case useDefaultKeys
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + convertFromSnakeCase + +
    +
    +
    +
    +
    +
    +

    A key decoding strategy that converts snake-case keys to camel-case keys.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case convertFromSnakeCase
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    A key decoding strategy defined by the closure you supply.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((String) -> CodingKey)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseColumnEncodingStrategy.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseColumnEncodingStrategy.html new file mode 100644 index 000000000..827261977 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseColumnEncodingStrategy.html @@ -0,0 +1,1217 @@ + + + + DatabaseColumnEncodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseColumnEncodingStrategy

+
+
+ +
public enum DatabaseColumnEncodingStrategy
+ +
+
+

DatabaseColumnEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their coding keys into +database columns.

+ +

For example:

+
struct Player: EncodableProtocol, Encodable {
+    static let databaseColumnEncodingStrategy = DatabaseColumnEncodingStrategy.convertToSnakeCase
+
+    // Encoded in the player_id column
+    var playerID: String
+}
+
+ + +
+
+
+
    +
  • +
    + + + + useDefaultKeys + +
    +
    +
    +
    +
    +
    +

    A key encoding strategy that doesn’t change key names during encoding.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case useDefaultKeys
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + convertToSnakeCase + +
    +
    +
    +
    +
    +
    +

    A key encoding strategy that converts camel-case keys to snake-case keys.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case convertToSnakeCase
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    A key encoding strategy defined by the closure you supply.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((CodingKey) -> String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseDateDecodingStrategy.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseDateDecodingStrategy.html new file mode 100644 index 000000000..72fa4d50e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseDateDecodingStrategy.html @@ -0,0 +1,1360 @@ + + + + DatabaseDateDecodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseDateDecodingStrategy

+
+
+ +
public enum DatabaseDateDecodingStrategy
+ +
+
+

DatabaseDateDecodingStrategy specifies how FetchableRecord types that +also adopt the standard Decodable protocol decode their +Date properties.

+ +

For example:

+
struct Player: FetchableRecord, Decodable {
+    static let databaseDateDecodingStrategy = DatabaseDateDecodingStrategy.timeIntervalSince1970
+
+    var name: String
+    var registrationDate: Date // decoded from epoch timestamp
+}
+
+ + +
+
+
+
    +
  • +
    + + + + deferredToDate + +
    +
    +
    +
    +
    +
    +

    The strategy that uses formatting from the Date structure.

    + +

    It decodes numeric values as a number of seconds since Epoch +(midnight UTC on January 1st, 1970).

    + +

    It decodes strings in the following formats, assuming UTC time zone. +Missing components are assumed to be zero:

    + +
      +
    • YYYY-MM-DD
    • +
    • YYYY-MM-DD HH:MM
    • +
    • YYYY-MM-DD HH:MM:SS
    • +
    • YYYY-MM-DD HH:MM:SS.SSS
    • +
    • YYYY-MM-DDTHH:MM
    • +
    • YYYY-MM-DDTHH:MM:SS
    • +
    • YYYY-MM-DDTHH:MM:SS.SSS
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferredToDate
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Decodes numeric values as a number of seconds between the date and +midnight UTC on 1 January 2001

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSinceReferenceDate
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + timeIntervalSince1970 + +
    +
    +
    +
    +
    +
    +

    Decodes numeric values as a number of seconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + millisecondsSince1970 + +
    +
    +
    +
    +
    +
    +

    Decodes numeric values as a number of milliseconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case millisecondsSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + iso8601 + +
    +
    +
    +
    +
    +
    +

    Decodes dates according to the ISO 8601 standards

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case iso8601
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + formatted(_:) + +
    +
    +
    +
    +
    +
    +

    Decodes a String, according to the provided formatter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case formatted(DateFormatter)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    Decodes according to the user-provided function.

    + +

    If the database value does not contain a suitable value, the function +must return nil (GRDB will interpret this nil result as a conversion +error, and react accordingly).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((DatabaseValue) -> Date?)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseDateEncodingStrategy.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseDateEncodingStrategy.html new file mode 100644 index 000000000..9da9bf0c6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseDateEncodingStrategy.html @@ -0,0 +1,1373 @@ + + + + DatabaseDateEncodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseDateEncodingStrategy

+
+
+ +
public enum DatabaseDateEncodingStrategy
+ +
+
+

DatabaseDateEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their Date properties.

+ +

For example:

+
struct Player: EncodableRecord, Encodable {
+    static let databaseDateEncodingStrategy = DatabaseDateEncodingStrategy.timeIntervalSince1970
+
+    var name: String
+    var registrationDate: Date // encoded as an epoch timestamp
+}
+
+ + +
+
+
+
    +
  • +
    + + + + deferredToDate + +
    +
    +
    +
    +
    +
    +

    The strategy that uses formatting from the Date structure.

    + +

    It encodes dates using the format “YYYY-MM-DD HH:MM:SS.SSS” in the +UTC time zone.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferredToDate
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Encodes a Double: the number of seconds between the date and +midnight UTC on 1 January 2001

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSinceReferenceDate
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + timeIntervalSince1970 + +
    +
    +
    +
    +
    +
    +

    Encodes a Double: the number of seconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case timeIntervalSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + secondsSince1970 + +
    +
    +
    +
    +
    +
    +

    Encodes an Int64: the number of seconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case secondsSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + millisecondsSince1970 + +
    +
    +
    +
    +
    +
    +

    Encodes an Int64: the number of milliseconds between the date and +midnight UTC on 1 January 1970

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case millisecondsSince1970
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + iso8601 + +
    +
    +
    +
    +
    +
    +

    Encodes dates according to the ISO 8601 and RFC 3339 standards

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case iso8601
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + formatted(_:) + +
    +
    +
    +
    +
    +
    +

    Encodes a String, according to the provided formatter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case formatted(DateFormatter)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + custom(_:) + +
    +
    +
    +
    +
    +
    +

    Encodes the result of the user-provided function

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case custom((Date) -> DatabaseValueConvertible?)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseEventKind.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseEventKind.html new file mode 100644 index 000000000..3e4c34161 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseEventKind.html @@ -0,0 +1,1251 @@ + + + + DatabaseEventKind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseEventKind

+
+
+ +
@frozen
+public enum DatabaseEventKind
+ +
+
+

A kind of database event. See the TransactionObserver protocol for +more information.

+ + +
+
+
+
    +
  • +
    + + + + insert(tableName:) + +
    +
    +
    +
    +
    +
    +

    The insertion of a row in a database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case insert(tableName: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete(tableName:) + +
    +
    +
    +
    +
    +
    +

    The deletion of a row in a database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case delete(tableName: String)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The update of a set of columns in a database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case update(tableName: String, columnNames: Set<String>)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database events +

+
+
+
    +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The impacted database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers.html new file mode 100644 index 000000000..f6517be55 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers.html @@ -0,0 +1,1297 @@ + + + + DatabasePublishers Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabasePublishers

+
+
+ +
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
+public enum DatabasePublishers
+ +
+
+

A namespace for database Combine publishers.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/DatabaseRegion.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/DatabaseRegion.html new file mode 100644 index 000000000..e20e9770e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/DatabaseRegion.html @@ -0,0 +1,1176 @@ + + + + DatabaseRegion Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegion

+
+
+ +
public struct DatabaseRegion : Publisher
+ +
+
+

A publisher that tracks changes in a database region.

+ +

See DatabaseRegionObservation.publisher(in:).

+ + +
+
+
+
    +
  • +
    + + + + Output + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias Output = Database
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Failure + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias Failure = Error
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Migrate.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Migrate.html new file mode 100644 index 000000000..bbaf8ae60 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Migrate.html @@ -0,0 +1,1206 @@ + + + + Migrate Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Migrate

+
+
+ +
public struct Migrate : Publisher
+ +
+
+

A publisher that migrates a database. It publishes exactly +one element, or an error.

+ +

See DatabaseMigrator.migratePublisher(_:receiveOn:).

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Read.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Read.html new file mode 100644 index 000000000..1120041b6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Read.html @@ -0,0 +1,1211 @@ + + + + Read Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Read

+
+
+ +
public struct Read<Output> : Publisher
+ +
+
+

A publisher that reads a value from the database. It publishes exactly +one element, or an error.

+ +

See:

+ + + + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Value.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Value.html new file mode 100644 index 000000000..a49861542 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Value.html @@ -0,0 +1,1176 @@ + + + + Value Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Value

+
+
+ +
public struct Value<Output> : Publisher
+ +
+
+

A publisher that tracks changes in the database.

+ +

See ValueObservation.publisher(in:scheduling:).

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Write.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Write.html new file mode 100644 index 000000000..c8e663ee4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabasePublishers/Write.html @@ -0,0 +1,1213 @@ + + + + Write Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Write

+
+
+ +
public struct Write<Output> : Publisher
+ +
+
+

A publisher that writes into the database. It publishes exactly +one element, or an error.

+ +

See:

+ + + + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseUUIDEncodingStrategy.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseUUIDEncodingStrategy.html new file mode 100644 index 000000000..1168d9191 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/DatabaseUUIDEncodingStrategy.html @@ -0,0 +1,1249 @@ + + + + DatabaseUUIDEncodingStrategy Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseUUIDEncodingStrategy

+
+
+ +
public enum DatabaseUUIDEncodingStrategy
+ +
+
+

DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that +also adopt the standard Encodable protocol encode their UUID properties.

+ +

For example:

+
struct Player: EncodableProtocol, Encodable {
+    static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
+
+    // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
+    var uuid: UUID
+}
+
+ + +
+
+
+
    +
  • +
    + + + + deferredToUUID + +
    +
    +
    +
    +
    +
    +

    The strategy that uses formatting from the UUID type.

    + +

    It encodes UUIDs as 16-bytes data blobs.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case deferredToUUID
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + uppercaseString + +
    +
    +
    +
    +
    +
    +

    Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case uppercaseString
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + lowercaseString + +
    +
    +
    +
    +
    +
    +

    Encodes UUIDs as lowercased strings such as “e621e1f8-c36c-495a-93fc-0c247a3e6e5f”

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case lowercaseString
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + string + +
    +
    +
    +
    +
    +
    +

    Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "uppercaseString")
    +public static var string: `Self` { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/PersistenceError.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/PersistenceError.html new file mode 100644 index 000000000..3b6b3af41 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/PersistenceError.html @@ -0,0 +1,1152 @@ + + + + PersistenceError Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistenceError

+
+
+ +
public enum PersistenceError : Error, CustomStringConvertible
+ +
+
+

An error thrown by a type that adopts MutablePersistableRecord.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/SQLDateModifier.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/SQLDateModifier.html new file mode 100644 index 000000000..efaaa47f1 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/SQLDateModifier.html @@ -0,0 +1,1538 @@ + + + + SQLDateModifier Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLDateModifier

+
+
+ +
public enum SQLDateModifier : SQLSpecificExpressible
+ +
+
+

A date modifier for SQLite date functions such as julianDay(_:_:) and +dateTime(_:_:).

+ +

For more information, see https://www.sqlite.org/lang_datefunc.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/SharedValueObservationExtent.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/SharedValueObservationExtent.html new file mode 100644 index 000000000..76cc790f5 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/SharedValueObservationExtent.html @@ -0,0 +1,1188 @@ + + + + SharedValueObservationExtent Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SharedValueObservationExtent

+
+
+ +
public enum SharedValueObservationExtent
+ +
+
+

Controls the extent of the shared database observation +of SharedValueObservation.

+ + +
+
+
+
    +
  • +
    + + + + observationLifetime + +
    +
    +
    +
    +
    +
    +

    The SharedValueObservation starts a single database observation, which +ends when the SharedValueObservation is deallocated and all +subscriptions terminated.

    + +

    This extent prevents the shared observation from recovering from +database errors. To recover from database errors, create a new shared +SharedValueObservation instance.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case observationLifetime
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + whileObserved + +
    +
    +
    +
    +
    +
    +

    The SharedValueObservation ends database observation when the number +of subscriptions drops down to zero. The database observation restarts +on the next subscription.

    + +

    Database errors can be recovered by resubscribing to the +shared observation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case whileObserved
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/ValueReducers.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/ValueReducers.html new file mode 100644 index 000000000..0aa00f483 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Enums/ValueReducers.html @@ -0,0 +1,1239 @@ + + + + ValueReducers Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ValueReducers

+
+
+ +
public enum ValueReducers
+ +
+
+

A namespace for types related to the ValueReducer protocol.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions.html new file mode 100644 index 000000000..a33250761 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions.html @@ -0,0 +1,2298 @@ + + + + Extensions Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Extensions

+

The following extensions are available globally.

+ +
+
+
+
+ + +
+ +

RangeReplaceableCollection, Sequence, Dictionary, Set extensions +

+
+
+ +
+
+
+ + +
+ +

Cursors +

+
+
+ +
+
+
+ + +
+ +

Value Types +

+
+
+ +
+
+
+ + +
+ +

Inclusion Operators (BETWEEN, IN) +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Bool.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Bool.html new file mode 100644 index 000000000..2bbf02aa6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Bool.html @@ -0,0 +1,1263 @@ + + + + Bool Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Bool

+ +

Bool adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Bool initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Bool?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CGFloat.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CGFloat.html new file mode 100644 index 000000000..ab1a884c5 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CGFloat.html @@ -0,0 +1,1173 @@ + + + + CGFloat Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CGFloat

+
+
+ +
extension CGFloat: DatabaseValueConvertible
+ +
+
+

CGFloat adopts DatabaseValueConvertible

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a CGFloat initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> CGFloat?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/ClosedRange.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/ClosedRange.html new file mode 100644 index 000000000..1a654a51b --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/ClosedRange.html @@ -0,0 +1,1154 @@ + + + + ClosedRange Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ClosedRange

+
+
+ +
extension ClosedRange where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // email BETWEEN 'A' AND 'B'
    +("A"..."B").contains(Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Collection.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Collection.html new file mode 100644 index 000000000..718a32d8c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Collection.html @@ -0,0 +1,1159 @@ + + + + Collection Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Collection

+
+
+ +
extension Collection where Element == SQL
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Element == SQL +

+
+
+
    +
  • +
    + + + + joined(separator:) + +
    +
    +
    +
    +
    +
    +

    Returns the concatenated SQL literal of this collection of literals, +inserting the given SQL separator between each element.

    +
    let components: [SQL] = [
    +    "UPDATE player",
    +    "SET name = \(name)",
    +    "WHERE id = \(id)"
    +]
    +let query = components.joined(separator: " ")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(separator: String = "") -> SQL
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Column.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Column.html new file mode 100644 index 000000000..49dce75c7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Column.html @@ -0,0 +1,1124 @@ + + + + Column Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Column

+ +
+
+
+
    +
  • +
    + + + + rank + +
    +
    +
    +
    +
    +
    +

    The FTS5 rank column

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/ColumnExpression.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/ColumnExpression.html new file mode 100644 index 000000000..6075f8853 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/ColumnExpression.html @@ -0,0 +1,1127 @@ + + + + ColumnExpression Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnExpression

+ +
+
+
+
    +
  • +
    + + + + match(_:) + +
    +
    +
    +
    +
    +
    +

    A matching SQL expression with the MATCH SQL operator.

    +
    // content MATCH '...'
    +Column("content").match(pattern)
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CountableClosedRange.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CountableClosedRange.html new file mode 100644 index 000000000..a990aad99 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CountableClosedRange.html @@ -0,0 +1,1154 @@ + + + + CountableClosedRange Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CountableClosedRange

+
+
+ +
extension CountableClosedRange where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // id BETWEEN 1 AND 10
    +(1...10).contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CountableRange.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CountableRange.html new file mode 100644 index 000000000..e9a83fcdb --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/CountableRange.html @@ -0,0 +1,1154 @@ + + + + CountableRange Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CountableRange

+
+
+ +
extension CountableRange where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // id BETWEEN 1 AND 9
    +(1..<10).contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Data.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Data.html new file mode 100644 index 000000000..15cfc07e8 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Data.html @@ -0,0 +1,1232 @@ + + + + Data Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Data

+ +

Data is convertible to and from DatabaseValue.

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Database.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Database.html new file mode 100644 index 000000000..32c31f056 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Database.html @@ -0,0 +1,1273 @@ + + + + Database Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Database

+ +
+
+
+
+ + +
+ +

Encryption +

+
+
+
    +
  • +
    + + + + usePassphrase(_:) + +
    +
    +
    +
    +
    +
    +

    Sets the passphrase used to crypt and decrypt an SQLCipher database.

    + +

    Call this method from Configuration.prepareDatabase, +as in the example below:

    +
    var config = Configuration()
    +config.prepareDatabase { db in
    +    try db.usePassphrase("secret")
    +}
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + changePassphrase(_:) + +
    +
    +
    +
    +
    +
    +

    Changes the passphrase used by an SQLCipher encrypted database.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Deletes the synchronization triggers for a synchronized FTS5 table

    + +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

FTS5 +

+
+
+
    +
  • +
    + + + + add(tokenizer:) + +
    +
    +
    +
    +
    +
    +

    Add a custom FTS5 tokenizer.

    +
    class MyTokenizer : FTS5CustomTokenizer { ... }
    +db.add(tokenizer: MyTokenizer.self)
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern from a raw pattern string; throws DatabaseError on +invalid syntax.

    + +

    The pattern syntax is documented at https://www.sqlite.org/fts5.html#full_text_query_syntax

    +
    try db.makeFTS5Pattern(rawPattern: "and", forTable: "document") // OK
    +try db.makeFTS5Pattern(rawPattern: "AND", forTable: "document") // malformed MATCH expression: [AND]
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + makeTokenizer(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an FTS5 tokenizer, given its descriptor.

    +
    let unicode61 = try db.makeTokenizer(.unicode61())
    +
    + +

    It is a programmer error to use the tokenizer outside of a protected +database queue, or after the database has been closed.

    + +

    Use this method when you implement a custom wrapper tokenizer:

    +
    final class MyTokenizer : FTS5WrapperTokenizer {
    +    var wrappedTokenizer: FTS5Tokenizer
    +
    +    init(db: Database, arguments: [String]) throws {
    +        wrappedTokenizer = try db.makeTokenizer(.unicode61())
    +    }
    +}
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Date.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Date.html new file mode 100644 index 000000000..7905b019a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Date.html @@ -0,0 +1,1278 @@ + + + + Date Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Date

+
+
+ +
extension Date: DatabaseValueConvertible
+
extension Date: StatementColumnConvertible
+ +
+
+

Date is stored in the database using the format +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a database value that contains the date encoded as +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a date initialized from dbValue, if possible.

    + +

    If database value contains a number, that number is interpreted as a +timeinterval since 00:00:00 UTC on 1 January 1970.

    + +

    If database value contains a string, that string is interpreted as a +SQLite date in the UTC time +zone. Nil is returned if the date string does not contain at least the +year, month and day components. Other components (minutes, etc.) +are set to zero if missing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Date?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(julianDay:) + +
    +
    +
    +
    +
    +
    +

    Creates a date from a Julian Day.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(julianDay: Double)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Decimal.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Decimal.html new file mode 100644 index 000000000..e4216e69d --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Decimal.html @@ -0,0 +1,1203 @@ + + + + Decimal Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Decimal

+
+
+ +
extension Decimal: DatabaseValueConvertible
+
extension Decimal: StatementColumnConvertible
+ +
+
+

Decimal adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Dictionary.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Dictionary.html new file mode 100644 index 000000000..51c3e60b3 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Dictionary.html @@ -0,0 +1,1411 @@ + + + + Dictionary Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Dictionary

+
+
+ +
extension Dictionary
+ +
+
+ +
+
+
+
    +
  • +
    + + + + init(grouping:by:) + +
    +
    +
    +
    +
    +
    +

    Creates a new dictionary whose keys are the groupings returned by the +given closure and whose values are arrays of the elements that returned +each key.

    +
    // [Int64: [Player]]
    +let cursor = try Player.fetchCursor(db)
    +let dictionary = try Dictionary(grouping: cursor, by: { $0.teamID })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(grouping cursor: C, by keyForValue: (C.Element) throws -> Key)
    +throws where Value == [C.Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + cursor + + +
    +

    A cursor of values to group into a dictionary.

    +
    +
    + + keyForValue + + +
    +

    A closure that returns a key for each element +in the cursor.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a new dictionary whose keys are the groupings returned by the +given closure and whose values are arrays of the elements that returned +each key.

    +
    // [Int64: [Player]]
    +let cursor = try Player.fetchCursor(db)
    +let dictionary = try Dictionary(
    +    minimumCapacity: 100,
    +    grouping: cursor,
    +    by: { $0.teamID })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(minimumCapacity: Int, grouping cursor: C, by keyForValue: (C.Element) throws -> Key)
    +throws where Value == [C.Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + minimumCapacity + + +
    +

    The minimum number of key-value pairs that +the newly created dictionary should be able to store without +reallocating its storage buffer.

    +
    +
    + + cursor + + +
    +

    A cursor of values to group into a dictionary.

    +
    +
    + + keyForValue + + +
    +

    A closure that returns a key for each element +in the cursor.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a new dictionary from the key-value pairs in the given cursor.

    + +

    You use this initializer to create a dictionary when you have a cursor +of key-value tuples with unique keys. Passing a cursor with duplicate +keys to this initializer results in a fatal error.

    +
    // [Int64: Player]
    +let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
    +let playerByID = try Dictionary(uniqueKeysWithValues: cursor)
    +
    +
    +

    Precondition

    + The cursor must not have duplicate keys. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(uniqueKeysWithValues keysAndValues: C)
    +throws where C.Element == (Key, Value)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + keysAndValues + + +
    +

    A cursor of key-value pairs to use for the +new dictionary. Every key in keysAndValues must be unique.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a new dictionary from the key-value pairs in the given cursor.

    + +

    You use this initializer to create a dictionary when you have a cursor +of key-value tuples with unique keys. Passing a cursor with duplicate +keys to this initializer results in a fatal error.

    +
    // [Int64: Player]
    +let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
    +let playerByID = try Dictionary(
    +    minimumCapacity: 100,
    +    uniqueKeysWithValues: cursor)
    +
    +
    +

    Precondition

    + The cursor must not have duplicate keys. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C: Cursor>(minimumCapacity: Int, uniqueKeysWithValues keysAndValues: C)
    +throws where C.Element == (Key, Value)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + minimumCapacity + + +
    +

    The minimum number of key-value pairs that +the newly created dictionary should be able to store without +reallocating its storage buffer.

    +
    +
    + + keysAndValues + + +
    +

    A cursor of key-value pairs to use for the +new dictionary. Every key in keysAndValues must be unique.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Double.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Double.html new file mode 100644 index 000000000..60ceecdac --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Double.html @@ -0,0 +1,1263 @@ + + + + Double Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Double

+
+ +
+

Double adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Double initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Double?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Float.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Float.html new file mode 100644 index 000000000..3ee1d1a12 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Float.html @@ -0,0 +1,1263 @@ + + + + Float Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Float

+ +

Float adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Float initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Float?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int.html new file mode 100644 index 000000000..722b30913 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int.html @@ -0,0 +1,1265 @@ + + + + Int Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int

+ +

Int adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int16.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int16.html new file mode 100644 index 000000000..329f782cf --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int16.html @@ -0,0 +1,1265 @@ + + + + Int16 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int16

+ +

Int16 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int16 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int16?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int32.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int32.html new file mode 100644 index 000000000..92de52ae3 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int32.html @@ -0,0 +1,1265 @@ + + + + Int32 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int32

+ +

Int32 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int32 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int32?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int64.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int64.html new file mode 100644 index 000000000..c1bd661b3 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int64.html @@ -0,0 +1,1263 @@ + + + + Int64 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int64

+ +

Int64 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int64 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int64?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int8.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int8.html new file mode 100644 index 000000000..7897078ec --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Int8.html @@ -0,0 +1,1265 @@ + + + + Int8 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Int8

+ +

Int8 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int8 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Int8?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSData.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSData.html new file mode 100644 index 000000000..87a499e78 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSData.html @@ -0,0 +1,1174 @@ + + + + NSData Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSData

+
+
+ +
extension NSData: DatabaseValueConvertible
+ +
+
+

NSData is convertible to and from DatabaseValue.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSData initialized from dbValue, if it contains +a Blob.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSDate.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSDate.html new file mode 100644 index 000000000..0f887ea07 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSDate.html @@ -0,0 +1,1184 @@ + + + + NSDate Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSDate

+
+
+ +
extension NSDate: DatabaseValueConvertible
+ +
+
+

NSDate is stored in the database using the format +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a database value that contains the date encoded as +“yyyy-MM-dd HH:mm:ss.SSS”, in the UTC time zone.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a date initialized from dbValue, if possible.

    + +

    If database value contains a number, that number is interpreted as a +timeinterval since 00:00:00 UTC on 1 January 1970.

    + +

    If database value contains a string, that string is interpreted as a +SQLite date in the UTC time +zone. Nil is returned if the date string does not contain at least the +year, month and day components. Other components (minutes, etc.) +are set to zero if missing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSNull.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSNull.html new file mode 100644 index 000000000..024d87477 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSNull.html @@ -0,0 +1,1173 @@ + + + + NSNull Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSNull

+
+
+ +
extension NSNull: DatabaseValueConvertible
+ +
+
+

NSNull adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSNumber.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSNumber.html new file mode 100644 index 000000000..43fc4be93 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSNumber.html @@ -0,0 +1,1173 @@ + + + + NSNumber Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSNumber

+
+
+ +
extension NSNumber: DatabaseValueConvertible
+ +
+
+

NSNumber adopts DatabaseValueConvertible

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSNumber initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSString.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSString.html new file mode 100644 index 000000000..8b7a1aa17 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSString.html @@ -0,0 +1,1173 @@ + + + + NSString Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSString

+
+
+ +
extension NSString: DatabaseValueConvertible
+ +
+
+

NSString adopts DatabaseValueConvertible

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSString initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSURL.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSURL.html new file mode 100644 index 000000000..903ca7978 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSURL.html @@ -0,0 +1,1174 @@ + + + + NSURL Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSURL

+
+
+ +
extension NSURL: DatabaseValueConvertible
+ +
+
+

NSURL stores its absoluteString in the database.

+ +
+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database. +(the URL’s absoluteString).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an NSURL initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> `Self`?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSUUID.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSUUID.html new file mode 100644 index 000000000..73f724d2a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/NSUUID.html @@ -0,0 +1,1171 @@ + + + + NSUUID Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

NSUUID

+
+
+ +
extension NSUUID: DatabaseValueConvertible
+ +
+
+

NSUUID adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Optional.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Optional.html new file mode 100644 index 000000000..80e78d1bf --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Optional.html @@ -0,0 +1,2906 @@ + + + + Optional Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Optional

+
+
+ +
extension Optional where Wrapped: DatabaseValueConvertible
+
extension Optional where Wrapped: DatabaseValueConvertible & Hashable
+
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible
+
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable
+ +
+
+

Swift’s Optional comes with built-in methods that allow to fetch cursors +and arrays of optional DatabaseValueConvertible:

+
try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String?
+try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String?]
+
+let statement = try db.makeStatement(sql: "SELECT name FROM ...")
+try Optional<String>.fetchCursor(statement, arguments:...) // Cursor of String?
+try Optional<String>.fetchAll(statement, arguments:...)    // [String?]
+
+ +

DatabaseValueConvertible is adopted by Bool, Int, String, etc.

+ +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> NullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchAll(statement)  // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchSet(statement)  // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> NullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from an SQL query.

    +
    let names = try String.fetchAll(db, sql: "SELECT name FROM ...") // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from an SQL query.

    +
    let names = try String.fetchSet(db, sql: "SELECT name FROM ...") // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchCursor(db, request) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R: FetchRequest>(_ db: Database, _ request: R)
    +throws -> NullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchAll(db, request) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Wrapped?] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchSet(db, request) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Wrapped?> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchCursor(statement) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> FastNullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchAll(statement)  // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try Optional<String>.fetchSet(statement)  // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> FastNullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchAll(db, sql: "SELECT name FROM ...") // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from an SQL query.

    +
    let names = try Optional<String>.fetchSet(db, sql: "SELECT name FROM ...") // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchCursor(db, request) // Cursor of String?
    +while let name = try names.next() { // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R: FetchRequest>(_ db: Database, _ request: R)
    +throws -> FastNullableDatabaseValueCursor<Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched optional values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an array of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchAll(db, request) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Wrapped?] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns a set of optional values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try Optional<String>.fetchSet(db, request) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Wrapped?> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of optional values.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Range.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Range.html new file mode 100644 index 000000000..09801a900 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Range.html @@ -0,0 +1,1154 @@ + + + + Range Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Range

+
+
+ +
extension Range where Bound: SQLExpressible
+ +
+
+ +
+
+
+
+ + +
+ +

Available where Bound: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a range.

    +
    // email >= 'A' AND email < 'B'
    +("A"..<"B").contains(Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/RangeReplaceableCollection.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/RangeReplaceableCollection.html new file mode 100644 index 000000000..ac38702cc --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/RangeReplaceableCollection.html @@ -0,0 +1,1231 @@ + + + + RangeReplaceableCollection Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RangeReplaceableCollection

+
+
+ +
extension RangeReplaceableCollection
+ +
+
+ +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a collection containing the elements of a cursor.

    +
    // [String]
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Array(cursor)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C) throws where C : Cursor, Self.Element == C.Element
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cursor + + +
    +

    The cursor whose elements feed the collection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a collection containing the elements of a cursor.

    +
    // [String]
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Array(cursor, minimumCapacity: 100)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C, minimumCapacity: Int) throws where C : Cursor, Self.Element == C.Element
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + cursor + + +
    +

    The cursor whose elements feed the collection.

    +
    +
    + + minimumCapacity + + +
    +

    Prepares the returned collection to store +the specified number of elements.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Sequence.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Sequence.html new file mode 100644 index 000000000..606799360 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Sequence.html @@ -0,0 +1,1415 @@ + + + + Sequence Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Sequence

+
+
+ +
extension Sequence
+
extension Sequence where Element == SQL
+
extension Sequence where Element: SQLSpecificExpressible
+
extension Sequence where Element == SQLSpecificExpressible
+
extension Sequence where Self.Iterator.Element: SQLExpressible
+
extension Sequence where Self.Iterator.Element == SQLExpressible
+ +
+
+ +
+
+
+
    +
  • +
    + + + + flatMap(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated results of mapping transform +over self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func flatMap<SegmentOfResult: Cursor>(
    +    _ transform: @escaping (Iterator.Element) throws -> SegmentOfResult)
    +-> FlattenCursor<MapCursor<AnyCursor<Iterator.Element>, SegmentOfResult>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element == SQL +

+
+
+
    +
  • +
    + + + + joined(separator:) + +
    +
    +
    +
    +
    +
    +

    Returns the concatenated SQL literal of this sequence of literals, +inserting the given separator between each element.

    +
    let components: [SQL] = [
    +    "UPDATE player",
    +    "SET name = \(name)",
    +    "WHERE id = \(id)"
    +]
    +let query = components.joined(separator: " ")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(separator: String = "") -> SQL
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: SQLSpecificExpressible +

+
+
+
    +
  • +
    + + + + joined(operator:) + +
    +
    +
    +
    +
    +
    +

    Returns an expression by joining all elements with an associative SQL +binary operator.

    + +

    For example:

    +
    // SELECT * FROM player
    +// WHERE (registered
    +//        AND (score >= 1000)
    +//        AND (name IS NOT NULL))
    +let conditions = [
    +    Column("registered"),
    +    Column("score") >= 1000,
    +    Column("name") != nil]
    +Player.filter(conditions.joined(operator: .and))
    +
    + +

    When the sequence is empty, joined(operator:) returns the neutral +value of the operator. It is 0 (zero) for .add, 1 for ‘.multiply, +false for.or, and true for.and`.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(operator: SQLExpression.AssociativeBinaryOperator) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element == SQLSpecificExpressible +

+
+
+
    +
  • +
    + + + + joined(operator:) + +
    +
    +
    +
    +
    +
    +

    Returns an expression by joining all elements with an associative SQL +binary operator.

    + +

    For example:

    +
    // SELECT * FROM player
    +// WHERE (registered
    +//        AND (score >= 1000)
    +//        AND (name IS NOT NULL))
    +let conditions = [
    +    Column("registered"),
    +    Column("score") >= 1000,
    +    Column("name") != nil]
    +Player.filter(conditions.joined(operator: .and))
    +
    + +

    When the sequence is empty, joined(operator:) returns the neutral +value of the operator. It is 0 (zero) for .add, 1 for ‘.multiply, +false for.or, and true for.and`.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(operator: SQLExpression.AssociativeBinaryOperator) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self.Iterator.Element: SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in +a sequence.

    +
    // id IN (1,2,3)
    +[1, 2, 3].contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self.Iterator.Element == SQLExpressible +

+
+
+
    +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in +a sequence.

    +
    // id IN (1,2,3)
    +[1, 2, 3].contains(Column("id"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Set.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Set.html new file mode 100644 index 000000000..ff605eefe --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/Set.html @@ -0,0 +1,1232 @@ + + + + Set Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Set

+
+
+ +
extension Set
+ +
+
+ +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a set containing the elements of a cursor.

    +
    // Set<String>
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Set(cursor)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C) throws where Element == C.Element, C : Cursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cursor + + +
    +

    A cursor of values to gather into a set.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a set containing the elements of a cursor.

    +
    // Set<String>
    +let cursor = try String.fetchCursor(db, ...)
    +let strings = try Set(cursor, minimumCapacity: 100)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<C>(_ cursor: C, minimumCapacity: Int) throws where Element == C.Element, C : Cursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + cursor + + +
    +

    A cursor of values to gather into a set.

    +
    +
    + + minimumCapacity + + +
    +

    The minimum number of elements that the +newly created set should be able to store without reallocating its +storage buffer.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/String.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/String.html new file mode 100644 index 000000000..4e015fc01 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/String.html @@ -0,0 +1,1309 @@ + + + + String Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

String

+
+ +
+

String adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a String initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> String?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Public +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns the receiver, quoted for safe insertion as an identifier in an +SQL query.

    +
    db.execute(sql: "SELECT * FROM \(tableName.quotedDatabaseIdentifier)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var quotedDatabaseIdentifier: String { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/TableRecord.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/TableRecord.html new file mode 100644 index 000000000..171ef381f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/TableRecord.html @@ -0,0 +1,1139 @@ + + + + TableRecord Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRecord

+ +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a QueryInterfaceRequest with a matching predicate.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/TableRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/TableRequest.html new file mode 100644 index 000000000..d26215c8e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/TableRequest.html @@ -0,0 +1,1145 @@ + + + + TableRequest Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRequest

+ +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with a full-text predicate added to the eventual +set of already applied predicates.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.all()
    +request = request.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt.html new file mode 100644 index 000000000..8f6c4bced --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt.html @@ -0,0 +1,1265 @@ + + + + UInt Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt

+ +

UInt adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an Int initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt16.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt16.html new file mode 100644 index 000000000..64618018d --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt16.html @@ -0,0 +1,1265 @@ + + + + UInt16 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt16

+
+ +
+

UInt16 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt16 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt16?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt32.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt32.html new file mode 100644 index 000000000..9da41def9 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt32.html @@ -0,0 +1,1265 @@ + + + + UInt32 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt32

+
+ +
+

UInt32 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt32 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt32?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt64.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt64.html new file mode 100644 index 000000000..0ce8a2c03 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt64.html @@ -0,0 +1,1265 @@ + + + + UInt64 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt64

+
+ +
+

UInt64 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt64 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt64?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt8.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt8.html new file mode 100644 index 000000000..dd4e699f2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UInt8.html @@ -0,0 +1,1265 @@ + + + + UInt8 Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UInt8

+ +

UInt8 adopts DatabaseValueConvertible and StatementColumnConvertible.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an UInt8 initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> UInt8?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UUID.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UUID.html new file mode 100644 index 000000000..d13665d92 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Extensions/UUID.html @@ -0,0 +1,1203 @@ + + + + UUID Extension Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

UUID

+
+
+ +
extension UUID: DatabaseValueConvertible
+
extension UUID: StatementColumnConvertible
+ +
+
+

UUID adopts DatabaseValueConvertible

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Functions.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Functions.html new file mode 100644 index 000000000..16bdf725b --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Functions.html @@ -0,0 +1,5270 @@ + + + + Functions Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Functions

+

The following functions are available globally.

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns an array of row adapters that split a row according to the input +number of columns.

    + +

    For example:

    +
    let sql = "SELECT 1, 2,3,4, 5,6, 7,8"
    +//               <.><. . .><. .><. .>
    +let adapters = splittingRowAdapters([1, 3, 2])
    +let adapter = ScopeAdapter([
    +    "a": adapters[0],
    +    "b": adapters[1],
    +    "c": adapters[2],
    +    "d": adapters[3]])
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)
    +row.scopes["a"] // [1]
    +row.scopes["b"] // [2, 3, 4]
    +row.scopes["c"] // [5, 6]
    +row.scopes["d"] // [7, 8]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func splittingRowAdapters(columnCounts: [Int]) -> [RowAdapter]
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Logical Operators (AND, OR, NOT) +

+
+
+ +
+
+
+ + +
+ +

Egality and Identity Operators (=, <>, IS, IS NOT) +

+
+
+
    +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the = SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count == Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the = SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count == 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the = SQL operator.

    + +

    For example:

    + +

    Author.having(3 == Author.books.count)

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(Author.books.isEmpty == false)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(false == Author.books.isEmpty)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == <RowDecoder>(lhs: Bool, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the <> SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count != Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the <> SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count != 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the <> SQL operator.

    + +

    For example:

    +
    Author.having(3 != Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(Author.books.isEmpty != true)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that checks the boolean value of an aggregate.

    + +

    For example:

    +
    Author.having(true != Author.books.isEmpty)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != <RowDecoder>(lhs: Bool, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the IS SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count === Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count === 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS SQL operator.

    + +

    For example:

    +
    Author.having(3 === Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares two aggregates with the IS NOT SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count !== Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

    + +

    For example:

    +
    Author.having(Author.books.count !== 3)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

    + +

    For example:

    +
    Author.having(3 !== Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Comparison Operators (<, >, <=, >=) +

+
+
+ +
+
+
+ + +
+ +

Arithmetic Operators (+, -, *, /) +

+
+
+
    +
  • +
    + + + + -(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an arithmetically negated aggregate.

    + +

    For example:

    +
    Author.annotated(with: -Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public prefix func - <RowDecoder>(aggregate: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that sums two aggregates with the + SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count + Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func + <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that sums an aggregate with the + SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count + 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func + <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that sums an aggregate with the + SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 1 + Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func + <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts two aggregates with the - SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count - Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func - <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the - SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count - 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func - <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the - SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 1 - Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func - <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that multiplies two aggregates with the * SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count * Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func * <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the * SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count * 2)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func * <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the * SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 2 * Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func * <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that multiplies two aggregates with the / SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count / Author.paintings.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func / <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the / SQL operator.

    + +

    For example:

    +
    Author.annotated(with: Author.books.count / 2)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func / <RowDecoder>(
    +    lhs: AssociationAggregate<RowDecoder>,
    +    rhs: SQLExpressible)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that substracts an aggregate with the / SQL operator.

    + +

    For example:

    +
    Author.annotated(with: 2 / Author.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func / <RowDecoder>(
    +    lhs: SQLExpressible,
    +    rhs: AssociationAggregate<RowDecoder>)
    +-> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

IFNULL(…) +

+
+
+ +
+
+
+ + +
+ +

ColumnAssignment +

+
+
+
    +
  • +
    + + + + +=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that adds a value

    +
    Column("score") += 1
    +Column("score") += Column("bonus")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score + 1
    +    try Player.updateAll(db, Column("score") += 1)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func += (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + -=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that subtracts a value

    +
    Column("score") -= 1
    +Column("score") -= Column("bonus")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score - 1
    +    try Player.updateAll(db, Column("score") -= 1)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func -= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + *=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that multiplies by a value

    +
    Column("score") *= 2
    +Column("score") *= Column("factor")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score * 2
    +    try Player.updateAll(db, Column("score") *= 2)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func *= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + /=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates an assignment that divides by a value

    +
    Column("score") /= 2
    +Column("score") /= Column("factor")
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = score / 2
    +    try Player.updateAll(db, Column("score") /= 2)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func /= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ABS(…) +

+
+
+ +
+
+
+ + +
+ +

AVG(…) +

+
+
+ +
+
+
+ + +
+ +

COUNT(…) +

+
+
+ +
+
+
+ + +
+ +

COUNT(DISTINCT …) +

+
+
+ +
+
+
+ + +
+ +

IFNULL(…) +

+
+
+ +
+
+
+ + +
+ +

LENGTH(…) +

+
+
+ +
+
+
+ + +
+ +

MAX(…) +

+
+
+ +
+
+
+ + +
+ +

MIN(…) +

+
+
+ +
+
+
+ + +
+ +

SUM(…) +

+
+
+ +
+
+
+ + +
+ +

JULIANDAY(…) +

+
+
+ +
+
+
+ + +
+ +

DATETIME(…) +

+
+
+ +
+
+
+ + +
+ +

Egality and Identity Operators (=, <>, IS, IS NOT) +

+
+
+
    +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the = SQL operator.

    +
    // name = 'Arthur'
    +Column("name") == "Arthur"
    +
    + +

    When the right operand is nil, IS NULL is used instead.

    +
    // name IS NULL
    +Column("name") == nil
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // validated
    +Column("validated") == true
    +
    +// NOT validated
    +Column("validated") == false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the = SQL operator.

    +
    // 'Arthur' = name
    +"Arthur" == Column("name")
    +
    + +

    When the left operand is nil, IS NULL is used instead.

    +
    // name IS NULL
    +nil == Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // validated
    +true == Column("validated")
    +
    +// NOT validated
    +false == Column("validated")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the = SQL operator.

    +
    // email = login
    +Column("email") == Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func == (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the <> SQL operator.

    +
    // name <> 'Arthur'
    +Column("name") != "Arthur"
    +
    + +

    When the right operand is nil, IS NOT NULL is used instead.

    +
    // name IS NOT NULL
    +Column("name") != nil
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // NOT validated
    +Column("validated") != true
    +
    +// validated
    +Column("validated") != false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the <> SQL operator.

    +
    // 'Arthur' <> name
    +"Arthur" != Column("name")
    +
    + +

    When the left operand is nil, IS NOT NULL is used instead.

    +
    // name IS NOT NULL
    +nil != Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the boolean value of an expression.

    + +

    The comparison is done with the built-in boolean evaluation of SQLite:

    +
    // NOT validated
    +true != Column("validated")
    +
    +// validated
    +false != Column("validated")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !=(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the <> SQL operator.

    +
    // email <> login
    +Column("email") != Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func != (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS SQL operator.

    +
    // name IS 'Arthur'
    +Column("name") === "Arthur"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS SQL operator.

    +
    // name IS 'Arthur'
    +"Arthur" === Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ===(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS SQL operator.

    +
    // email IS login
    +Column("email") === Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func === (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS NOT SQL operator.

    +
    // name IS NOT 'Arthur'
    +Column("name") !== "Arthur"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS NOT SQL operator.

    +
    // name IS NOT 'Arthur'
    +"Arthur" !== Column("name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + !==(_:_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that compares two expressions with the IS NOT SQL operator.

    +
    // email IS NOT login
    +Column("email") !== Column("login")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func !== (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Comparison Operators (<, >, <=, >=) +

+
+
+ +
+
+
+ + +
+ +

Arithmetic Operators (+, -, *, /) +

+
+
+ +
+
+
+ + +
+ +

Logical Operators (AND, OR, NOT) +

+
+
+ +
+
+
+ + +
+ +

Public +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Return as many question marks separated with commas as the count argument.

    +
    databaseQuestionMarks(count: 3) // "?,?,?"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseQuestionMarks(count: Int) -> String
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols.html new file mode 100644 index 000000000..6398f614b --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols.html @@ -0,0 +1,2786 @@ + + + + Protocols Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Protocols

+

The following protocols are available globally.

+ +
+
+
+
+ + +
+ +

Cursor +

+
+
+
    +
  • +
    + + + + Cursor + +
    +
    +
    +
    +
    +
    +

    A type that supplies the values of some external resource, one at a time.

    +

    Overview

    + +

    The most common way to iterate over the elements of a cursor is to use a +while loop:

    +
    let cursor = ...
    +while let element = try cursor.next() {
    +    ...
    +}
    +
    +

    Relationship with standard Sequence and IteratorProtocol

    + +

    Cursors share traits with lazy sequences and iterators from the Swift +standard library. Differences are:

    + +
      +
    • Cursor types are classes, and have a lifetime.
    • +
    • Cursor iteration may throw errors.
    • +
    • A cursor can not be repeated.
    • +
    + +

    The protocol comes with default implementations for many operations similar +to those defined by Swift’s Sequence protocol: contains, dropFirst, +dropLast, drop(while:), enumerated, filter, first, flatMap, +forEach, joined, joined(separator:), max, max(by:), min, +min(by:), map, prefix, prefix(while:), reduce, reduce(into:), +suffix.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol Cursor : AnyObject
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseAggregate + +
    +
    +
    +
    +
    +
    +

    The protocol for custom SQLite aggregates.

    + +

    For example:

    +
    struct MySum : DatabaseAggregate {
    +    var sum: Int = 0
    +
    +    mutating func step(_ dbValues: [DatabaseValue]) {
    +        if let int = Int.fromDatabaseValue(dbValues[0]) {
    +            sum += int
    +        }
    +    }
    +
    +    func finalize() -> DatabaseValueConvertible? {
    +        return sum
    +    }
    +}
    +
    +let dbQueue = DatabaseQueue()
    +let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
    +try dbQueue.write { db in
    +    db.add(function: fn)
    +    try db.execute(sql: "CREATE TABLE test(i)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (1)")
    +    try db.execute(sql: "INSERT INTO test(i) VALUES (2)")
    +    try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseAggregate
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseReader + +
    +
    +
    +
    +
    +
    +

    DatabaseReader is the protocol for all types that can fetch values from +an SQLite database.

    + +

    It is adopted by DatabaseQueue, DatabasePool, and DatabaseSnapshot.

    + +

    The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

    + +

    Types that adopt the protocol can provide in practice stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

    + +

    Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseReader : AnyObject
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseRegionConvertible +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    DatabaseRegionConvertible is the protocol for values that can be turned +into a DatabaseRegion.

    + +

    Such values specify the region obserbed by DatabaseRegionObservation.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Types that adopt DatabaseValueConvertible can be initialized from +database values.

    + +

    The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single values:

    +
    try String.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String
    +try String.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String]
    +try String.fetchOne(db, sql: "SELECT name FROM ...", arguments:...)    // String?
    +
    +let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +try String.fetchCursor(statement, arguments:...) // Cursor of String
    +try String.fetchAll(statement, arguments:...)    // [String]
    +try String.fetchOne(statement, arguments:...)    // String?
    +
    + +

    DatabaseValueConvertible is adopted by Bool, Int, String, etc.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseValueConvertible : SQLExpressible, StatementBinding
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FetchRequest +

+
+
+
    +
  • +
    + + + + FetchRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that fetch database rows, and tell how those +rows should be interpreted.

    +
    struct Player: FetchableRecord { ... }
    +let request: ... // Some FetchRequest that fetches Player
    +try request.fetchCursor(db) // Cursor of Player
    +try request.fetchAll(db)    // [Player]
    +try request.fetchSet(db)    // Set<Player>
    +try request.fetchOne(db)    // Player?
    +try request.fetchCount(db)  // Int
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol FetchRequest : DatabaseRegionConvertible, SQLSubqueryable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseWriter + +
    +
    +
    +
    +
    +
    +

    DatabaseWriter is the protocol for all types that can write into an +SQLite database.

    + +

    It is adopted by DatabaseQueue and DatabasePool.

    + +

    The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

    + +

    Types that adopt the protocol can in practice provide stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

    + +

    Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol DatabaseWriter : DatabaseReader
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + RowAdapter + +
    +
    +
    +
    +
    +
    +

    RowAdapter is a protocol that helps two incompatible row interfaces +working together.

    + +

    GRDB ships with four concrete types that adopt the RowAdapter protocol:

    + + + +

    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)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol RowAdapter : _RowAdapter
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementBinding +

+
+
+
    +
  • +
    + + + + StatementBinding + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol StatementBinding
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The StatementColumnConvertible protocol grants access to the low-level C +interface that extracts values from query results: +https://www.sqlite.org/c3ref/column_blob.html. It can bring performance +improvements.

    + +

    To use it, have a value type adopt both StatementColumnConvertible and +DatabaseValueConvertible. GRDB will then automatically apply the +optimization whenever direct access to SQLite is possible:

    +
    let rows = Row.fetchCursor(db, sql: "SELECT ...")
    +while let row = try rows.next() {
    +    let int: Int = row[0]                 // there
    +}
    +let ints = Int.fetchAll(db, sql: "SELECT ...") // there
    +struct Player {
    +    init(row: Row) {
    +        name = row["name"]                // there
    +        score = row["score"]              // there
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol StatementColumnConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQLSelectable +

+
+
+ +
+
+
+ + +
+ +

SQLOrderingTerm +

+
+
+ +
+
+
+ + +
+ +

SQLExpressible +

+
+
+ +
+
+
+ + +
+ +

TransactionObserver +

+
+
+
    +
  • +
    + + + + TransactionObserver + +
    +
    +
    +
    +
    +
    +

    A transaction observer is notified of all changes and transactions committed +or rollbacked on a database.

    + +

    Adopting types must be a class.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TransactionObserver : AnyObject
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5CustomTokenizer + +
    +
    +
    +
    +
    +
    +

    The protocol for custom FTS5 tokenizers.

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5Tokenizer + +
    +
    +
    +
    +
    +
    +

    The protocol for FTS5 tokenizers

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5WrapperTokenizer + +
    +
    +
    +
    +
    +
    +

    The protocol for custom FTS5 tokenizers that wrap another tokenizer.

    + +

    Types that adopt FTS5WrapperTokenizer don’t have to implement the +low-level FTS5Tokenizer.tokenize(context:flags:pText:nText:tokenCallback:).

    + +

    Instead, they process regular Swift strings.

    + +

    Here is the implementation for a trivial tokenizer that wraps the +built-in ascii tokenizer without any custom processing:

    +
    class TrivialAsciiTokenizer : FTS5WrapperTokenizer {
    +    static let name = "trivial"
    +    let wrappedTokenizer: FTS5Tokenizer
    +
    +    init(db: Database, arguments: [String]) throws {
    +        wrappedTokenizer = try db.makeTokenizer(.ascii())
    +    }
    +
    +    func accept(
    +        token: String,
    +        flags: FTS5TokenFlags,
    +        for tokenization: FTS5Tokenization,
    +        tokenCallback: FTS5WrapperTokenCallback)
    +        throws
    +    {
    +        try tokenCallback(token, flags)
    +    }
    +}
    +
    + + See more +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

TableRequest +

+
+
+
    +
  • +
    + + + + TableRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that feed from a database table

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TableRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + TableRecord + +
    +
    +
    +
    +
    +
    +

    Types that adopt TableRecord declare a particular relationship with +a database table.

    + +

    Types that adopt both TableRecord and FetchableRecord are granted with +built-in methods that allow to fetch instances identified by key:

    +
    try Player.fetchOne(db, key: 123)  // Player?
    +try Citizenship.fetchOne(db, key: ["citizenId": 12, "countryId": 45]) // Citizenship?
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnExpression + +
    +
    +
    +
    +
    +
    +

    Adopt the ColumnExpression protocol when you define a column type.

    + +

    You can, for example, define a String-based column enum:

    +
    enum Columns: String, ColumnExpression {
    +    case id, name, score
    +}
    +let arthur = try Player.filter(Columns.name == "Arthur").fetchOne(db)
    +
    + +

    You can also define a genuine column type:

    +
    struct MyColumn: ColumnExpression {
    +    var name: String
    +    var sqlType: String
    +}
    +let nameColumn = MyColumn(name: "name", sqlType: "VARCHAR")
    +let arthur = try Player.filter(nameColumn == "Arthur").fetchOne(db)
    +
    + +

    See https://github.com/groue/GRDB.swift#the-query-interface

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol ColumnExpression : SQLSpecificExpressible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Association + +
    +
    +
    +
    +
    +
    +

    The base protocol for all associations that define a connection between two +record types.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol Association : DerivableRequest, _Association
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AssociationToOne +

+
+
+
    +
  • +
    + + + + AssociationToOne + +
    +
    +
    +
    +
    +
    +

    The base protocol for all associations that define a one-to-one connection.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol AssociationToOne : Association
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AssociationToMany +

+
+
+
    +
  • +
    + + + + AssociationToMany + +
    +
    +
    +
    +
    +
    +

    The base protocol for all associations that define a one-to-many connection.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol AssociationToMany : Association
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

TypedRequest +

+
+
+
    +
  • +
    + + + + TypedRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that know how database rows should +be interpreted.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol TypedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SelectionRequest +

+
+
+
    +
  • +
    + + + + SelectionRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can refine their selection.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol SelectionRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FilteredRequest +

+
+
+
    +
  • +
    + + + + FilteredRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can be filtered.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol FilteredRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AggregatingRequest +

+
+
+
    +
  • +
    + + + + AggregatingRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can aggregate.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol AggregatingRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

OrderedRequest +

+
+
+
    +
  • +
    + + + + OrderedRequest + +
    +
    +
    +
    +
    +
    +

    The protocol for all requests that can be ordered.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol OrderedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

JoinableRequest +

+
+
+ +
+
+
+ + +
+ +

DerivableRequest +

+
+
+ +
+
+
+ + +
+ +

SQLSubqueryable +

+
+
+
    +
  • +
    + + + + SQLSubqueryable + +
    +
    +
    +
    +
    +
    +

    The protocol for types that can be embedded as a subquery.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol SQLSubqueryable : SQLSpecificExpressible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + VirtualTableModule + +
    +
    +
    +
    +
    +
    +

    The protocol for SQLite virtual table modules. It lets you define a DSL for +the Database.create(virtualTable:using:) method:

    +
    let module = ...
    +try db.create(virtualTable: "item", using: module) { t in
    +    ...
    +}
    +
    + +

    GRDB ships with three concrete classes that implement this protocol: FTS3, +FTS4 and FTS5.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol VirtualTableModule
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + EncodableRecord + +
    +
    +
    +
    +
    +
    +

    Types that adopt EncodableRecord can be encoded into the database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol EncodableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FetchableRecord + +
    +
    +
    +
    +
    +
    +

    Types that adopt FetchableRecord can be initialized from a database Row.

    +
    let row = try Row.fetchOne(db, sql: "SELECT ...")!
    +let player = Player(row)
    +
    + +

    The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single records:

    +
    try Player.fetchCursor(db, sql: "SELECT ...", arguments:...) // Cursor of Player
    +try Player.fetchAll(db, sql: "SELECT ...", arguments:...)    // [Player]
    +try Player.fetchOne(db, sql: "SELECT ...", arguments:...)    // Player?
    +
    +let statement = try db.makeStatement(sql: "SELECT ...")
    +try Player.fetchCursor(statement, arguments:...) // Cursor of Player
    +try Player.fetchAll(statement, arguments:...)    // [Player]
    +try Player.fetchOne(statement, arguments:...)    // Player?
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol FetchableRecord
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Types that adopt MutablePersistableRecord can be inserted, updated, +and deleted.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public protocol MutablePersistableRecord : EncodableRecord, TableRecord
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

PersistableRecord +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AggregatingRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AggregatingRequest.html new file mode 100644 index 000000000..844490ef0 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AggregatingRequest.html @@ -0,0 +1,1341 @@ + + + + AggregatingRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AggregatingRequest

+
+
+ +
public protocol AggregatingRequest
+ +
+
+

The protocol for all requests that can aggregate.

+ + +
+
+
+
    +
  • +
    + + + + group(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request grouped according to expressions promise.

    + +
    +

    Default Implementation

    +
    +

    Creates a request grouped according to expressions.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    + +
    +

    Default Implementation

    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func having(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AggregatingRequest +

+
+
+
    +
  • +
    + + + + group(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with a new grouping.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + group(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with a new grouping.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided sql added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided SQL literal added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/Association.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/Association.html new file mode 100644 index 000000000..2a877d62f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/Association.html @@ -0,0 +1,1746 @@ + + + + Association Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Association

+
+
+ +
public protocol Association : DerivableRequest, _Association
+ +
+
+

The base protocol for all associations that define a connection between two +record types.

+ + +
+
+
+
    +
  • +
    + + + + OriginRowDecoder + +
    +
    +
    +
    +
    +
    +

    The record type at the origin of the association.

    + +

    In the belongsTo association below, it is Book:

    +
    struct Book: TableRecord {
    +    // BelongsToAssociation<Book, Author>
    +    static let author = belongsTo(Author.self)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + forKey(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates an association with the given key.

    + +

    This new key impacts how rows fetched from the resulting association +should be consumed:

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// Consume rows:
    +let request = Player.including(required: Player.team.forKey("custom"))
    +for row in Row.fetchAll(db, request) {
    +    let team: Team = row["custom"]
    +}
    +
    + +
    +

    Default Implementation

    +
    +

    Creates an association with the given key.

    + +

    This new key helps Decodable records decode rows fetched from the +resulting association:

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +struct PlayerInfo: FetchableRecord, Decodable {
    +    let player: Player
    +    let team: Team
    +
    +    static func all() -> QueryInterfaceRequest<PlayerInfo> {
    +        return Player
    +            .including(required: Player.team.forKey(CodingKeys.team))
    +            .asRequest(of: PlayerInfo.self)
    +    }
    +}
    +
    +let playerInfos = PlayerInfo.all().fetchAll(db)
    +print(playerInfos.first?.team)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func forKey(_ key: String) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.color = ‘red’” condition in the where +clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ...
    +// WHERE team.color = 'red'
    +let teamAlias = TableAlias()
    +let request = Player
    +    .including(required: Player.team.aliased(teamAlias))
    +    .filter(teamAlias[Column("color")] == "red")
    +
    + +

    When you give a name to a table alias, you can reliably inject sql +snippets in your requests:

    +
    // SELECT player.*, custom.*
    +// JOIN team custom ON ...
    +// WHERE custom.color = 'red'
    +let teamAlias = TableAlias(name: "custom")
    +let request = Player
    +    .including(required: Player.team.aliased(teamAlias))
    +    .filter(sql: "custom.color = ?", arguments: ["red"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func aliased(_ alias: TableAlias) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association which selects selection.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.color
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team.select { db in [Column("color")]
    +var request = Player.including(required: association)
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT player.*, team.color
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team
    +    .select { db in [Column("id")] }
    +    .select { db in [Column("color") }
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association which appends selection.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.color, team.name
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team
    +    .select([Column("color")])
    +    .annotated(with: { db in [Column("name")] })
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association with the provided predicate promise added to +the eventual set of already applied predicates.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId AND 1
    +let association = Player.team.filter { db in true }
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association with the provided orderings promise.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +// ORDER BY team.name
    +let association = Player.team.order { _ in [Column("name")] }
    +var request = Player.including(required: association)
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +// ORDER BY team.name
    +let association = Player.team
    +    .order{ _ in [Column("color")] }
    +    .reversed()
    +    .order{ _ in [Column("name")] }
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reversed() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association that reverses applied orderings.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +// ORDER BY team.name DESC
    +let association = Player.team.order(Column("name")).reversed()
    +var request = Player.including(required: association)
    +
    + +

    If no ordering was applied, the returned association is identical.

    +
    // SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team.reversed()
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reversed() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unordered() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association without any ordering.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let association = Player.team.order(Column("name")).unordered()
    +var request = Player.including(required: association)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unordered() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseTableName + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseTableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + group(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association grouped according to expressions promise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association with the provided predicate promise added to +the eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + distinct() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association for returns distinct rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func distinct() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an association that embeds the common table expression.

    + +

    See QueryInterfaceRequest.with(_:) for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AssociationToMany.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AssociationToMany.html new file mode 100644 index 000000000..b6cafeeb5 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AssociationToMany.html @@ -0,0 +1,1647 @@ + + + + AssociationToMany Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociationToMany

+
+
+ +
public protocol AssociationToMany : Association
+ +
+
+

The base protocol for all associations that define a one-to-many connection.

+ + +
+
+
+
+ + +
+ +

AssociationToMany +

+
+
+
    +
  • +
    + + + + forKey(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: String) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + count + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The number of associated records.

    + +

    It has a default name, which is “[key]Count”, where key is the key of +the association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var playerCount: Int
    +}
    +let request = Team.annotated(with: Team.players.count())
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.count() > 10).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var count: AssociationAggregate<OriginRowDecoder> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isEmpty + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate that is true if there exists no associated records.

    + +

    It has a default name, which is “hasNo[Key]”, where key is the key of +the association. For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var hasNoPlayer: Bool
    +}
    +let request = Team.annotated(with: Team.players.isEmpty())
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.isEmpty()).fetchAll(db)
    +let teams: [Team] = try Team.having(!Team.players.isEmpty())
    +let teams: [Team] = try Team.having(Team.players.isEmpty() == false)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: AssociationAggregate<OriginRowDecoder> { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + average(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the average value of the given +expression in associated records.

    + +

    When the averaged expression is a column, the aggregate has a default +name which is “average[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var averagePlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.average(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.average(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean average(Column(...﹚﹚? If not, prefer average(value.databaseValue﹚ instead.")
    +public func average(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + average(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the average value of the given +expression in associated records.

    + +

    When the averaged expression is a column, the aggregate has a default +name which is “average[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var averagePlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.average(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.average(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func average(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + max(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the maximum value of the given +expression in associated records.

    + +

    When the maximized expression is a column, the aggregate has a default +name which is “maximum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var maxPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.max(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.max(Column("score")) < 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean max(Column(...﹚﹚? If not, prefer max(value.databaseValue﹚ instead.")
    +public func max(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + max(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the maximum value of the given +expression in associated records.

    + +

    When the maximized expression is a column, the aggregate has a default +name which is “maximum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var maxPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.max(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.max(Column("score")) < 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func max(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + min(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the minimum value of the given +expression in associated records.

    + +

    When the minimized expression is a column, the aggregate has a default +name which is “minimum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var minPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.min(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.min(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean min(Column(...﹚﹚? If not, prefer min(value.databaseValue﹚ instead.")
    +public func min(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + min(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the minimum value of the given +expression in associated records.

    + +

    When the minimized expression is a column, the aggregate has a default +name which is “minimum[Key][Column]”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var minPlayerScore: Double
    +}
    +let request = Team.annotated(with: Team.players.min(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.min(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func min(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sum(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the sum of the given expression +in associated records.

    + +

    When the summed expression is a column, the aggregate has a default +name which is “[key][Column]Sum”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var playerScoreSum: Double
    +}
    +let request = Team.annotated(with: Team.players.sum(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.sum(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean sum(Column(...﹚﹚? If not, prefer sum(value.databaseValue﹚ instead.")
    +public func sum(_ expression: SQLExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sum(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate which evaluate to the sum of the given expression +in associated records.

    + +

    When the summed expression is a column, the aggregate has a default +name which is “[key][Column]Sum”, where key is the key of the +association. For example:

    + +

    For example:

    +
    struct TeamInfo: FetchableRecord, Decodable {
    +    var team: Team
    +    var playerScoreSum: Double
    +}
    +let request = Team.annotated(with: Team.players.sum(Column("score")))
    +let infos: [TeamInfo] = try TeamInfo.fetchAll(db, request)
    +
    +let teams: [Team] = try Team.having(Team.players.sum(Column("score")) > 100).fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func sum(_ expression: SQLSpecificExpressible) -> AssociationAggregate<OriginRowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AssociationToOne.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AssociationToOne.html new file mode 100644 index 000000000..3cac3dc78 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/AssociationToOne.html @@ -0,0 +1,1157 @@ + + + + AssociationToOne Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociationToOne

+
+
+ +
public protocol AssociationToOne : Association
+ +
+
+

The base protocol for all associations that define a one-to-one connection.

+ + +
+
+
+
+ + +
+ +

AssociationToOne +

+
+
+
    +
  • +
    + + + + forKey(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: String) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/ColumnExpression.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/ColumnExpression.html new file mode 100644 index 000000000..f562188ce --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/ColumnExpression.html @@ -0,0 +1,1339 @@ + + + + ColumnExpression Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnExpression

+
+
+ +
public protocol ColumnExpression : SQLSpecificExpressible
+ +
+
+

Adopt the ColumnExpression protocol when you define a column type.

+ +

You can, for example, define a String-based column enum:

+
enum Columns: String, ColumnExpression {
+    case id, name, score
+}
+let arthur = try Player.filter(Columns.name == "Arthur").fetchOne(db)
+
+ +

You can also define a genuine column type:

+
struct MyColumn: ColumnExpression {
+    var name: String
+    var sqlType: String
+}
+let nameColumn = MyColumn(name: "name", sqlType: "VARCHAR")
+let arthur = try Player.filter(nameColumn == "Arthur").fetchOne(db)
+
+ +

See https://github.com/groue/GRDB.swift#the-query-interface

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The unqualified name of a database column.

    + +

    “score” is a valid unqualified name. “player.score” is not.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var name: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + match(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A matching SQL expression with the MATCH SQL operator.

    +
    // content MATCH '...'
    +Column("content").match(pattern)
    +
    + +

    If the search pattern is nil, SQLite will evaluate the expression +to false.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func match(_ pattern: FTS3Pattern?) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ColumnAssignment +

+
+
+
    +
  • +
    + + + + set(to:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an assignment to a value.

    +
    Column("valid").set(to: true)
    +Column("score").set(to: 0)
    +Column("score").set(to: nil)
    +Column("score").set(to: Column("score") + Column("bonus"))
    +
    +try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.updateAll(db, Column("score").set(to: 0))
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func set(to value: SQLExpressible?) -> ColumnAssignment
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlExpression + + + Extension method + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self == Column +

+
+
+
    +
  • +
    + + + + rowID + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The hidden rowID column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var rowID: Self { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/Cursor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/Cursor.html new file mode 100644 index 000000000..1981978f0 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/Cursor.html @@ -0,0 +1,2574 @@ + + + + Cursor Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Cursor

+
+
+ +
public protocol Cursor : AnyObject
+ +
+
+

A type that supplies the values of some external resource, one at a time.

+

Overview

+ +

The most common way to iterate over the elements of a cursor is to use a +while loop:

+
let cursor = ...
+while let element = try cursor.next() {
+    ...
+}
+
+

Relationship with standard Sequence and IteratorProtocol

+ +

Cursors share traits with lazy sequences and iterators from the Swift +standard library. Differences are:

+ +
    +
  • Cursor types are classes, and have a lifetime.
  • +
  • Cursor iteration may throw errors.
  • +
  • A cursor can not be repeated.
  • +
+ +

The protocol comes with default implementations for many operations similar +to those defined by Swift’s Sequence protocol: contains, dropFirst, +dropLast, drop(while:), enumerated, filter, first, flatMap, +forEach, joined, joined(separator:), max, max(by:), min, +min(by:), map, prefix, prefix(while:), reduce, reduce(into:), +suffix.

+ + +
+
+
+
    +
  • +
    + + + + Element + +
    +
    +
    +
    +
    +
    +

    The type of element traversed by the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype Element
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + next() + +
    +
    +
    +
    +
    +
    +

    Advances to the next element and returns it, or nil if no next element +exists. Once nil has been returned, all subsequent calls return nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func next() throws -> Element?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Cursor +

+
+
+
    +
  • +
    + + + + isEmpty() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Boolean value indicating whether the cursor contains +an element.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isEmpty() throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + contains(where:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Boolean value indicating whether the cursor contains an +element that satisfies the given predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(where predicate: (Element) throws -> Bool) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + predicate + + +
    +

    A closure that takes an element of the cursor as +its argument and returns a Boolean value that indicates whether the +passed element represents a match.

    +
    +
    +
    +
    +

    Return Value

    +

    true if the cursor contains an element that satisfies +predicate; otherwise, false.

    +
    + +
    +
    +
  • +
  • +
    + + + + enumerated() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor of pairs (n, x), where n represents a consecutive +integer starting at zero, and x represents an element of the cursor.

    +
    let cursor = try String.fetchCursor(db, sql: "SELECT 'foo' UNION ALL SELECT 'bar'")
    +let c = cursor.enumerated()
    +while let (n, x) = c.next() {
    +    print("\(n): \(x)")
    +}
    +// Prints: "0: foo"
    +// Prints: "1: bar"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func enumerated() -> EnumeratedCursor<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of the cursor that satisfy the given predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ isIncluded: @escaping (Element) throws -> Bool) -> FilterCursor<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + first(where:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the first element of the cursor that satisfies the given +predicate or nil if no such element is found.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func first(where predicate: (Element) throws -> Bool) throws -> Element?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + compactMap(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated non-nil results of mapping +transform over this cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func compactMap<ElementOfResult>(_ transform: @escaping (Element) throws -> ElementOfResult?)
    +-> MapCursor<FilterCursor<MapCursor<Self, ElementOfResult?>>, ElementOfResult>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + drop(while:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor that skips any initial elements that satisfy +predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func drop(while predicate: @escaping (Element) throws -> Bool) -> DropWhileCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + predicate + + +
    +

    A closure that takes an element of the cursir as +its argument and returns true if the element should be skipped or +false otherwise. Once predicate returns false it will not be +called again.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + dropFirst(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor containing all but the given number of initial +elements.

    + +

    If the number of elements to drop exceeds the number of elements in +the cursor, the result is an empty cursor.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropFirst(2))
    +// Prints "[3, 4, 5]"
    +try print(numbers.dropFirst(10))
    +// Prints "[]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropFirst(_ n: Int) -> DropFirstCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + n + + +
    +

    The number of elements to drop from the beginning of +the cursor. n must be greater than or equal to zero.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor starting after the specified number of +elements.

    +
    + +
    +
    +
  • +
  • +
    + + + + dropFirst() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor containing all but the first element of the cursor.

    + +

    The following example drops the first element from a cursor of integers.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropFirst())
    +// Prints "[2, 3, 4, 5]"
    +
    + +

    If the cursor has no elements, the result is an empty cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropFirst() -> DropFirstCursor<Self>
    + +
    +
    +
    +

    Return Value

    +

    A cursor starting after the first element of the cursor.

    +
    + +
    +
    +
  • +
  • +
    + + + + dropLast(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array containing all but the given number of final +elements.

    + +

    The cursor must be finite. If the number of elements to drop exceeds +the number of elements in the cursor, the result is an empty array.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropLast(2))
    +// Prints "[1, 2, 3]"
    +try print(numbers.dropLast(10))
    +// Prints "[]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropLast(_ n: Int) throws -> [Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + n + + +
    +

    The number of elements to drop off the end of the +cursor. n must be greater than or equal to zero.

    +
    +
    +
    +
    +

    Return Value

    +

    An array leaving off the specified number of elements.

    +
    + +
    +
    +
  • +
  • +
    + + + + dropLast() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array containing all but the last element of the cursor.

    + +

    The following example drops the last element from a cursor of integers.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.dropLast())
    +// Prints "[1, 2, 3, 4]"
    +
    + +

    If the cursor has no elements, the result is an empty cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func dropLast() throws -> [Element]
    + +
    +
    +
    +

    Return Value

    +

    An array leaving off the last element of the cursor.

    +
    + +
    +
    +
  • +
  • +
    + + + + flatMap(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated results of mapping transform +over self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func flatMap<SegmentOfResult>(_ transform: @escaping (Element) throws -> SegmentOfResult)
    +-> FlattenCursor<MapCursor<Self, AnyCursor<SegmentOfResult.Element>>>
    +where SegmentOfResult: Sequence
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + flatMap(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the concatenated results of mapping transform +over self.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func flatMap<SegmentOfResult>(_ transform: @escaping (Element) throws -> SegmentOfResult)
    +-> FlattenCursor<MapCursor<Self, SegmentOfResult>>
    +where SegmentOfResult: Cursor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + forEach(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Calls the given closure on each element in the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forEach(_ body: (Element) throws -> Void) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + map(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over the results of the transform function applied to +this cursor’s elements.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func map<T>(_ transform: @escaping (Element) throws -> T) -> MapCursor<Self, T>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + max(by:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the maximum element in the cursor, using the given predicate as +the comparison between elements.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func max(by areInIncreasingOrder: (Element, Element) throws -> Bool) throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s maximum element, according to +areInIncreasingOrder. If the cursor has no elements, returns nil.

    +
    + +
    +
    +
  • +
  • +
    + + + + min(by:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the minimum element in the cursor, using the given predicate as +the comparison between elements.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func min(by areInIncreasingOrder: (Element, Element) throws -> Bool) throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s minimum element, according to +areInIncreasingOrder. If the cursor has no elements, returns nil.

    +
    + +
    +
    +
  • +
  • +
    + + + + prefix(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor, up to the specified maximum length, containing the +initial elements of the cursor.

    + +

    If the maximum length exceeds the number of elements in the cursor, +the result contains all the elements in the cursor.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.prefix(2))
    +// Prints "[1, 2]"
    +try print(numbers.prefix(10))
    +// Prints "[1, 2, 3, 4, 5]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func prefix(_ maxLength: Int) -> PrefixCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + maxLength + + +
    +

    The maximum number of elements to return. The +value of maxLength must be greater than or equal to zero.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor starting at the beginning of this cursor +with at most maxLength elements.

    +
    + +
    +
    +
  • +
  • +
    + + + + prefix(while:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor of the initial consecutive elements that satisfy +predicate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func prefix(while predicate: @escaping (Element) throws -> Bool) -> PrefixWhileCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + predicate + + +
    +

    A closure that takes an element of the cursor as +its argument and returns true if the element should be included or +false otherwise. Once predicate returns false it will not be +called again.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + reduce(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the result of calling the given combining closure with each +element of this cursor and an accumulating value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reduce<Result>(
    +    _ initialResult: Result,
    +    _ nextPartialResult: (Result, Element) throws -> Result)
    +throws -> Result
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reduce(into:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the result of calling the given combining closure with each +element of this cursor and an accumulating value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reduce<Result>(
    +    into initialResult: Result,
    +    _ updateAccumulatingResult: (inout Result, Element) throws -> Void)
    +throws -> Result
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + suffix(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array, up to the given maximum length, containing the +final elements of the cursor.

    + +

    The cursor must be finite. If the maximum length exceeds the number of +elements in the cursor, the result contains all the elements in the +cursor.

    +
    let numbers = AnyCursor([1, 2, 3, 4, 5])
    +try print(numbers.suffix(2))
    +// Prints "[4, 5]"
    +try print(numbers.suffix(10))
    +// Prints "[1, 2, 3, 4, 5]"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func suffix(_ maxLength: Int) throws -> [Element]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + maxLength + + +
    +

    The maximum number of elements to return. The +value of maxLength must be greater than or equal to zero.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Equatable +

+
+
+
    +
  • +
    + + + + contains(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Boolean value indicating whether the cursor contains the +given element.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: Element) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Comparable +

+
+
+
    +
  • +
    + + + + max() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the maximum element in the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func max() throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s maximum element, according to +areInIncreasingOrder. If the cursor has no elements, returns +nil.

    +
    + +
    +
    +
  • +
  • +
    + + + + min() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the minimum element in the cursor.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func min() throws -> Element?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + areInIncreasingOrder + + +
    +

    A predicate that returns true +if its first argument should be ordered before its second +argument; otherwise, false.

    +
    +
    +
    +
    +

    Return Value

    +

    The cursor’s minimum element, according to +areInIncreasingOrder. If the cursor has no elements, returns +nil.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Cursor +

+
+
+
    +
  • +
    + + + + joined() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of this cursor of cursors, concatenated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined() -> FlattenCursor<Self>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: Sequence +

+
+
+
    +
  • +
    + + + + joined() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of this cursor of sequences, concatenated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined() -> FlattenCursor<MapCursor<Self, AnyCursor<Element.Element>>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Element: StringProtocol +

+
+
+
    +
  • +
    + + + + joined(separator:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the elements of this cursor of sequences, concatenated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joined(separator: String = "") throws -> String
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseAggregate.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseAggregate.html new file mode 100644 index 000000000..76b4152a6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseAggregate.html @@ -0,0 +1,1243 @@ + + + + DatabaseAggregate Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseAggregate

+
+
+ +
public protocol DatabaseAggregate
+ +
+
+

The protocol for custom SQLite aggregates.

+ +

For example:

+
struct MySum : DatabaseAggregate {
+    var sum: Int = 0
+
+    mutating func step(_ dbValues: [DatabaseValue]) {
+        if let int = Int.fromDatabaseValue(dbValues[0]) {
+            sum += int
+        }
+    }
+
+    func finalize() -> DatabaseValueConvertible? {
+        return sum
+    }
+}
+
+let dbQueue = DatabaseQueue()
+let fn = DatabaseFunction("mysum", argumentCount: 1, aggregate: MySum.self)
+try dbQueue.write { db in
+    db.add(function: fn)
+    try db.execute(sql: "CREATE TABLE test(i)")
+    try db.execute(sql: "INSERT INTO test(i) VALUES (1)")
+    try db.execute(sql: "INSERT INTO test(i) VALUES (2)")
+    try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an aggregate.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + step(_:) + +
    +
    +
    +
    +
    +
    +

    This method is called at each step of the aggregation.

    + +

    The dbValues argument contains as many values as given to the SQL +aggregate function.

    + +

    – One value + SELECT maxLength(name) FROM player

    + +

    – Two values + SELECT maxFullNameLength(firstName, lastName) FROM player

    + +

    This method is never called after the finalize() method has been called.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func step(_ dbValues: [DatabaseValue]) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + finalize() + +
    +
    +
    +
    +
    +
    +

    Returns the final result

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func finalize() throws -> DatabaseValueConvertible?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseCancellable.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseCancellable.html new file mode 100644 index 000000000..5f1751b05 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseCancellable.html @@ -0,0 +1,1146 @@ + + + + DatabaseCancellable Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseCancellable

+
+
+ +
public protocol DatabaseCancellable
+ +
+
+

A protocol indicating that an activity or action supports cancellation.

+ + +
+
+
+
    +
  • +
    + + + + cancel() + +
    +
    +
    +
    +
    +
    +

    Cancel the activity.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func cancel()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseReader.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseReader.html new file mode 100644 index 000000000..af307efd5 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseReader.html @@ -0,0 +1,1847 @@ + + + + DatabaseReader Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseReader

+
+
+ +
public protocol DatabaseReader : AnyObject
+ +
+
+

DatabaseReader is the protocol for all types that can fetch values from +an SQLite database.

+ +

It is adopted by DatabaseQueue, DatabasePool, and DatabaseSnapshot.

+ +

The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

+ +

Types that adopt the protocol can provide in practice stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

+ +

Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

+ + +
+
+
+
    +
  • +
    + + + + configuration + +
    +
    +
    +
    +
    +
    +

    The database configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var configuration: Configuration { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + close() + +
    +
    +
    +
    +
    +
    +

    Closes the database connection with the sqlite3_close() function.

    + +

    Note: You DO NOT HAVE to call this method, and you SHOULD NOT call +it unless the correct execution of your program depends on precise +database closing. Database connections are automatically closed when +they are deinitialized, and this is sufficient for most applications.

    + +

    If this method does not throw, then the database is properly closed, and +every future database access will throw a DatabaseError of +code SQLITE_MISUSE.

    + +

    Otherwise, there exists concurrent database accesses or living prepared +statements that prevent the database from closing, and this method +throws a DatabaseError of code SQLITE_BUSY. +See https://www.sqlite.org/c3ref/close.html for more information.

    + +

    After an error has been thrown, the database may still be opened, and +you can keep on accessing it. It may also remain in a “zombie” state, +in which case it will throw SQLITE_MISUSE for all future +database accesses.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func close() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Interrupting Database Operations +

+
+
+
    +
  • +
    + + + + interrupt() + +
    +
    +
    +
    +
    +
    +

    This method causes any pending database operation to abort and return at +its earliest opportunity.

    + +

    It can be called from any thread.

    + +

    A call to interrupt() that occurs when there are no running SQL +statements is a no-op and has no effect on SQL statements that are +started after interrupt() returns.

    + +

    A database operation that is interrupted will throw a DatabaseError with +code SQLITE_INTERRUPT. If the interrupted SQL operation is an INSERT, +UPDATE, or DELETE that is inside an explicit transaction, then the +entire transaction will be rolled back automatically. If the rolled back +transaction was started by a transaction-wrapping method such as +DatabaseWriter.write or Database.inTransaction, then all database +accesses will throw a DatabaseError with code SQLITE_ABORT until the +wrapping method returns.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // interrupted:
    +    try Player(...).insert(db)     // throws SQLITE_INTERRUPT
    +    // not executed:
    +    try Player(...).insert(db)
    +}                                  // throws SQLITE_INTERRUPT
    +
    +try dbQueue.write { db in
    +    do {
    +        // interrupted:
    +        try Player(...).insert(db) // throws SQLITE_INTERRUPT
    +    } catch { }
    +    try Player(...).insert(db)     // throws SQLITE_ABORT
    +}                                  // throws SQLITE_ABORT
    +
    +try dbQueue.write { db in
    +    do {
    +        // interrupted:
    +        try Player(...).insert(db) // throws SQLITE_INTERRUPT
    +    } catch { }
    +}                                  // throws SQLITE_ABORT
    +
    + +

    When an application creates transaction without a transaction-wrapping +method, no SQLITE_ABORT error warns of aborted transactions:

    +
    try dbQueue.inDatabase { db in // or dbPool.writeWithoutTransaction
    +    try db.beginTransaction()
    +    do {
    +        // interrupted:
    +        try Player(...).insert(db) // throws SQLITE_INTERRUPT
    +    } catch { }
    +    try Player(...).insert(db)     // success
    +    try db.commit()                // throws SQLITE_ERROR "cannot commit - no transaction is active"
    +}
    +
    + +

    Both SQLITE_ABORT and SQLITE_INTERRUPT errors can be checked with the +DatabaseError.isInterruptionError property.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func interrupt()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Read From Database +

+
+
+
    +
  • +
    + + + + read(_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes a read-only function that accepts a database +connection, and returns its result.

    + +

    For example:

    +
    let count = try reader.read { db in
    +    try Player.fetchCount(db)
    +}
    +
    + +

    The value function runs in an isolated fashion: eventual concurrent +database updates are not visible from the function:

    +
    try reader.read { db in
    +    // Those two values are guaranteed to be equal, even if the
    +    // `player` table is modified, between the two requests, by
    +    // some other database connection or some other thread.
    +    let count1 = try Player.fetchCount(db)
    +    let count2 = try Player.fetchCount(db)
    +}
    +
    +try reader.read { db in
    +    // Now this value may be different:
    +    let count = try Player.fetchCount(db)
    +}
    +
    + +

    Attempts to write in the database throw a DatabaseError with +resultCode SQLITE_READONLY.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try reader.read { db in
    +    // Raises a fatal error
    +    try reader.read { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by value, or any DatabaseError that would +happen while establishing the read access to the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func read<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + asyncRead(_:) + +
    +
    +
    +
    +
    +
    +

    Asynchronously executes a read-only function that accepts a +database connection.

    + +

    The value function runs in an isolated fashion: eventual concurrent +database updates are not visible from the function:

    +
    reader.asyncRead { dbResult in
    +    do {
    +        let db = try dbResult.get()
    +        // Those two values are guaranteed to be equal, even if the
    +        // `player` table is modified, between the two requests, by
    +        // some other database connection or some other thread.
    +        let count1 = try Player.fetchCount(db)
    +        let count2 = try Player.fetchCount(db)
    +    } catch {
    +        // handle error
    +    }
    +}
    +
    + +

    Attempts to write in the database throw a DatabaseError with +resultCode SQLITE_READONLY.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncRead(_ value: @escaping (Result<Database, Error>) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database. Its argument +is a Result that provides the database connection, or the failure +that would prevent establishing the read access to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + unsafeRead(_:) + +
    +
    +
    +
    +
    +
    +

    Synchronously executes a function that accepts a database +connection, and returns its result.

    + +

    For example:

    +
    let count = try reader.unsafeRead { db in
    +    try Player.fetchCount(db)
    +}
    +
    + +

    The guarantees of the read method are lifted:

    + +

    the value function is not isolated: eventual concurrent database +updates are visible from the function:

    +
    try reader.unsafeRead { db in
    +    // Those two values can be different, because some other
    +    // database connection or some other thread may modify the
    +    // database between the two requests.
    +    let count1 = try Player.fetchCount(db)
    +    let count2 = try Player.fetchCount(db)
    +}
    +
    + +

    The value function is not prevented from writing (DatabaseQueue, in +particular, will accept database modifications in unsafeRead).

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try reader.read { db in
    +    // Raises a fatal error
    +    try reader.unsafeRead { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by value, or any DatabaseError that would +happen while establishing the read access to the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes a function that accepts a database +connection, and returns its result.

    + +

    The guarantees of the safe read method are lifted:

    + +

    the value function is not isolated: eventual concurrent database +updates are visible from the function:

    +
    try reader.unsafeReentrantRead { db in
    +    // Those two values can be different, because some other
    +    // database connection or some other thread may modify the
    +    // database between the two requests.
    +    let count1 = try Player.fetchCount(db)
    +    let count2 = try Player.fetchCount(db)
    +}
    +
    + +

    The value function is not prevented from writing (DatabaseQueue, in +particular, will accept database modifications in unsafeRead).

    + +

    This method is reentrant. It should be avoided because it fosters +dangerous concurrency practices.

    +
    +

    Throws

    + The error thrown by value, or any DatabaseError that would +happen while establishing the read access to the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unsafeReentrantRead<T>(_ value: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A function that accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Backup +

+
+
+
    +
  • +
    + + + + backup(to:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Copies the database contents into another database.

    + +

    The backup method blocks the current thread until the destination +database contains the same contents as the source database.

    + +

    When the source is a DatabasePool, concurrent writes can happen during +the backup. Those writes may, or may not, be reflected in the backup, +but they won’t trigger any error.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func backup(to writer: DatabaseWriter) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Database Values +

+
+
+
    +
  • +
    + + + + readPublisher(value:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously completes with a fetched value.

    +
    // DatabasePublishers.Read<[Player]>
    +let players = dbQueue.readPublisher { db in
    +    try Player.fetchAll(db)
    +}
    +
    + +

    Its value and completion are emitted on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func readPublisher<Output>(
    +    value: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Read<Output>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + value + + +
    +

    A closure which accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + readPublisher(receiveOn:value:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously completes with a fetched value.

    +
    // DatabasePublishers.Read<[Player]>
    +let players = dbQueue.readPublisher(
    +    receiveOn: DispatchQueue.global(),
    +    value: { db in try Player.fetchAll(db) })
    +
    + +

    Its value and completion are emitted on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func readPublisher<S, Output>(
    +    receiveOn scheduler: S,
    +    value: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Read<Output>
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    + + value + + +
    +

    A closure which accesses the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseRegionConvertible.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseRegionConvertible.html new file mode 100644 index 000000000..4c3061dcf --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseRegionConvertible.html @@ -0,0 +1,1215 @@ + + + + DatabaseRegionConvertible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegionConvertible

+
+
+ +
public protocol DatabaseRegionConvertible
+ +
+
+

DatabaseRegionConvertible is the protocol for values that can be turned +into a DatabaseRegion.

+ +

Such values specify the region obserbed by DatabaseRegionObservation.

+ + +
+
+
+
    +
  • +
    + + + + databaseRegion(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a database region.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseRegion(_ db: Database) throws -> DatabaseRegion
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self == DatabaseRegion +

+
+
+
    +
  • +
    + + + + fullDatabase + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The region that covers the full database: all columns and all rows +from all tables.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var fullDatabase: Self { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseValueConvertible.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseValueConvertible.html new file mode 100644 index 000000000..468dbb6fb --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseValueConvertible.html @@ -0,0 +1,3706 @@ + + + + DatabaseValueConvertible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseValueConvertible

+
+
+ +
public protocol DatabaseValueConvertible : SQLExpressible, StatementBinding
+ +
+
+

Types that adopt DatabaseValueConvertible can be initialized from +database values.

+ +

The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single values:

+
try String.fetchCursor(db, sql: "SELECT name FROM ...", arguments:...) // Cursor of String
+try String.fetchAll(db, sql: "SELECT name FROM ...", arguments:...)    // [String]
+try String.fetchOne(db, sql: "SELECT name FROM ...", arguments:...)    // String?
+
+let statement = try db.makeStatement(sql: "SELECT name FROM ...")
+try String.fetchCursor(statement, arguments:...) // Cursor of String
+try String.fetchAll(statement, arguments:...)    // [String]
+try String.fetchOne(statement, arguments:...)    // String?
+
+ +

DatabaseValueConvertible is adopted by Bool, Int, String, etc.

+ + +
+
+
+ +
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • +
    + + + + fetchCursor(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchCursor(statement) // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> DatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchAll(statement)  // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a prepared statement.

    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let name = try String.fetchOne(statement)   // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • +
    + + + + fetchCursor(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from an SQL query.

    +
    let names = try String.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String
    +while let name = try name.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> DatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from an SQL query.

    +
    let names = try String.fetchAll(db, sql: "SELECT name FROM ...") // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from an SQL query.

    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    let name = try String.fetchOne(db, sql: "SELECT name FROM ...") // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchCursor(db, request) // Cursor of String
    +while let name = try name.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R>(_ db: Database, _ request: R) throws -> DatabaseValueCursor<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchAll(db, request) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Self] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a fetch request.

    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    let request = Player.filter(key: 1).select(Column("name"))
    +let name = try String.fetchOne(db, request) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Self? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchSet(statement)  // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from an SQL query.

    +
    let names = try String.fetchSet(db, sql: "SELECT name FROM ...") // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchSet(db, request) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • +
    + + + + fetchCursor(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchCursor(statement) // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> FastDatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchAll(statement)  // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let name = try String.fetchOne(statement)   // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT name FROM ...")
    +let names = try String.fetchSet(statement)  // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • +
    + + + + fetchCursor(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from an SQL query.

    +
    let names = try String.fetchCursor(db, sql: "SELECT name FROM ...") // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> FastDatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from an SQL query.

    +
    let names = try String.fetchAll(db, sql: "SELECT name FROM ...") // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from an SQL query.

    +
    let name = try String.fetchOne(db, sql: "SELECT name FROM ...") // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from an SQL query.

    +
    let names = try String.fetchSet(db, sql: "SELECT name FROM ...") // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchCursor(db, request) // Cursor of String
    +while let name = try names.next() { // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R: FetchRequest>(_ db: Database, _ request: R)
    +throws -> FastDatabaseValueCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchAll(db, request) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Self] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single value fetched from a fetch request.

    +
    let request = Player.filter(key: 1).select(Column("name"))
    +let name = try String.fetchOne(db, request) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Self? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of values fetched from a fetch request.

    +
    let request = Player.select(Column("name"))
    +let names = try String.fetchSet(db, request) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + request + + +
    +

    A FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: ReferenceConvertible, Self.ReferenceType: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + databaseValue + + + Default implementation + +
    +
    +
    +
    +
    +
    + +
    +

    Default Implementation

    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    + +
    +

    Default Implementation

    +
    +

    Returns a value initialized from dbValue, if possible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseWriter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseWriter.html new file mode 100644 index 000000000..cfaa6db8a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DatabaseWriter.html @@ -0,0 +1,2286 @@ + + + + DatabaseWriter Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseWriter

+
+
+ +
public protocol DatabaseWriter : DatabaseReader
+ +
+
+

DatabaseWriter is the protocol for all types that can write into an +SQLite database.

+ +

It is adopted by DatabaseQueue and DatabasePool.

+ +

The protocol comes with isolation guarantees that describe the behavior of +adopting types in a multithreaded application.

+ +

Types that adopt the protocol can in practice provide stronger guarantees. +For example, DatabaseQueue provides a stronger isolation level +than DatabasePool.

+ +

Warning: Isolation guarantees stand as long as there is no external +connection to the database. Should you have to cope with external +connections, protect yourself with transactions, and be ready to setup a +busy handler.

+ + +
+
+
+
+ + +
+ +

Writing in Database +

+
+
+
    +
  • +
    + + + + write(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction, and returns the result.

    + +

    If the updates throw an error, the transaction is rollbacked and the +error is rethrown.

    + +

    Eventual concurrent database updates are postponed until the transaction +has completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try writer.write { db in
    +    // Raises a fatal error
    +    try writer.write { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates, or by the +wrapping transaction. + +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func write<T>(_ updates: (Database) throws -> T) throws -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Eventual concurrent database updates are postponed until the updates +are completed.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try writer.write { db in
    +    // Raises a fatal error
    +    try writer.writeWithoutTransaction { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Updates are guaranteed an exclusive access to the database. They wait +until all pending writes and reads are completed. They postpone all +other writes and reads until they are completed.

    + +

    It is a programmer error to call this method from another database +access method:

    +
    try writer.write { db in
    +    // Raises a fatal error
    +    try writer.barrierWriteWithoutTransaction { ... )
    +}
    +
    +
    +

    Throws

    + The error thrown by the updates. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Updates are guaranteed an exclusive access to the database. They wait +until all pending writes and reads are completed. They postpone all +other writes and reads until they are completed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncBarrierWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + asyncWrite(_:completion:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction.

    + +

    If the updates throw an error, the transaction is rollbacked.

    + +

    The completion closure is always called with the result of the +database updates. Its arguments are a database connection and the +result of the transaction. This result is a failure if the transaction +could not be committed.

    + +

    Eventual concurrent database updates are postponed until the transaction +and the completion closure have completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    This method is not reentrant.

    +
    +

    Throws

    + The error thrown by the updates, or by the wrapping transaction. + +
    + +
    +

    Default Implementation

    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +wrapped inside a transaction.

    + +

    If the updates throw an error, the transaction is rollbacked.

    + +

    The completion closure is always called with the result of the +database updates. Its arguments are a database connection and the +result of the transaction. This result is a failure if the transaction +could not be committed. The completion closure is executed in a +protected dispatch queue, outside of any transaction.

    + +

    Eventual concurrent database updates are postponed until the transaction +and the completion closure have completed.

    + +

    Eventual concurrent reads are guaranteed to not see any partial updates +of the database until the transaction has completed.

    + +

    This method is not reentrant.

    +
    +

    Throws

    + The error thrown by the updates, or by the wrapping transaction. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncWrite<T>(
    +    _ updates: @escaping (Database) throws -> T,
    +    completion: @escaping (Database, Result<T, Error>) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + updates + + +
    +

    The updates to the database.

    +
    +
    + + completion + + +
    +

    A closure that is called with the eventual +transaction error.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Asynchronously executes database updates in a protected dispatch queue, +outside of any transaction.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func asyncWriteWithoutTransaction(_ updates: @escaping (Database) -> Void)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Synchronously executes database updates in a protected dispatch queue, +outside of any transaction, and returns the result.

    + +

    Eventual concurrent database updates are postponed until the updates +are completed.

    + +

    Eventual concurrent reads may see partial updates unless you wrap them +in a transaction.

    + +

    This method is reentrant. It should be avoided because it fosters +dangerous concurrency practices.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unsafeReentrantWrite<T>(_ updates: (Database) throws -> T) rethrows -> T
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Reading from Database +

+
+
+
    +
  • +
    + + + + concurrentRead(_:) + +
    +
    +
    +
    +
    +
    +

    Concurrently executes a read-only block in a protected dispatch queue.

    + +

    This method must be called from a writing dispatch queue, outside of any +transaction. You’ll get a fatal error otherwise.

    + +

    The block argument is guaranteed to see the database in the last +committed state at the moment this method is called. Eventual concurrent +database updates are not visible inside the block.

    + +

    To access the fetched results, you call the wait() method of the +returned future, on any dispatch queue.

    + +

    In the example below, the number of players is fetched concurrently with +the player insertion. Yet the future is guaranteed to return zero:

    +
    try writer.writeWithoutTransaction { db in
    +    // Delete all players
    +    try Player.deleteAll()
    +
    +    // Count players concurrently
    +    let future = writer.concurrentRead { db in
    +        return try Player.fetchCount()
    +    }
    +
    +    // Insert a player
    +    try Player(...).insert(db)
    +
    +    // Guaranteed to be zero
    +    let count = try future.wait()
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Transaction Observers +

+
+
+
    +
  • +
    + + + + add(transactionObserver:extent:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Add a transaction observer, so that it gets notified of +database changes.

    + +

    To remove the observer, use DatabaseReader.remove(transactionObserver:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func add(
    +    transactionObserver: TransactionObserver,
    +    extent: Database.TransactionObservationExtent = .observerLifetime)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + transactionObserver + + +
    +

    A transaction observer.

    +
    +
    + + extent + + +
    +

    The duration of the observation. The default is +the observer lifetime (observation lasts until observer +is deallocated).

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove(transactionObserver:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func remove(transactionObserver: TransactionObserver)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Erasing the content of the database +

+
+
+
    +
  • +
    + + + + erase() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Erases the content of the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func erase() throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Claiming Disk Space +

+
+
+
    +
  • +
    + + + + vacuum() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Rebuilds the database file, repacking it into a minimal amount of +disk space.

    + +

    See https://www.sqlite.org/lang_vacuum.html for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func vacuum() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + vacuum(into:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a new database file at the specified path with a minimum +amount of disk space.

    + +

    Databases encrypted with SQLCipher are copied with the same password +and configuration as the original database.

    + +

    See https://www.sqlite.org/lang_vacuum.html#vacuuminto for more information.

    + +
    +
    +
    +
  • +
  • +
    + + + + vacuum(into:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a new database file at the specified path with a minimum +amount of disk space. +See https://www.sqlite.org/lang_vacuum.html#vacuuminto for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 11.0, iOS 14, tvOS 14, watchOS 7, *)
    +public func vacuum(into filePath: String) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + filePath + + +
    +

    file path for new database

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Database Updates +

+
+
+
    +
  • +
    + + + + writePublisher(updates:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher { db -> Int in
    +    try Player(...).insert(db)
    +    return try Player.fetchCount(db)
    +}
    +
    + +

    Its value and completion are emitted on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<Output>(
    +    updates: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + writePublisher(receiveOn:updates:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher(
    +    receiveOn: DispatchQueue.global(),
    +    updates: { db -> Int in
    +        try Player(...).insert(db)
    +        return try Player.fetchCount(db)
    +    })
    +
    + +

    Its value and completion are emitted on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<S, Output>(
    +    receiveOn scheduler: S,
    +    updates: @escaping (Database) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + writePublisher(updates:thenRead:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher(
    +    updates: { db in try Player(...).insert(db) }
    +    thenRead: { db, _ in try Player.fetchCount(db) })
    +
    + +

    Its value and completion are emitted on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<T, Output>(
    +    updates: @escaping (Database) throws -> T,
    +    thenRead value: @escaping (Database, T) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    + + value + + +
    +

    A closure which reads from the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + writePublisher(receiveOn:updates:thenRead:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously writes into the database.

    +
    // DatabasePublishers.Write<Int>
    +let newPlayerCount = dbQueue.writePublisher(
    +    receiveOn: DispatchQueue.global(),
    +    updates: { db in try Player(...).insert(db) }
    +    thenRead: { db, _ in try Player.fetchCount(db) })
    +
    + +

    Its value and completion are emitted on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func writePublisher<S, T, Output>(
    +    receiveOn scheduler: S,
    +    updates: @escaping (Database) throws -> T,
    +    thenRead value: @escaping (Database, T) throws -> Output)
    +-> DatabasePublishers.Write<Output>
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    + + updates + + +
    +

    A closure which writes in the database.

    +
    +
    + + value + + +
    +

    A closure which reads from the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DerivableRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DerivableRequest.html new file mode 100644 index 000000000..2d9eb3f7e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/DerivableRequest.html @@ -0,0 +1,1344 @@ + + + + DerivableRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DerivableRequest

+
+ +
+

The base protocol for all requests that can be refined.

+ + +
+
+
+
    +
  • +
    + + + + distinct() + +
    +
    +
    +
    +
    +
    +

    Creates a request which returns distinct rows.

    +
    // SELECT DISTINCT * FROM player
    +var request = Player.all()
    +request = request.distinct()
    +
    +// SELECT DISTINCT name FROM player
    +var request = Player.select(Column("name"))
    +request = request.distinct()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func distinct() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a request which embeds the common table expression.

    + +

    If a common table expression with the same table name had already been +embedded, it is replaced by the new one.

    + +

    For example, you can build a request that fetches all chats with their +latest message:

    +
    let latestMessageRequest = Message
    +    .annotated(with: max(Column("date")))
    +    .group(Column("chatID"))
    +
    +let latestMessageCTE = CommonTableExpression(
    +    named: "latestMessage",
    +    request: latestMessageRequest)
    +
    +let latestMessage = Chat.association(
    +    to: latestMessageCTE,
    +    on: { chat, latestMessage in
    +        chat[Column("id")] == latestMessage[Column("chatID")]
    +    })
    +
    +// WITH latestMessage AS
    +//   (SELECT *, MAX(date) FROM message GROUP BY chatID)
    +// SELECT chat.*, latestMessage.*
    +// FROM chat
    +// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
    +let request = Chat.all()
    +    .with(latestMessageCTE)
    +    .including(optional: latestMessage)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DerivableRequest +

+
+
+
    +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends aggregates to the current selection.

    +
    // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount
    +// FROM team LEFT JOIN player ...
    +var request = Team.all()
    +request = request.annotated(with: Team.players.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: AssociationAggregate<RowDecoder>...) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends aggregates to the current selection.

    +
    // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount
    +// FROM team LEFT JOIN player ...
    +var request = team.all()
    +request = request.annotated(with: [Team.players.count])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends the provided aggregate predicate to +the eventual set of already applied predicates.

    +
    // SELECT team.*
    +// FROM team LEFT JOIN player ...
    +// HAVING COUNT(DISTINCT player.id) = 0
    +var request = Team.all()
    +request = request.having(Team.players.isEmpty)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: AssociationAggregate<RowDecoder>) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/EncodableRecord.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/EncodableRecord.html new file mode 100644 index 000000000..60e0f3d24 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/EncodableRecord.html @@ -0,0 +1,1577 @@ + + + + EncodableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

EncodableRecord

+
+
+ +
public protocol EncodableRecord
+ +
+
+

Types that adopt EncodableRecord can be encoded into the database.

+ + +
+
+
+
    +
  • +
    + + + + encode(to:) + +
    +
    +
    +
    +
    +
    +

    Encodes the record into database values.

    + +

    Store in the container argument all values that should be stored in +the columns of the database table (see databaseTableName()).

    + +

    Primary key columns, if any, must be included.

    +
    struct Player: EncodableRecord {
    +    var id: Int64?
    +    var name: String?
    +
    +    func encode(to container: inout PersistenceContainer) {
    +        container["id"] = id
    +        container["name"] = name
    +    }
    +}
    +
    + +

    It is undefined behavior to set different values for the same column. +Column names are case insensitive, so defining both “name” and “NAME” +is considered undefined behavior.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func encode(to container: inout PersistenceContainer)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Customizing the Format of Database Columns +

+
+
+
    +
  • +
    + + + + databaseEncodingUserInfo + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, you can use this dictionary to customize the encoding process +into database rows.

    + +

    For example:

    +
    // A key that holds a encoder's name
    +let encoderName = CodingUserInfoKey(rawValue: "encoderName")!
    +
    +struct Player: PersistableRecord, Encodable {
    +    // Customize the encoder name when encoding a database row
    +    static let databaseEncodingUserInfo: [CodingUserInfoKey: Any] = [encoderName: "Database"]
    +
    +    func encode(to encoder: Encoder) throws {
    +        // Print the encoder name
    +        print(encoder.userInfo[encoderName])
    +        ...
    +    }
    +}
    +
    +let player = Player(...)
    +
    +// prints "Database"
    +try player.insert(db)
    +
    +// prints "JSON"
    +let encoder = JSONEncoder()
    +encoder.userInfo = [encoderName: "JSON"]
    +let data = try encoder.encode(player)
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseEncodingUserInfo: [CodingUserInfoKey : Any] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseJSONEncoder(for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this method controls the encoding process of nested properties +into JSON database columns.

    + +

    The default implementation returns a JSONEncoder with the +following properties:

    + +
      +
    • dataEncodingStrategy: .base64
    • +
    • dateEncodingStrategy: .millisecondsSince1970
    • +
    • nonConformingFloatEncodingStrategy: .throw
    • +
    • outputFormatting: .sortedKeys (iOS 11.0+, macOS 10.13+, tvOS 11.0+, watchOS 4.0+)
    • +
    + +

    You can override those defaults:

    +
    struct Achievement: Encodable {
    +    var name: String
    +    var date: Date
    +}
    +
    +struct Player: Encodable, PersistableRecord {
    +    // stored in a JSON column
    +    var achievements: [Achievement]
    +
    +    static func databaseJSONEncoder(for column: String) -> JSONEncoder {
    +        let encoder = JSONEncoder()
    +        encoder.dateEncodingStrategy = .iso8601
    +        return encoder
    +    }
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static func databaseJSONEncoder(for column: String) -> JSONEncoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDateEncodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this property controls the encoding of date properties.

    + +

    Default value is .deferredToDate

    + +

    For example:

    +
    struct Player: PersistableRecord, Encodable {
    +    static let databaseDateEncodingStrategy: DatabaseDateEncodingStrategy = .timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // encoded as an epoch timestamp
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseDateEncodingStrategy: DatabaseDateEncodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseUUIDEncodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this property controls the encoding of UUID properties.

    + +

    Default value is .deferredToUUID

    + +

    For example:

    +
    struct Player: PersistableProtocol, Encodable {
    +    static let databaseUUIDEncodingStrategy: DatabaseUUIDEncodingStrategy = .uppercaseString
    +
    +    // encoded in a string like "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
    +    var uuid: UUID
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseUUIDEncodingStrategy: DatabaseUUIDEncodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseColumnEncodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the EncodableRecord type also adopts the standard Encodable +protocol, this property controls the key encoding strategy.

    + +

    Default value is .useDefaultKeys

    + +

    For example:

    +
    struct Player: PersistableProtocol, Encodable {
    +    static let databaseColumnEncodingStrategy: DatabaseColumnEncodingStrategy = .convertToSnakeCase
    +
    +    // encoded as player_id
    +    var playerID: String
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseColumnEncodingStrategy: DatabaseColumnEncodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDictionary + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A dictionary whose keys are the columns encoded in the encode(to:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseDictionary: [String : DatabaseValue] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Record Comparison +

+
+
+
    +
  • +
    + + + + databaseEquals(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a boolean indicating whether this record and the other record +have the same database representation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseEquals(_ record: Self) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseChanges(from:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A dictionary of values changed from the other record.

    + +

    Its keys are column names. Its values come from the other record.

    + +

    Note that this method is not symmetrical, not only in terms of values, +but also in terms of columns. When the two records don’t define the +same set of columns in their encode(to:) method, only the columns +defined by the receiver record are considered.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseChanges<Record>(from record: Record) -> [String : DatabaseValue] where Record : EncodableRecord
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5CustomTokenizer.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5CustomTokenizer.html new file mode 100644 index 000000000..1c2bf8fc7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5CustomTokenizer.html @@ -0,0 +1,1182 @@ + + + + FTS5CustomTokenizer Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5CustomTokenizer

+

The protocol for custom FTS5 tokenizers.

+ +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the tokenizer; should uniquely identify your custom +tokenizer.

    + +
    +
    +
    +
  • +
  • +
    + + + + init(db:arguments:) + +
    +
    +
    +
    +
    +
    +

    Creates a custom tokenizer.

    + +

    The arguments parameter is an array of String built from the CREATE +VIRTUAL TABLE statement. In the example below, the arguments will +be ["arg1", "arg2"].

    +
    CREATE VIRTUAL TABLE document USING fts5(
    +    tokenize='custom arg1 arg2'
    +)
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + tokenizerDescriptor(arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an FTS5 tokenizer descriptor.

    +
    class MyTokenizer : FTS5CustomTokenizer { ... }
    +
    +db.create(virtualTable: "book", using: FTS5()) { t in
    +    let tokenizer = MyTokenizer.tokenizerDescriptor(arguments: ["unicode61", "remove_diacritics", "0"])
    +    t.tokenizer = tokenizer
    +}
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5Tokenizer.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5Tokenizer.html new file mode 100644 index 000000000..914a05edb --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5Tokenizer.html @@ -0,0 +1,1197 @@ + + + + FTS5Tokenizer Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5Tokenizer

+

The protocol for FTS5 tokenizers

+ +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Tokenizes the text described by pText and nText, and +notifies found tokens to the tokenCallback function.

    + +

    It matches the xTokenize function documented at https://www.sqlite.org/fts5.html#custom_tokenizers

    + +
    +
    +
    +
  • +
  • +
    + + + + tokenize(document:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Tokenizes the string argument as a document that would be inserted into +an FTS5 table.

    + +

    For example:

    +
    let tokenizer = try db.makeTokenizer(.ascii())
    +try tokenizer.tokenize(document: "foo bar") // [("foo", flags), ("bar", flags)]
    +
    + +

    See also tokenize(query:).

    +
    +

    Throws

    + An error if tokenization fails. + +
    + +
    +
    +
    +
  • +
  • +
    + + + + tokenize(query:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Tokenizes the string argument as an FTS5 query.

    + +

    For example:

    +
    let tokenizer = try db.makeTokenizer(.ascii())
    +try tokenizer.tokenize(query: "foo bar") // [("foo", flags), ("bar", flags)]
    +
    + +

    See also tokenize(document:).

    +
    +

    Throws

    + An error if tokenization fails. + +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5WrapperTokenizer.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5WrapperTokenizer.html new file mode 100644 index 000000000..06f5335b4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FTS5WrapperTokenizer.html @@ -0,0 +1,1218 @@ + + + + FTS5WrapperTokenizer Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5WrapperTokenizer

+

The protocol for custom FTS5 tokenizers that wrap another tokenizer.

+ +

Types that adopt FTS5WrapperTokenizer don’t have to implement the +low-level FTS5Tokenizer.tokenize(context:flags:pText:nText:tokenCallback:).

+ +

Instead, they process regular Swift strings.

+ +

Here is the implementation for a trivial tokenizer that wraps the +built-in ascii tokenizer without any custom processing:

+
class TrivialAsciiTokenizer : FTS5WrapperTokenizer {
+    static let name = "trivial"
+    let wrappedTokenizer: FTS5Tokenizer
+
+    init(db: Database, arguments: [String]) throws {
+        wrappedTokenizer = try db.makeTokenizer(.ascii())
+    }
+
+    func accept(
+        token: String,
+        flags: FTS5TokenFlags,
+        for tokenization: FTS5Tokenization,
+        tokenCallback: FTS5WrapperTokenCallback)
+        throws
+    {
+        try tokenCallback(token, flags)
+    }
+}
+
+ +
+
+
+
    +
  • +
    + + + + wrappedTokenizer + +
    +
    +
    +
    +
    +
    +

    The wrapped tokenizer

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Given a token produced by the wrapped tokenizer, notifies customized +tokens to the tokenCallback function.

    + +

    For example:

    +
    func accept(
    +    token: String,
    +    flags: FTS5TokenFlags,
    +    for tokenization: FTS5Tokenization,
    +    tokenCallback: FTS5WrapperTokenCallback)
    +    throws
    +{
    +    // pass through:
    +    try tokenCallback(token, flags)
    +}
    +
    + +

    When implementing the accept method, there are a two rules +to observe:

    + +
      +
    1. Errors thrown by the tokenCallback function must not be caught.

    2. +
    3. The input flags should be given unmodified to the tokenCallback +function, unless you union it with the .colocated flag when the +tokenizer produces synonyms (see +https://www.sqlite.org/fts5.html#synonym_support).

    4. +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Default implementation

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FetchRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FetchRequest.html new file mode 100644 index 000000000..c52d05128 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FetchRequest.html @@ -0,0 +1,3136 @@ + + + + FetchRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FetchRequest

+
+
+ +
public protocol FetchRequest : DatabaseRegionConvertible, SQLSubqueryable
+ +
+
+

The protocol for all requests that fetch database rows, and tell how those +rows should be interpreted.

+
struct Player: FetchableRecord { ... }
+let request: ... // Some FetchRequest that fetches Player
+try request.fetchCursor(db) // Cursor of Player
+try request.fetchAll(db)    // [Player]
+try request.fetchSet(db)    // Set<Player>
+try request.fetchOne(db)    // Player?
+try request.fetchCount(db)  // Int
+
+ + +
+
+
+
    +
  • +
    + + + + RowDecoder + +
    +
    +
    +
    +
    +
    +

    The type that tells how fetched database rows should be interpreted.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a PreparedRequest that is ready to be executed.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func makePreparedRequest(_ db: Database, forSingleResult singleResult: Bool) throws -> PreparedRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + singleResult + + +
    +

    A hint that a single result row will be +consumed. Implementations can optionally use it to optimize the +prepared statement, for example by adding a LIMIT 1 SQL clause.

    + +

    // Calls makePreparedRequest(db, forSingleResult: true) + try request.fetchOne(db)

    + +

    // Calls makePreparedRequest(db, forSingleResult: false) + try request.fetchAll(db)

    +
    +
    +
    +
    +

    Return Value

    +

    A prepared request.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the number of rows fetched by the request.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func fetchCount(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FetchRequest +

+
+
+
    +
  • +
    + + + + databaseRegion(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the database region that the request feeds from.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseRegion(_ db: Database) throws -> DatabaseRegion
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AdaptedFetchRequest +

+
+
+ +
+
+
+ + +
+ +

Fetching Values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchCursor(db) // Cursor of String
    +while let string = try strings.next() {   // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> DatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Optional values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchCursor(db) // Cursor of String?
    +while let string = try strings.next() {   // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> NullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String?
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Rows +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched rows.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let rows = try request.fetchCursor(db) // RowCursor
    +while let row = try rows.next() {  // Row
    +    let id: Int64 = row[0]
    +    let name: String = row[1]
    +}
    +
    + +

    Fetched rows are reused during the cursor iteration: don’t turn a row +cursor into an array with Array(rows) or rows.filter { ... } since +you would not get the distinct rows you expect. Use Row.fetchAll(...) +instead.

    + +

    For the same reason, make sure you make a copy whenever you extract a +row for later use: row.copy().

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched rows.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let rows = try request.fetchAll(db)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched rows.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let rows = try request.fetchSet(db)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of fetched rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched row.

    +
    let request: ... // Some FetchRequest that fetches Row
    +let row = try request.fetchOne(db)
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional row.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchCursor(db) // Cursor of String
    +while let string = try strings.next() {   // String
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastDatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched values.

    +
    let request: ... // Some FetchRequest that fetches String
    +let strings = try request.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Optional values +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchCursor(db) // Cursor of String?
    +while let string = try strings.next() {   // String?
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastNullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of values.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched value.

    + +

    The result is nil if the request returns no row, or if no value can be +extracted from the first row.

    +
    let request: ... // Some FetchRequest that fetches String?
    +let string = try request.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional value.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched optional values.

    +
    let request: ... // Some FetchRequest that fetches Optional<String>
    +let strings = try request.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of values.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching Records +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over fetched records.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let players = try request.fetchCursor(db) // Cursor of Player
    +while let player = try players.next() {   // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RecordCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of fetched records.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let players = try request.fetchAll(db) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first fetched record.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let player = try request.fetchOne(db) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: FetchableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of fetched records.

    +
    let request: ... // Some FetchRequest that fetches Player
    +let players = try request.fetchSet(db) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FetchableRecord.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FetchableRecord.html new file mode 100644 index 000000000..a472078df --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FetchableRecord.html @@ -0,0 +1,4221 @@ + + + + FetchableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FetchableRecord

+
+
+ +
public protocol FetchableRecord
+ +
+
+

Types that adopt FetchableRecord can be initialized from a database Row.

+
let row = try Row.fetchOne(db, sql: "SELECT ...")!
+let player = Player(row)
+
+ +

The protocol comes with built-in methods that allow to fetch cursors, +arrays, or single records:

+
try Player.fetchCursor(db, sql: "SELECT ...", arguments:...) // Cursor of Player
+try Player.fetchAll(db, sql: "SELECT ...", arguments:...)    // [Player]
+try Player.fetchOne(db, sql: "SELECT ...", arguments:...)    // Player?
+
+let statement = try db.makeStatement(sql: "SELECT ...")
+try Player.fetchCursor(statement, arguments:...) // Cursor of Player
+try Player.fetchAll(statement, arguments:...)    // [Player]
+try Player.fetchOne(statement, arguments:...)    // Player?
+
+ + +
+
+
+
+ + +
+ +

Row Decoding +

+
+
+
    +
  • +
    + + + + init(row:) + +
    +
    +
    +
    +
    +
    +

    Creates a record from row.

    + +

    For performance reasons, the row argument may be reused during the +iteration of a fetch query. If you want to keep the row for later use, +make sure to store a copy: self.row = row.copy().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    init(row: Row)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Customizing the Format of Database Columns +

+
+
+
    +
  • +
    + + + + databaseDecodingUserInfo + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, you can use this dictionary to customize the decoding process +from database rows.

    + +

    For example:

    +
    // A key that holds a decoder's name
    +let decoderName = CodingUserInfoKey(rawValue: "decoderName")!
    +
    +// A FetchableRecord + Decodable record
    +struct Player: FetchableRecord, Decodable {
    +    // Customize the decoder name when decoding a database row
    +    static let databaseDecodingUserInfo: [CodingUserInfoKey: Any] = [decoderName: "Database"]
    +
    +    init(from decoder: Decoder) throws {
    +        // Print the decoder name
    +        print(decoder.userInfo[decoderName])
    +        ...
    +    }
    +}
    +
    +// prints "Database"
    +let player = try Player.fetchOne(db, ...)
    +
    +// prints "JSON"
    +let decoder = JSONDecoder()
    +decoder.userInfo = [decoderName: "JSON"]
    +let player = try decoder.decode(Player.self, from: ...)
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseDecodingUserInfo: [CodingUserInfoKey : Any] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseJSONDecoder(for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, this method controls the decoding process of nested properties +from JSON database columns.

    + +

    The default implementation returns a JSONDecoder with the +following properties:

    + +
      +
    • dataDecodingStrategy: .base64
    • +
    • dateDecodingStrategy: .millisecondsSince1970
    • +
    • nonConformingFloatDecodingStrategy: .throw
    • +
    + +

    You can override those defaults:

    +
    struct Achievement: Decodable {
    +    var name: String
    +    var date: Date
    +}
    +
    +struct Player: Decodable, FetchableRecord {
    +    // stored in a JSON column
    +    var achievements: [Achievement]
    +
    +    static func databaseJSONDecoder(for column: String) -> JSONDecoder {
    +        let decoder = JSONDecoder()
    +        decoder.dateDecodingStrategy = .iso8601
    +        return decoder
    +    }
    +}
    +
    + +
    +

    Default Implementation

    +
    +

    Returns a JSONDecoder with the following properties:

    + +
      +
    • dataDecodingStrategy: .base64
    • +
    • dateDecodingStrategy: .millisecondsSince1970
    • +
    • nonConformingFloatDecodingStrategy: .throw
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static func databaseJSONDecoder(for column: String) -> JSONDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDateDecodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, this property controls the decoding of date properties.

    + +

    Default value is .deferredToDate

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseDateDecodingStrategy: DatabaseDateDecodingStrategy = .timeIntervalSince1970
    +
    +    var name: String
    +    var registrationDate: Date // decoded from epoch timestamp
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseDateDecodingStrategy: DatabaseDateDecodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseColumnDecodingStrategy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When the FetchableRecord type also adopts the standard Decodable +protocol, this property controls the key decoding strategy.

    + +

    Default value is .useDefaultKeys

    + +

    For example:

    +
    struct Player: FetchableRecord, Decodable {
    +    static let databaseDateDecodingStrategy: DatabaseColumnDecodingStrategy = .convertFromSnakeCase
    +
    +    var playerID: String // decoded from player_id
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseColumnDecodingStrategy: DatabaseColumnDecodingStrategy { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From Prepared Statement +

+
+
+
    +
  • +
    + + + + fetchCursor(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over records fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let players = try Player.fetchCursor(statement) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let players = try Player.fetchAll(statement) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let player = try Player.fetchOne(statement) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From SQL +

+
+
+
    +
  • +
    + + + + fetchCursor(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records fetched from an SQL query.

    +
    let players = try Player.fetchCursor(db, sql: "SELECT * FROM player") // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records fetched from an SQL query.

    +
    let players = try Player.fetchAll(db, sql: "SELECT * FROM player") // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record fetched from an SQL query.

    +
    let player = try Player.fetchOne(db, sql: "SELECT * FROM player") // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching From FetchRequest +

+
+
+
    +
  • +
    + + + + fetchCursor(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records fetched from a fetch request.

    +
    let request = try Player.all()
    +let players = try Player.fetchCursor(db, request) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<R>(_ db: Database, _ request: R) throws -> RecordCursor<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records fetched from a fetch request.

    +
    let request = try Player.all()
    +let players = try Player.fetchAll(db, request) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<R>(_ db: Database, _ request: R) throws -> [Self] where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record fetched from a fetch request.

    +
    let request = try Player.filter(key: 1)
    +let player = try Player.fetchOne(db, request) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<R>(_ db: Database, _ request: R) throws -> Self? where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching All +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A cursor over all records fetched from the database.

    +
    // SELECT * FROM player
    +let players = try Player.fetchCursor(db) // Cursor of Player
    +while let player = try players.next() {  // Player
    +    ...
    +}
    +
    + +

    Records are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(_ db: Database) throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An array of all records fetched from the database.

    +
    // SELECT * FROM player
    +let players = try Player.fetchAll(db) // [Player]
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(_ db: Database) throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The first found record.

    +
    // SELECT * FROM player LIMIT 1
    +let player = try Player.fetchOne(db) // Player?
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    A set of all records fetched from the database.

    +
    // SELECT * FROM player
    +let players = try Player.fetchSet(db) // Set<Player>
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(_ db: Database) throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + fetchCursor(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records, given their primary keys.

    +
    let players = try Player.fetchCursor(db, keys: [1, 2, 3]) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<Sequence>(_ db: Database, keys: Sequence)
    +throws -> RecordCursor<Self>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records, given their primary keys.

    +
    let players = try Player.fetchAll(db, keys: [1, 2, 3]) // [Player]
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<Sequence>(_ db: Database, keys: Sequence)
    +throws -> [Self]
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record given its primary key.

    +
    let player = try Player.fetchOne(db, key: 123) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType?)
    +throws -> Self?
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCursor(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records, given their primary keys.

    +
    let players = try Player.fetchCursor(db, ids: [1, 2, 3]) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<Collection>(_ db: Database, ids: Collection)
    +throws -> RecordCursor<Self>
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records, given their primary keys.

    +
    let players = try Player.fetchAll(db, ids: [1, 2, 3]) // [Player]
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<Collection>(_ db: Database, ids: Collection)
    +throws -> [Self]
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record given its primary key.

    +
    let player = try Player.fetchOne(db, id: 123) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database, id: ID) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCursor(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records, given their primary keys.

    +
    let players = try Player.fetchCursor(db, ids: [1, 2, 3]) // Cursor of Player
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor<Collection>(_ db: Database, ids: Collection)
    +throws -> RecordCursor<Self>
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records, given their primary keys.

    +
    let players = try Player.fetchAll(db, ids: [1, 2, 3]) // [Player]
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll<Collection>(_ db: Database, ids: Collection)
    +throws -> [Self]
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record given its primary key.

    +
    let player = try Player.fetchOne(db, id: 123) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database, id: ID.Wrapped) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records, given their primary keys.

    +
    let players = try Player.fetchSet(db, keys: [1, 2, 3]) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<Sequence>(_ db: Database, keys: Sequence)
    +throws -> Set<Self>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable & Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchSet(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records, given their primary keys.

    +
    let players = try Player.fetchSet(db, ids: [1, 2, 3]) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<Collection>(_ db: Database, ids: Collection)
    +throws -> Set<Self>
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable & Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchSet(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records, given their primary keys.

    +
    let players = try Player.fetchSet(db, ids: [1, 2, 3]) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<Collection>(_ db: Database, ids: Collection)
    +throws -> Set<Self>
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Fetching by Key +

+
+
+
    +
  • +
    + + + + fetchCursor(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a cursor over records identified by the provided unique keys +(primary key or any key with a unique index on it).

    +
    // Cursor of Player
    +let players = try Player.fetchCursor(db, keys: [
    +    ["email": "a@example.com"],
    +    ["email": "b@example.com"]])
    +while let player = try players.next() { // Player
    +    ...
    +}
    +
    + +

    Records are iterated in unspecified order.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCursor(_ db: Database, keys: [[String: DatabaseValueConvertible?]])
    +throws -> RecordCursor<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an array of records identified by the provided unique keys +(primary key or any key with a unique index on it).

    +
    // [Player]
    +let players = try Player.fetchAll(db, keys: [
    +    ["email": "a@example.com"],
    +    ["email": "b@example.com"]])
    +
    + +

    The order of records in the returned array is undefined.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchAll(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> [Self]
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    An array of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a single record identified by a unique key (the primary key or +any key with a unique index on it).

    +
    let player = try Player.fetchOne(db, key: ["name": Arthur"]) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchOne(_ db: Database, key: [String : DatabaseValueConvertible?]?) throws -> Self?
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    An optional record.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: TableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records identified by the provided unique keys +(primary key or any key with a unique index on it).

    +
    // Set<Player>
    +let players = try Player.fetchSet(db, keys: [
    +    ["email": "a@example.com"],
    +    ["email": "b@example.com"]])
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records fetched from a prepared statement.

    +
    let statement = try db.makeStatement(sql: "SELECT * FROM player")
    +let players = try Player.fetchSet(statement) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ statement: Statement,
    +    arguments: StatementArguments? = nil,
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + statement + + +
    +

    The statement to run.

    +
    +
    + + arguments + + +
    +

    Optional statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:sql:arguments:adapter:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records fetched from an SQL query.

    +
    let players = try Player.fetchSet(db, sql: "SELECT * FROM player") // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet(
    +    _ db: Database,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil)
    +throws -> Set<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a set of records fetched from a fetch request.

    +
    let request = try Player.all()
    +let players = try Player.fetchSet(db, request) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchSet<R>(_ db: Database, _ request: R) throws -> Set<Self> where R : FetchRequest
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + sql + + +
    +

    a FetchRequest.

    +
    +
    +
    +
    +

    Return Value

    +

    A set of records.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FilteredRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FilteredRequest.html new file mode 100644 index 000000000..f387d87e7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/FilteredRequest.html @@ -0,0 +1,1294 @@ + + + + FilteredRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FilteredRequest

+
+
+ +
public protocol FilteredRequest
+ +
+
+

The protocol for all requests that can be filtered.

+ + +
+
+
+
    +
  • +
    + + + + filter(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE 1
    +var request = Player.all()
    +request = request.filter { db in true }
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +var request = Player.all()
    +request = request.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

FilteredRequest +

+
+
+
    +
  • +
    + + + + filter(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +var request = Player.all()
    +request = request.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT * FROM player WHERE name = 'O''Brien'
    +let name = "O'Brien"
    +var request = Player.all()
    +request = request.filter(literal: "email = \(email)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + none() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that matches nothing.

    +
    // SELECT * FROM player WHERE 0
    +var request = Player.all()
    +request = request.none()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func none() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/JoinableRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/JoinableRequest.html new file mode 100644 index 000000000..4b1c8a59a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/JoinableRequest.html @@ -0,0 +1,1435 @@ + + + + JoinableRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

JoinableRequest

+
+
+ +
public protocol JoinableRequest : TypedRequest, _JoinableRequest
+ +
+
+

The protocol for all requests that can be associated.

+ + +
+
+
+
+ + +
+ +

JoinableRequest +

+
+
+
    +
  • +
    + + + + including(all:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that prefetches an association.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A>(all association: A) -> Self where A : AssociationToMany, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned request does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A>(optional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned request requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A>(required association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that joins an association. The columns of the +associated record are not selected. The returned request does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A>(optional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that joins an association. The columns of the +associated record are not selected. The returned request requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A>(required association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: SelectionRequest +

+
+
+
    +
  • +
    + + + + annotated(withOptional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the current selection.

    +
    // SELECT player.*, team.color
    +// FROM player LEFT JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.all().annotated(withOptional: teamColor)
    +
    + +

    This method performs the same SQL request as including(optional:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String?
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(optional:):

    +
    let teamAlias = TableAlias()
    +let request = Player.all()
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(optional: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A>(withOptional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(withRequired:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the current selection.

    +
    // SELECT player.*, team.color
    +// FROM player JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.all().annotated(withRequired: teamColor)
    +
    + +

    This method performs the same SQL request as including(required:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(required:):

    +
    let teamAlias = TableAlias()
    +let request = Player.all()
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(required: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A>(withRequired association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/MutablePersistableRecord.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/MutablePersistableRecord.html new file mode 100644 index 000000000..c42e1fd35 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/MutablePersistableRecord.html @@ -0,0 +1,2346 @@ + + + + MutablePersistableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

MutablePersistableRecord

+
+
+ +
public protocol MutablePersistableRecord : EncodableRecord, TableRecord
+ +
+
+

Types that adopt MutablePersistableRecord can be inserted, updated, +and deleted.

+ + +
+
+
+
    +
  • +
    + + + + persistenceConflictPolicy + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    The policy that handles SQLite conflicts when records are inserted +or updated.

    + +

    This property is optional: its default value uses the ABORT policy +for both insertions and updates, and has GRDB generate regular +INSERT and UPDATE queries.

    + +

    If insertions are resolved with .ignore policy, the +didInsert(with:for:) method is not called upon successful insertion, +even if a row was actually inserted without any conflict.

    + +

    See https://www.sqlite.org/lang_conflict.html

    + +
    +

    Default Implementation

    +
    +

    Describes the conflict policy for insertions and updates.

    + +

    The default value specifies ABORT policy for both insertions and +updates, which has GRDB generate regular INSERT and UPDATE queries.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var persistenceConflictPolicy: PersistenceConflictPolicy { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + didInsert(with:for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Notifies the record that it was successfully inserted.

    + +

    Do not call this method directly: it is called for you, in a protected +dispatch queue, with the inserted RowID and the eventual +INTEGER PRIMARY KEY column name.

    + +

    This method is optional: the default implementation does nothing.

    +
    struct Player : MutablePersistableRecord {
    +    var id: Int64?
    +    var name: String?
    +
    +    mutating func didInsert(with rowID: Int64, for column: String?) {
    +        self.id = rowID
    +    }
    +}
    +
    + +
    +

    Default Implementation

    +
    +

    Notifies the record that it was successfully inserted.

    + +

    The default implementation does nothing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func didInsert(with rowID: Int64, for column: String?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + rowID + + +
    +

    The inserted rowID.

    +
    +
    + + column + + +
    +

    The name of the eventual INTEGER PRIMARY KEY column.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

CRUD +

+
+
+
    +
  • +
    + + + + insert(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement.

    + +

    This method is guaranteed to have inserted a row in the database if it +returns without error.

    + +

    Upon successful insertion, the didInsert(with:for:) method +is called with the inserted RowID and the eventual INTEGER PRIMARY KEY +column name.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of insert(). In their implementation, it is recommended +that they invoke the performInsert() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT statement.

    + +

    The default implementation for insert() invokes performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func insert(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + update(_:columns:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an UPDATE statement.

    + +

    This method is guaranteed to have updated a row in the database if it +returns without error.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of update(). In their implementation, it is recommended +that they invoke the performUpdate() method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +

    Default Implementation

    +
    +

    Executes an UPDATE statement.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func update(_ db: Database, columns: Set<String>) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + save(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    If the receiver has a non-nil primary key and a matching row in the +database, this method performs an update.

    + +

    Otherwise, performs an insert.

    + +

    This method is guaranteed to have inserted or updated a row in the +database if it returns without error.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of save(). In their implementation, it is recommended +that they invoke the performSave() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs, or errors +thrown by update(). + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    The default implementation for save() invokes performSave().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    mutating func save(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes a DELETE statement.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of delete(). In their implementation, it is recommended +that they invoke the performDelete() method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Executes a DELETE statement.

    + +

    The default implementation for delete() invokes performDelete().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +func delete(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
  • +
    + + + + exists(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Returns true if and only if the primary key matches a row in +the database.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of exists(). In their implementation, it is recommended +that they invoke the performExists() method.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Returns true if and only if the primary key matches a row in +the database.

    + +

    The default implementation for exists() invokes performExists().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func exists(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the primary key matches a row in the database.

    +
    + +
    +
    +
  • +
  • +
    + + + + inserted(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement so that self is saved in the database, +and return the inserted record.

    + +

    Usage:

    +
    let player = Player(id: nil, name: "Arthur")
    +let insertedPlayer = try dbQueue.write { db in
    +    try player.inserted(db)
    +}
    +print(player.id)         // nil
    +print(insertedPlayer.id) // some id
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func inserted(_ db: Database) throws -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + update(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Executes an UPDATE statement that updates all table columns.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func update(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + updateChanges(_:from:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    If the record has any difference from the other record, executes an +UPDATE statement so that those differences and only those difference are +saved in the database.

    + +

    This method is guaranteed to have saved the eventual differences in the +database if it returns without error.

    + +

    For example:

    +
    if let oldPlayer = try Player.fetchOne(db, key: 42) {
    +    var newPlayer = oldPlayer
    +    newPlayer.score += 10
    +    newPlayer.hasAward = true
    +    try newPlayer.updateChanges(db, from: oldRecord)
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    +

    See also

    + updateChanges(_:with:) + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateChanges<Record>(_ db: Database, from record: Record) throws -> Bool where Record : MutablePersistableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + record + + +
    +

    The comparison record.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
  • +
    + + + + updateChanges(_:with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Mutates the record according to the provided closure, and then, if the +record has any difference from its previous version, executes an +UPDATE statement so that those differences and only those difference are +saved in the database.

    + +

    This method is guaranteed to have saved the eventual differences in the +database if it returns without error.

    + +

    For example:

    +
    if var player = try Player.fetchOne(db, key: 42) {
    +    try player.updateChanges(db) {
    +        $0.score += 10
    +        $0.hasAward = true
    +    }
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public mutating func updateChanges(_ db: Database, with change: (inout Self) throws -> Void) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + change + + +
    +

    A closure that modifies the record.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
  • +
    + + + + saved(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database, and return the saved record.

    + +

    Usage:

    +
    let player = Player(id: nil, name: "Arthur")
    +let savedPlayer = try dbQueue.write { db in
    +    try player.saved(db)
    +}
    +print(player.id)      // nil
    +print(savedPlayer.id) // some id
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func saved(_ db: Database) throws -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

CRUD Internals +

+
+
+
    +
  • +
    + + + + performInsert(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performInsert() provides the default implementation for insert(). Types +that adopt MutablePersistableRecord can invoke performInsert() in their +implementation of insert(). They should not provide their own +implementation of performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func performInsert(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performUpdate(_:columns:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performUpdate() provides the default implementation for update(). Types +that adopt MutablePersistableRecord can invoke performUpdate() in their +implementation of update(). They should not provide their own +implementation of performUpdate().

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performUpdate(_ db: Database, columns: Set<String>) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + columns + + +
    +

    The columns to update.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + performSave(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performSave() provides the default implementation for save(). Types +that adopt MutablePersistableRecord can invoke performSave() in their +implementation of save(). They should not provide their own +implementation of performSave().

    + +

    This default implementation forwards the job to update or insert.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func performSave(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performDelete(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performDelete() provides the default implementation for deelte(). Types +that adopt MutablePersistableRecord can invoke performDelete() in +their implementation of delete(). They should not provide their own +implementation of performDelete().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performDelete(_ db: Database) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performExists(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt MutablePersistableRecord.

    + +

    performExists() provides the default implementation for exists(). Types +that adopt MutablePersistableRecord can invoke performExists() in +their implementation of exists(). They should not provide their own +implementation of performExists().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performExists(_ db: Database) throws -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Record Comparison +

+
+
+
    +
  • +
    + + + + updateChanges(_:with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Mutates the record according to the provided closure, and then, if the +record has any difference from its previous version, executes an +UPDATE statement so that those differences and only those difference are +saved in the database.

    + +

    This method is guaranteed to have saved the eventual differences in the +database if it returns without error.

    + +

    For example:

    +
    if let player = try Player.fetchOne(db, key: 42) {
    +    try player.updateChanges(db) {
    +        $0.score += 10
    +        $0.hasAward = true
    +    }
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. +PersistenceError.recordNotFound is thrown if the primary key does not +match any row in the database and record could not be updated. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateChanges(_ db: Database, with change: (Self) throws -> Void) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + change + + +
    +

    A closure that modifies the record.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the record had changes.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/OrderedRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/OrderedRequest.html new file mode 100644 index 000000000..a6c0d398d --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/OrderedRequest.html @@ -0,0 +1,1353 @@ + + + + OrderedRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

OrderedRequest

+
+
+ +
public protocol OrderedRequest
+ +
+
+

The protocol for all requests that can be ordered.

+ + +
+
+
+
    +
  • +
    + + + + order(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided orderings promise.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order { _ in [Column("name")] }
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order{ _ in [Column("email")] }
    +    .reversed()
    +    .order{ _ in [Column("name")] }
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request with the provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order(Column("name"))
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order(Column("email"))
    +    .reversed()
    +    .order(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reversed() + +
    +
    +
    +
    +
    +
    +

    Creates a request that reverses applied orderings.

    +
    // SELECT * FROM player ORDER BY name DESC
    +var request = Player.all().order(Column("name"))
    +request = request.reversed()
    +
    + +

    If no ordering was applied, the returned request is identical.

    +
    // SELECT * FROM player
    +var request = Player.all()
    +request = request.reversed()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func reversed() -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unordered() + +
    +
    +
    +
    +
    +
    +

    Creates a request without any ordering.

    +
    // SELECT * FROM player
    +var request = Player.all().order(Column("name"))
    +request = request.unordered()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func unordered() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

OrderedRequest +

+
+
+
    +
  • +
    + + + + order(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to sql.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order(sql: "name")
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order(sql: "email")
    +    .order(sql: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to an SQL literal.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order(literal: "name")
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order(literal: "email")
    +    .order(literal: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/PersistableRecord.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/PersistableRecord.html new file mode 100644 index 000000000..2348ade34 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/PersistableRecord.html @@ -0,0 +1,1448 @@ + + + + PersistableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistableRecord

+
+
+ +
public protocol PersistableRecord : MutablePersistableRecord
+ +
+
+

Types that adopt PersistableRecord can be inserted, updated, and deleted.

+ +

Unlike MutablePersistableRecord, the insert(_:) and save(_:) methods +are not mutating methods.

+ + +
+
+
+
    +
  • +
    + + + + didInsert(with:for:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Notifies the record that it was successfully inserted.

    + +

    Do not call this method directly: it is called for you, in a protected +dispatch queue, with the inserted RowID and the eventual +INTEGER PRIMARY KEY column name.

    + +

    This method is optional: the default implementation does nothing.

    + +

    If you need a mutating variant of this method, adopt the +MutablePersistableRecord protocol instead.

    + +
    +

    Default Implementation

    +
    +

    Notifies the record that it was successfully inserted.

    + +

    The default implementation does nothing.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func didInsert(with rowID: Int64, for column: String?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + rowID + + +
    +

    The inserted rowID.

    +
    +
    + + column + + +
    +

    The name of the eventual INTEGER PRIMARY KEY column.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + insert(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT statement.

    + +

    This method is guaranteed to have inserted a row in the database if it +returns without error.

    + +

    Upon successful insertion, the didInsert(with:for:) method +is called with the inserted RowID and the eventual INTEGER PRIMARY KEY +column name.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of insert(). In their implementation, it is recommended +that they invoke the performInsert() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs. + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT statement.

    + +

    The default implementation for insert() invokes performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func insert(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + save(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    If the receiver has a non-nil primary key and a matching row in the +database, this method performs an update.

    + +

    Otherwise, performs an insert.

    + +

    This method is guaranteed to have inserted or updated a row in the +database if it returns without error.

    + +

    This method has a default implementation, so your adopting types don’t +have to implement it. Yet your types can provide their own +implementation of save(). In their implementation, it is recommended +that they invoke the performSave() method.

    +
    +

    Throws

    + A DatabaseError whenever an SQLite error occurs, or errors +thrown by update(). + +
    + +
    +

    Default Implementation

    +
    +

    Executes an INSERT or an UPDATE statement so that self is saved in +the database.

    + +

    The default implementation for save() invokes performSave().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func save(_ db: Database) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Immutable CRUD Internals +

+
+
+
    +
  • +
    + + + + performInsert(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt PersistableRecord.

    + +

    performInsert() provides the default implementation for insert(). Types +that adopt PersistableRecord can invoke performInsert() in their +implementation of insert(). They should not provide their own +implementation of performInsert().

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performInsert(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + performSave(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Don’t invoke this method directly: it is an internal method for types +that adopt PersistableRecord.

    + +

    performSave() provides the default implementation for save(). Types +that adopt PersistableRecord can invoke performSave() in their +implementation of save(). They should not provide their own +implementation of performSave().

    + +

    This default implementation forwards the job to update or insert.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func performSave(_ db: Database) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/RowAdapter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/RowAdapter.html new file mode 100644 index 000000000..f39c9fe7e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/RowAdapter.html @@ -0,0 +1,1190 @@ + + + + RowAdapter Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RowAdapter

+
+
+ +
public protocol RowAdapter : _RowAdapter
+ +
+
+

RowAdapter is a protocol that helps two incompatible row interfaces +working together.

+ +

GRDB ships with four concrete types that adopt the RowAdapter protocol:

+ + + +

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.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func addingScopes(_ scopes: [String : RowAdapter]) -> RowAdapter
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + scopes + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLExpressible.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLExpressible.html new file mode 100644 index 000000000..e60867a9d --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLExpressible.html @@ -0,0 +1,1248 @@ + + + + SQLExpressible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLExpressible

+
+
+ +
public protocol SQLExpressible
+ +
+
+

SQLExpressible is the protocol for all types that can be used as an +SQL expression.

+ +

It is adopted by protocols like DatabaseValueConvertible, and types +like Column.

+ +

See https://github.com/groue/GRDB.swift/#the-query-interface

+ + +
+
+
+ +
+
+
+ + +
+ +

Available where Self: RawRepresentable, Self.RawValue: SQLExpressible +

+
+
+
    +
  • +
    + + + + sqlExpression + + + Default implementation + +
    +
    +
    +
    +
    +
    + +
    +

    Default Implementation

    +
    +

    Returns the raw value as an SQL expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self == Column +

+
+
+
    +
  • +
    + + + + rowID + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The hidden rowID column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var rowID: Self { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLOrderingTerm.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLOrderingTerm.html new file mode 100644 index 000000000..d08848ce2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLOrderingTerm.html @@ -0,0 +1,1147 @@ + + + + SQLOrderingTerm Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLOrderingTerm

+
+
+ +
public protocol SQLOrderingTerm
+ +
+
+

The protocol for all types that can be used as an SQL ordering term, as +described at https://www.sqlite.org/syntax/ordering-term.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSelectable.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSelectable.html new file mode 100644 index 000000000..5ab681eda --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSelectable.html @@ -0,0 +1,1147 @@ + + + + SQLSelectable Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSelectable

+
+
+ +
public protocol SQLSelectable
+ +
+
+

SQLSelectable is the protocol for types that can be selected, as +described at https://www.sqlite.org/syntax/result-column.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSpecificExpressible.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSpecificExpressible.html new file mode 100644 index 000000000..6a0ec1907 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSpecificExpressible.html @@ -0,0 +1,1539 @@ + + + + SQLSpecificExpressible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSpecificExpressible

+
+
+ +
public protocol SQLSpecificExpressible : SQLExpressible, SQLOrderingTerm, SQLSelectable
+ +
+
+

SQLSpecificExpressible is a protocol for all database-specific types that +can be turned into an SQL expression. Types whose existence is not purely +dedicated to the database should adopt the SQLExpressible +protocol instead.

+ +

For example, Column is a type that only exists to help you build requests, +and it adopts SQLSpecificExpressible.

+ +

On the other side, Int adopts SQLExpressible.

+ + +
+
+
+
+ + +
+ +

SQLExpressible +

+
+
+ +
+
+
+ + +
+ +

SQL Ordering Support +

+
+
+ +
+
+
+ + +
+ +

SQL Collations Support +

+
+
+
    +
  • +
    + + + + collating(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a collated expression.

    + +

    For example:

    +
    Player.filter(Column("email").collating(.nocase) == "contact@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func collating(_ collation: Database.CollationName) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + collating(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a collated expression.

    + +

    For example:

    +
    Player.filter(Column("name").collating(.localizedStandardCompare) == "Hervé")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func collating(_ collation: DatabaseCollation) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Like Operator +

+
+
+
    +
  • +
    + + + + like(_:escape:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    An SQL expression with the LIKE SQL operator.

    +
    // email LIKE '%@example.com"
    +Column("email").like("%@example.com")
    +
    +// title LIKE '%10\%%' ESCAPE '\'
    +Column("title").like("%10\\%%", escape: "\\")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func like(_ pattern: SQLExpressible, escape: SQLExpressible? = nil) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSubqueryable.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSubqueryable.html new file mode 100644 index 000000000..d39ae4244 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SQLSubqueryable.html @@ -0,0 +1,1268 @@ + + + + SQLSubqueryable Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSubqueryable

+
+
+ +
public protocol SQLSubqueryable : SQLSpecificExpressible
+ +
+
+

The protocol for types that can be embedded as a subquery.

+ + +
+
+
+ +
+
+
+ + +
+ +

SQLSubqueryable +

+
+
+
    +
  • +
    + + + + sqlExpression + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a subquery expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + contains(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an expression that checks the inclusion of the expression in +the subquery.

    +
    // 1000 IN (SELECT score FROM player)
    +let request = Player.select(Column("score"), as: Int.self)
    +let condition = request.contains(1000)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + exists() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns an expression that is true if and only if the subquery would +return one or more rows.

    +
    // EXISTS (SELECT * FROM player WHERE name = 'Arthur')
    +let request = Player.filter(Column("name") == "Arthur")
    +let condition = request.exists()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists() -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SelectionRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SelectionRequest.html new file mode 100644 index 000000000..48a5960ea --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/SelectionRequest.html @@ -0,0 +1,1333 @@ + + + + SelectionRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SelectionRequest

+
+
+ +
public protocol SelectionRequest
+ +
+
+

The protocol for all requests that can refine their selection.

+ + +
+
+
+
    +
  • +
    + + + + select(_:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection promise.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select { db in [Column("id"), Column("email") })
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select { db in [Column("id")] }
    +    .select { db in [Column("email")] }
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select(Column("id"), Column("email"))
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select(Column("id"))
    +    .select(Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection promise.

    +
    // SELECT id, email, name FROM player
    +var request = Player.all()
    +request = request
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: { db in [Column("name")] })
    +
    + +
    +

    Default Implementation

    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +var request = Player.all()
    +request = request
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func annotated(with selection: @escaping (Database) throws -> [SQLSelectable]) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SelectionRequest +

+
+
+
    +
  • +
    + + + + select(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects sql.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select(sql: "id, email")
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select(sql: "id")
    +    .select(sql: "email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT id, email, score + 1000 FROM player
    +let bonus = 1000
    +var request = Player.all()
    +request = request.select(literal: """
    +    id, email, score + \(bonus)
    +    """)
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select(...)
    +    .select(literal: "email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(literal sqlLiteral: SQL) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/StatementBinding.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/StatementBinding.html new file mode 100644 index 000000000..8b5285e68 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/StatementBinding.html @@ -0,0 +1,1181 @@ + + + + StatementBinding Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

StatementBinding

+
+
+ +
public protocol StatementBinding
+ +
+
+

Undocumented

+ + +
+
+
+
    +
  • +
    + + + + bind(to:at:) + +
    +
    +
    +
    +
    +
    +

    Binds a statement argument.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    An SQLite statement.

    +
    +
    + + index + + +
    +

    1-based index to statement arguments

    +
    +
    +
    +
    +

    Return Value

    +

    the code returned by the sqlite3_bind_xxx function.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/StatementColumnConvertible.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/StatementColumnConvertible.html new file mode 100644 index 000000000..34d0ff5b7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/StatementColumnConvertible.html @@ -0,0 +1,1210 @@ + + + + StatementColumnConvertible Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

StatementColumnConvertible

+
+
+ +
public protocol StatementColumnConvertible
+ +
+
+

The StatementColumnConvertible protocol grants access to the low-level C +interface that extracts values from query results: +https://www.sqlite.org/c3ref/column_blob.html. It can bring performance +improvements.

+ +

To use it, have a value type adopt both StatementColumnConvertible and +DatabaseValueConvertible. GRDB will then automatically apply the +optimization whenever direct access to SQLite is possible:

+
let rows = Row.fetchCursor(db, sql: "SELECT ...")
+while let row = try rows.next() {
+    let int: Int = row[0]                 // there
+}
+let ints = Int.fetchAll(db, sql: "SELECT ...") // there
+struct Player {
+    init(row: Row) {
+        name = row["name"]                // there
+        score = row["score"]              // there
+    }
+}
+
+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Initializes a value from a raw SQLite statement pointer, if possible.

    + +

    For example, here is the how Int64 adopts StatementColumnConvertible:

    +
    extension Int64: StatementColumnConvertible {
    +    init?(sqliteStatement: SQLiteStatement, index: Int32) {
    +        self = sqlite3_column_int64(sqliteStatement, index)
    +    }
    +}
    +
    + +

    This initializer is never called for NULL database values. Just return +nil for failed conversions: GRDB will interpret a nil result as a +decoding failure.

    + +

    See https://www.sqlite.org/c3ref/column_blob.html for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TableRecord.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TableRecord.html new file mode 100644 index 000000000..a5f8e64dd --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TableRecord.html @@ -0,0 +1,5960 @@ + + + + TableRecord Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRecord

+
+
+ +
public protocol TableRecord
+ +
+
+

Types that adopt TableRecord declare a particular relationship with +a database table.

+ +

Types that adopt both TableRecord and FetchableRecord are granted with +built-in methods that allow to fetch instances identified by key:

+
try Player.fetchOne(db, key: 123)  // Player?
+try Citizenship.fetchOne(db, key: ["citizenId": 12, "countryId": 45]) // Citizenship?
+
+ + +
+
+
+
    +
  • +
    + + + + databaseTableName + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    The name of the database table used to build requests.

    +
    struct Player : TableRecord {
    +    static var databaseTableName = "player"
    +}
    +
    +// SELECT * FROM player
    +try Player.fetchAll(db)
    +
    + +
    +

    Default Implementation

    +
    +

    The default name of the database table used to build requests.

    + +
      +
    • Player -> “player”
    • +
    • Place -> “place”
    • +
    • PostalAddress -> “postalAddress”
    • +
    • HTTPRequest -> “httpRequest”
    • +
    • TOEFL -> “toefl”
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseTableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseSelection + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    The default request selection.

    + +

    Unless said otherwise, requests select all columns:

    +
    // SELECT * FROM player
    +try Player.fetchAll(db)
    +
    + +

    You can provide a custom implementation and provide an explicit list +of columns:

    +
    struct RestrictedPlayer : TableRecord {
    +    static var databaseTableName = "player"
    +    static var databaseSelection = [Column("id"), Column("name")]
    +}
    +
    +// SELECT id, name FROM player
    +try RestrictedPlayer.fetchAll(db)
    +
    + +

    You can also add extra columns such as the rowid column:

    +
    struct ExtendedPlayer : TableRecord {
    +    static var databaseTableName = "player"
    +    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
    +}
    +
    +// SELECT *, rowid FROM player
    +try ExtendedPlayer.fetchAll(db)
    +
    + +
    +

    Default Implementation

    +
    +

    Default value: [AllColumns()].

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    static var databaseSelection: [SQLSelectable] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a QueryInterfaceRequest with a matching predicate.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func matching(_ pattern: FTS3Pattern?) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to TableRecord +

+
+
+
    +
  • +
    + + + + belongsTo(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +type, based on a database foreign key.

    +
    struct Author: TableRecord { ... }
    +struct Book: TableRecord {
    +    static let author = belongsTo(Author.self)
    +}
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all books with their authors:
    +let request = Book.including(optional: Book.author)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct BookInfo: FetchableRecord, Decodable {
    +    var book: Book
    +    var author: Author?
    +}
    +
    +let bookInfos = try dbQueue.read { db in
    +    return try BookInfo.fetchAll(db, request)
    +}
    +for bookInfo in bookInfos {
    +    print("\(bookInfo.book.title) by \(bookInfo.author.name)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Book: TableRecord, EncodableRecord {
    +    static let author = belongsTo(Author.self)
    +    var author: QueryInterfaceRequest<Author> {
    +        return request(for: Book.author)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let book: Book = ...
    +    let author = try book.author.fetchOne(db) // Author?
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func belongsTo<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<Self, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination type, +based on a database foreign key.

    +
    struct Book: TableRecord { ... }
    +struct Author: TableRecord {
    +    static let books = hasMany(Book.self)
    +}
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all (author, book) pairs:
    +let request = Author.including(required: Author.books)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct Authorship: FetchableRecord, Decodable {
    +    var author: Author
    +    var book: Book
    +}
    +
    +let authorships = try dbQueue.read { db in
    +    return try Authorship.fetchAll(db, request)
    +}
    +for authorship in authorships {
    +    print("\(authorship.author.name) wrote \(authorship.book.title)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Author: TableRecord, EncodableRecord {
    +    static let books = hasMany(Book.self)
    +    var books: QueryInterfaceRequest<Book> {
    +        return request(for: Author.books)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let author: Author = ...
    +    let books = try author.books.fetchAll(db) // [Book]
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasMany<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<Self, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination type, +based on a database foreign key.

    +
    struct Demographics: TableRecord { ... }
    +struct Country: TableRecord {
    +    static let demographics = hasOne(Demographics.self)
    +}
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all countries with their demographic profile:
    +let request = Country.including(optional: Country.demographics)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct CountryInfo: FetchableRecord, Decodable {
    +    var country: Country
    +    var demographics: Demographics?
    +}
    +
    +let countryInfos = try dbQueue.read { db in
    +    return try CountryInfo.fetchAll(db, request)
    +}
    +for countryInfo in countryInfos {
    +    print("\(countryInfo.country.name) has \(countryInfo.demographics.population) citizens")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Country: TableRecord, EncodableRecord {
    +    static let demographics = hasOne(Demographics.self)
    +    var demographics: QueryInterfaceRequest<Demographics> {
    +        return request(for: Country.demographics)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let country: Country = ...
    +    let demographics = try country.demographics.fetchOne(db) // Demographics?
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasOne<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<Self, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to Table +

+
+
+
    +
  • +
    + + + + belongsTo(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +table, based on a database foreign key.

    + +

    For more information, see TableRecord.belongsTo(_:key:using:) where +the first argument is TableRecord.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func belongsTo<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasMany(_:key:using:) where +the first argument is TableRecord.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasMany<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasOne(_:key:using:) where +the first argument is TableRecord.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasOne<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to CommonTableExpression +

+
+
+
    +
  • +
    + + + + association(to:on:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +

    For example, you can build a request that fetches all chats with their +latest message:

    +
    let latestMessageRequest = Message
    +    .annotated(with: max(Column("date")))
    +    .group(Column("chatID"))
    +
    +let latestMessageCTE = CommonTableExpression(
    +    named: "latestMessage",
    +    request: latestMessageRequest)
    +
    +let latestMessage = Chat.association(
    +    to: latestMessageCTE,
    +    on: { chat, latestMessage in
    +        chat[Column("id")] == latestMessage[Column("chatID")]
    +    })
    +
    +// WITH latestMessage AS
    +//   (SELECT *, MAX(date) FROM message GROUP BY chatID)
    +// SELECT chat.*, latestMessage.*
    +// FROM chat
    +// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
    +let request = Chat
    +    .with(latestMessageCTE)
    +    .including(optional: latestMessage)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func association<Destination>(
    +    to cte: CommonTableExpression<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func association<Destination>(
    +    to cte: CommonTableExpression<Destination>)
    +-> JoinAssociation<Self, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

“Through” Associations +

+
+
+
    +
  • +
    + + + + hasMany(_:through:using:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has Many Through” association between Self and the +destination type.

    +
    struct Country: TableRecord {
    +    static let passports = hasMany(Passport.self)
    +    static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
    +}
    +
    +struct Passport: TableRecord {
    +    static let citizen = belongsTo(Citizen.self)
    +}
    +
    +struct Citizen: TableRecord { }
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all (country, citizen) pairs:
    +let request = Country.including(required: Coutry.citizens)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct Citizenship: FetchableRecord, Decodable {
    +    var country: Country
    +    var citizen: Citizen
    +}
    +
    +let citizenships = try dbQueue.read { db in
    +    return try Citizenship.fetchAll(db, request)
    +}
    +for citizenship in citizenships {
    +    print("\(citizenship.citizen.name) is a citizen of \(citizenship.country.name)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Country: TableRecord, EncodableRecord {
    +    static let passports = hasMany(Passport.self)
    +    static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
    +    var citizens: QueryInterfaceRequest<Citizen> {
    +        return request(for: Country.citizens)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let country: Country = ...
    +    let citizens = try country.citizens.fetchAll(db) // [Country]
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasMany<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasManyThroughAssociation<Self, Target.RowDecoder>
    +where Pivot: Association,
    +      Target: Association,
    +      Pivot.OriginRowDecoder == Self,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:through:using:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a “Has One Through” association between Self and the +destination type.

    +
    struct Book: TableRecord {
    +    static let library = belongsTo(Library.self)
    +    static let returnAddress = hasOne(Address.self, through: library, using: Library.address)
    +}
    +
    +struct Library: TableRecord {
    +    static let address = hasOne(Address.self)
    +}
    +
    +struct Address: TableRecord { ... }
    +
    + +

    The association will let you define requests that load both the source +and the destination type:

    +
    // A request for all (book, returnAddress) pairs:
    +let request = Book.including(required: Book.returnAddress)
    +
    + +

    To consume those requests, define a type that adopts both the +FetchableRecord and Decodable protocols:

    +
    struct Todo: FetchableRecord, Decodable {
    +    var book: Book
    +    var address: Address
    +}
    +
    +let todos = try dbQueue.read { db in
    +    return try Todo.fetchAll(db, request)
    +}
    +for todo in todos {
    +    print("Please return \(todo.book) to \(todo.address)")
    +}
    +
    + +

    It is recommended that you define, alongside the static association, a +property with the same name:

    +
    struct Book: TableRecord, EncodableRecord {
    +    static let library = belongsTo(Library.self)
    +    static let returnAddress = hasOne(Address.self, through: library, using: library.address)
    +    var returnAddress: QueryInterfaceRequest<Address> {
    +        return request(for: Book.returnAddress)
    +    }
    +}
    +
    + +

    This property will let you navigate from the source type to the +destination type:

    +
    try dbQueue.read { db in
    +    let book: Book = ...
    +    let address = try book.returnAddress.fetchOne(db) // Address?
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func hasOne<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasOneThroughAssociation<Self, Target.RowDecoder>
    +where Pivot: AssociationToOne,
    +      Target: AssociationToOne,
    +      Pivot.OriginRowDecoder == Self,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Joining Methods +

+
+
+
    +
  • +
    + + + + including(all:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that prefetches an association.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func including<A: AssociationToMany>(all association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func including<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func including<A: Association>(required association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(optional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func joining<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(required:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func joining<A: Association>(required association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(withOptional:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the selection.

    +
    // SELECT player.*, team.color
    +// FROM player LEFT JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.annotated(withOptional: teamColor)
    +
    + +

    This method performs the same SQL request as including(optional:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String?
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(optional:):

    +
    let teamAlias = TableAlias()
    +let request = Player
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(optional: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated<A: Association>(withOptional association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(withRequired:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the selection.

    +
    // SELECT player.*, team.color
    +// FROM player JOIN team ...
    +let teamColor = Player.team.select(Column("color"))
    +let request = Player.annotated(withRequired: teamColor)
    +
    + +

    This method performs the same SQL request as including(required:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(required:):

    +
    let teamAlias = TableAlias()
    +let request = Player
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(required: Player.team.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated<A: Association>(withRequired association: A)
    +-> QueryInterfaceRequest<Self>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Aggregates +

+
+
+
    +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let request = Player.annotated(with: Player.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with aggregates: AssociationAggregate<Self>...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let request = Player.annotated(with: [Player.books.count])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with aggregates: [AssociationAggregate<Self>]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided aggregate predicate.

    +
    // SELECT player.*
    +// FROM player LEFT JOIN book ...
    +// HAVING COUNT(DISTINCT book.id) = 0
    +var request = Player.all()
    +request = request.having(Player.books.isEmpty)
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func having(_ predicate: AssociationAggregate<Self>) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Request Derivation +

+
+
+
    +
  • +
    + + + + all() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches all records.

    +
    // SELECT * FROM player
    +let request = Player.all()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func all() -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + none() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches no record.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func none() -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let request = Player.select(Column("id"), Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(_ selection: SQLSelectable...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let request = Player.select([Column("id"), Column("email")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(_ selection: [SQLSelectable]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects sql.

    +
    // SELECT id, email FROM player
    +let request = Player.select(sql: "id, email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT id, email, score + 1000 FROM player
    +let bonus = 1000
    +let request = Player.select(literal: """
    +    id, email, score + \(bonus)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select(literal sqlLiteral: SQL) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.select([max(Column("score"))], as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    _ selection: [SQLSelectable],
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.select(max(Column("score")), as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    _ selection: SQLSelectable...,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(sql:arguments:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects sql, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.select(sql: "max(score)", as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:as:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal, and fetches values of +type type.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +let defaultName = "Anonymous"
    +let request = Player.select(
    +    literal: "IFNULL(name, \(defaultName))",
    +    as: String.self)
    +let name: String? = try request.fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func select<RowDecoder>(
    +    literal sqlLiteral: SQL,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let request = Player
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: [Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let request = Player
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func annotated(with selection: SQLSelectable...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let request = Player.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, message: "Did you mean filter(id:﹚ or filter(key:﹚? If not, prefer filter(value.databaseValue﹚ instead. See also none(﹚.")
    +public static func filter(_ predicate: SQLExpressible) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let request = Player.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(_ predicate: SQLSpecificExpressible) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id = 1
    +let request = Player.filter(key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<PrimaryKeyType>(key: PrimaryKeyType?)
    +-> QueryInterfaceRequest<Self>
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let request = Player.filter(keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<Sequence>(keys: Sequence)
    +-> QueryInterfaceRequest<Self>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE personId = 1 AND countryCode = 'FR'
    +let request = Passport.filter(key: ["personId": 1, "countryCode": "FR"])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(key: [String : DatabaseValueConvertible?]?) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE (personId = 1 AND countryCode = 'FR') OR ...
    +let request = Passport.filter(keys: [["personId": 1, "countryCode": "FR"], ...])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(keys: [[String : DatabaseValueConvertible?]]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let request = Player.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT * FROM player WHERE name = 'O''Brien'
    +let name = "O'Brien"
    +let request = Player.filter(literal: "email = \(email)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(literal sqlLiteral: SQL) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(_ orderings: SQLOrderingTerm...) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order([Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(_ orderings: [SQLOrderingTerm]) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + orderByPrimaryKey() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted by primary key.

    +
    // SELECT * FROM player ORDER BY id
    +let request = Player.orderByPrimaryKey()
    +
    +// SELECT * FROM country ORDER BY code
    +let request = Country.orderByPrimaryKey()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func orderByPrimaryKey() -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(sql:arguments:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to sql.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order(sql: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(literal:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to an SQL literal.

    +
    // SELECT * FROM player ORDER BY name
    +let request = Player.order(literal: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func order(literal sqlLiteral: SQL) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + limit(_:offset:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches limit rows, starting at +offset.

    +
    // SELECT * FROM player LIMIT 1
    +let request = Player.limit(1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func limit(_ limit: Int, offset: Int? = nil) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.avgScore < player.score” condition in +the ON clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ... AND team.avgScore < player.score
    +let playerAlias = TableAlias()
    +let request = Player
    +    .aliased(playerAlias)
    +    .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func aliased(_ alias: TableAlias) -> QueryInterfaceRequest<Self>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns a request which embeds the common table expression.

    + +

    If a common table expression with the same table name had already been +embedded, it is replaced by the new one.

    + +

    For example, you can build a request that fetches all chats with their +latest post:

    +
    let latestMessageRequest = Message
    +    .annotated(with: max(Column("date")))
    +    .group(Column("chatID"))
    +
    +let latestMessageCTE = CommonTableExpression(
    +    named: "latestMessage",
    +    request: latestMessageRequest)
    +
    +let latestMessage = Chat.association(
    +    to: latestMessageCTE,
    +    on: { chat, latestMessage in
    +        chat[Column("id")] == latestMessage[Column("chatID")]
    +    })
    +
    +// WITH latestMessage AS
    +//   (SELECT *, MAX(date) FROM message GROUP BY chatID)
    +// SELECT chat.*, latestMessage.*
    +// FROM chat
    +// LEFT JOIN latestMessage ON chat.id = latestMessage.chatID
    +let request = Chat
    +    .with(latestMessageCTE)
    +    .including(optional: latestMessage)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> QueryInterfaceRequest<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    A request.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Counting All +

+
+
+
    +
  • +
    + + + + fetchCount(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    The number of records.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fetchCount(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQL Generation +

+
+
+
    +
  • +
    + + + + numberOfSelectedColumns(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns the number of selected columns.

    + +

    For example:

    +
    struct Player: TableRecord {
    +    static let databaseTableName = "player"
    +}
    +
    +try dbQueue.write { db in
    +    try db.create(table: "player") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("name", .text)
    +        t.column("score", .integer)
    +    }
    +
    +    // 3
    +    try Player.numberOfSelectedColumns(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func numberOfSelectedColumns(_ db: Database) throws -> Int
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Delete +

+
+
+
    +
  • +
    + + + + deleteAll(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Deletes all records; returns the number of deleted rows.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Player.exists(db, key: 123)
    +try Country.exists(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Document.exists(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this unique key (primary key or any key +with a unique index on it).

    +
    try Player.exists(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Player.deleteAll(db, keys: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Country.deleteAll(db, keys: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Document.deleteAll(db, keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll<Sequence>(_ db: Database, keys: Sequence)
    +throws -> Int
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Player.deleteOne(db, key: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Country.deleteOne(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Document.deleteOne(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType?)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by the provided unique keys (primary key or +any key with a unique index on it); returns the number of deleted rows.

    +
    try Player.deleteAll(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by a unique key (the primary key or any key +with a unique index on it); returns whether a database row was deleted.

    +
    Player.deleteOne(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Update +

+
+
+
    +
  • +
    + + + + updateAll(_:onConflict:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Updates all records; returns the number of updated records.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.updateAll(db, [Column("score").set(to: 0)])
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignments: [ColumnAssignment])
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution, +defaulting to the record’s persistenceConflictPolicy.

    +
    +
    + + assignments + + +
    +

    An array of column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
  • +
    + + + + updateAll(_:onConflict:_:_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Updates all records; returns the number of updated records.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.updateAll(db, Column("score").set(to: 0))
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignment: ColumnAssignment,
    +    _ otherAssignments: ColumnAssignment...)
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution, +defaulting to the record’s persistenceConflictPolicy.

    +
    +
    + + assignment + + +
    +

    A column assignment.

    +
    +
    + + otherAssignments + + +
    +

    Eventual other column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: EncodableRecord +

+
+
+
    +
  • +
    + + + + request(for:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request that fetches the associated record(s).

    + +

    For example:

    +
    struct Team: TableRecord, EncodableRecord {
    +    static let players = hasMany(Player.self)
    +    var players: QueryInterfaceRequest<Player> {
    +        return request(for: Team.players)
    +    }
    +}
    +
    +let team: Team = ...
    +let players = try team.players.fetchAll(db) // [Player]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func request<A: Association>(for association: A)
    +-> QueryInterfaceRequest<A.RowDecoder>
    +where A.OriginRowDecoder == Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let request = Player.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(id: ID) -> QueryInterfaceRequest<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let request = Player.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<Self>
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let request = try Player.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func selectID() -> QueryInterfaceRequest<ID>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let request = Player.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter(id: ID.Wrapped) -> QueryInterfaceRequest<Self>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let request = Player.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<Self>
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let request = try Player.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func selectID() -> QueryInterfaceRequest<ID.Wrapped>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Player.deleteOne(db, id: 123)
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists(_ db: Database, id: ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Player.deleteOne(db, id: 123)
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func exists(_ db: Database, id: ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Player.deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Country.deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Document.deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Player.deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne(_ db: Database, id: ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: Identifiable, ID: _OptionalProtocol, ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete records identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Player.deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Country.deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Document.deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Delete a record, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Player.deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Country.deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Document.deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public static func deleteOne(_ db: Database, id: ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TableRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TableRequest.html new file mode 100644 index 000000000..e80cb6cf5 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TableRequest.html @@ -0,0 +1,1829 @@ + + + + TableRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TableRequest

+
+
+ +
public protocol TableRequest
+ +
+
+

The protocol for all requests that feed from a database table

+ + +
+
+
+
    +
  • +
    + + + + databaseTableName + +
    +
    +
    +
    +
    +
    +

    The name of the database table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var databaseTableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.avgScore < player.score” condition in +the ON clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ... AND team.avgScore < player.score
    +let playerAlias = TableAlias()
    +let request = Player
    +    .all()
    +    .aliased(playerAlias)
    +    .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func aliased(_ alias: TableAlias) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Full Text Search +

+
+
+
    +
  • +
    + + + + matching(_:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request with a full-text predicate added to the eventual +set of already applied predicates.

    +
    // SELECT * FROM book WHERE book MATCH '...'
    +var request = Book.all()
    +request = request.matching(pattern)
    +
    + +

    If the search pattern is nil, the request does not match any +database row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func matching(_ pattern: FTS3Pattern?) -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: FilteredRequest, Self: TypedRequest +

+
+
+
    +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id = 1
    +let request = try Player...filter(key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<PrimaryKeyType>(key: PrimaryKeyType?) -> Self where PrimaryKeyType : DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + key + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id IN (1, 2, 3)
    +let request = try Player...filter(keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Sequence: Swift.Sequence>(keys: Sequence)
    +-> Self
    +where Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + keys + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by unique key.

    +
    // SELECT * FROM player WHERE ... email = 'arthur@example.com'
    +let request = try Player...filter(key: ["email": "arthur@example.com"])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(key: [String : DatabaseValueConvertible?]?) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + key + + +
    +

    A unique key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by unique key.

    +
    // SELECT * FROM player WHERE ... email = 'arthur@example.com' OR ...
    +let request = try Player...filter(keys: [["email": "arthur@example.com"], ...])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(keys: [[String : DatabaseValueConvertible?]]) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + keys + + +
    +

    A collection of unique keys

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: FilteredRequest, Self: TypedRequest, RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id = 1
    +let request = try Player...filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id IN (1, 2, 3)
    +let request = try Player...filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection: Swift.Collection>(ids: Collection)
    +-> Self
    +where Collection.Element == RowDecoder.ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: FilteredRequest, Self: TypedRequest, RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id = 1
    +let request = try Player...filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID.Wrapped) -> Self
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE ... id IN (1, 2, 3)
    +let request = try Player...filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection: Swift.Collection>(ids: Collection)
    +-> Self
    +where Collection.Element == RowDecoder.ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: OrderedRequest +

+
+
+
    +
  • +
    + + + + orderByPrimaryKey() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request ordered by primary key.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func orderByPrimaryKey() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Self: AggregatingRequest +

+
+
+
    +
  • +
    + + + + groupByPrimaryKey() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    Creates a request grouped by primary key.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func groupByPrimaryKey() -> Self
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TransactionObserver.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TransactionObserver.html new file mode 100644 index 000000000..342a00090 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TransactionObserver.html @@ -0,0 +1,1441 @@ + + + + TransactionObserver Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TransactionObserver

+
+
+ +
public protocol TransactionObserver : AnyObject
+ +
+
+

A transaction observer is notified of all changes and transactions committed +or rollbacked on a database.

+ +

Adopting types must be a class.

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Filters database changes that should be notified the the +databaseDidChange(with:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Notifies a database change (insert, update, or delete).

    + +

    The change is pending until the current transaction ends. See +databaseWillCommit, databaseDidCommit and databaseDidRollback.

    + +

    This method is called in a protected dispatch queue, serialized will all +database updates.

    + +

    The event is only valid for the duration of this method call. If you +need to keep it longer, store a copy: event.copy()

    + +

    The observer has an opportunity to stop receiving further change events +from the current transaction by calling the +stopObservingDatabaseChangesUntilNextTransaction() method.

    +
    +

    Warning

    + this method must not change the database. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseDidChange(with event: DatabaseEvent)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseWillCommit() + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    When a transaction is about to be committed, the transaction observer +has an opportunity to rollback pending changes by throwing an error.

    + +

    This method is called on the database queue.

    +
    +

    Warning

    +

    this method must not change the database.

    + +
    +

    Throws

    +

    An eventual error that rollbacks pending changes.

    + +
    + +
    +

    Default Implementation

    +
    +

    Default implementation does nothing

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseWillCommit() throws
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseDidCommit(_:) + +
    +
    +
    +
    +
    +
    +

    Database changes have been committed.

    + +

    This method is called on the database queue. It can change the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseDidCommit(_ db: Database)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Database changes have been rollbacked.

    + +

    This method is called on the database queue. It can change the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func databaseDidRollback(_ db: Database)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseWillChange(with:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Notifies before a database change (insert, update, or delete) +with change information (initial / final values for the row’s +columns). (Called before databaseDidChangeWithEvent.)

    + +

    The change is pending until the end of the current transaction, +and you always get a second chance to get basic event information in +the databaseDidChangeWithEvent callback.

    + +

    This callback is mostly useful for calculating detailed change +information for a row, and provides the initial / final values.

    + +

    This method is called in a protected dispatch queue, serialized will all +database updates.

    + +

    The event is only valid for the duration of this method call. If you +need to keep it longer, store a copy: event.copy()

    +
    +

    Warning

    + this method must not change the database. + +
    + +

    Availability Info

    + +

    Requires SQLite 3.13.0 + +Compiled with option SQLITE_ENABLE_PREUPDATE_HOOK

    + +

    As of OSX 10.11.5, and iOS 9.3.2, the built-in SQLite library +does not have this enabled, so you’ll need to compile your own +version of SQLite: +See https://github.com/groue/GRDB.swift/blob/master/Documentation/CustomSQLiteBuilds.md

    + +

    The databaseDidChangeWithEvent callback is always available, +and may provide most/all of what you need.

    + +
    +

    Default Implementation

    +
    +

    Default implementation does nothing

    + +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

TransactionObserver +

+
+
+
    +
  • +
    + + + + stopObservingDatabaseChangesUntilNextTransaction() + + + Extension method + +
    +
    +
    +
    +
    +
    +

    After this method has been called, the databaseDidChange(with:) +method won’t be called until the next transaction.

    + +

    For example:

    +
    class PlayerObserver: TransactionObserver {
    +    var playerTableWasModified = false
    +
    +    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
    +        return eventKind.tableName == "player"
    +    }
    +
    +    func databaseDidChange(with event: DatabaseEvent) {
    +        playerTableWasModified = true
    +
    +        // It is pointless to keep on tracking further changes:
    +        stopObservingDatabaseChangesUntilNextTransaction()
    +    }
    +}
    +
    +
    +

    Precondition

    + This method must be called from databaseDidChange(with:). + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func stopObservingDatabaseChangesUntilNextTransaction()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TypedRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TypedRequest.html new file mode 100644 index 000000000..b38e93a7d --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/TypedRequest.html @@ -0,0 +1,1151 @@ + + + + TypedRequest Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

TypedRequest

+
+
+ +
public protocol TypedRequest
+ +
+
+

The protocol for all requests that know how database rows should +be interpreted.

+ + +
+
+
+
    +
  • +
    + + + + RowDecoder + +
    +
    +
    +
    +
    +
    +

    The type that can decode database rows.

    + +

    In the request below, it is Player:

    +
    let request = Player.all()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype RowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/VirtualTableModule.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/VirtualTableModule.html new file mode 100644 index 000000000..2a96a302b --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Protocols/VirtualTableModule.html @@ -0,0 +1,1334 @@ + + + + VirtualTableModule Protocol Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

VirtualTableModule

+
+
+ +
public protocol VirtualTableModule
+ +
+
+

The protocol for SQLite virtual table modules. It lets you define a DSL for +the Database.create(virtualTable:using:) method:

+
let module = ...
+try db.create(virtualTable: "item", using: module) { t in
+    ...
+}
+
+ +

GRDB ships with three concrete classes that implement this protocol: FTS3, +FTS4 and FTS5.

+ + +
+
+
+
    +
  • +
    + + + + TableDefinition + +
    +
    +
    +
    +
    +
    +

    The type of the closure argument in the +Database.create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "item", using: module) { t in
    +    // t is TableDefinition
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    associatedtype TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + moduleName + +
    +
    +
    +
    +
    +
    +

    The name of the module.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    var moduleName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + makeTableDefinition() + +
    +
    +
    +
    +
    +
    +

    Returns a table definition that is passed as the closure argument in the +Database.create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "item", using: module) { t in
    +    // t is the result of makeTableDefinition()
    +}
    +
    +
    +

    Warning

    + This method is DEPRECATED. Define +makeTableDefinition(configuration:) instead. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func makeTableDefinition() -> TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + makeTableDefinition(configuration:) + + + Default implementation + +
    +
    +
    +
    +
    +
    +

    Returns a table definition that is passed as the closure argument in the +Database.create(virtualTable:using:) method:

    +
    try db.create(virtualTable: "item", using: module) { t in
    +    // t is the result of makeTableDefinition(configuration:)
    +}
    +
    + +
    +

    Default Implementation

    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func makeTableDefinition(configuration: VirtualTableConfiguration) -> TableDefinition
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the module arguments for the CREATE VIRTUAL TABLE query.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func moduleArguments(for definition: TableDefinition, in db: Database) throws -> [String]
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Execute any relevant database statement after the virtual table has +been created.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    func database(_ db: Database, didCreate tableName: String, using definition: TableDefinition) throws
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs.html new file mode 100644 index 000000000..23c25f852 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs.html @@ -0,0 +1,3822 @@ + + + + Structures Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Structures

+

The following structures are available globally.

+ +
+
+
+
    +
  • +
    + + + + Configuration + +
    +
    +
    +
    +
    +
    +

    Configuration for a DatabaseQueue or DatabasePool.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct Configuration
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnInfo + +
    +
    +
    +
    +
    +
    +

    A column of a database table.

    + +

    This type closely matches the information returned by the +table_info and table_xinfo pragmas.

    +
    sqlite> CREATE TABLE player (
    +   ...>   id INTEGER PRIMARY KEY,
    +   ...>   firstName TEXT,
    +   ...>   lastName TEXT);
    +sqlite> PRAGMA table_info(player);
    +cid     name        type        notnull     dflt_value  pk
    +------  ----------  ----------  ----------  ----------  -----
    +0       id          INTEGER     0                       1
    +1       firstName   TEXT        0                       0
    +2       lastName    TEXT        0                       0
    +sqlite> PRAGMA table_xinfo(player);
    +cid     name        type        notnull     dflt_value  pk     hidden
    +------  ----------  ----------  ----------  ----------  -----  ----------
    +0       id          INTEGER     0                       1      0
    +1       firstName   TEXT        0                       0      0
    +2       lastName    TEXT        0                       0      0
    +
    + +

    See Database.columns(in:) and https://www.sqlite.org/pragma.html#pragma_table_info

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ColumnInfo : FetchableRecord
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + IndexInfo + +
    +
    +
    +
    +
    +
    +

    An index on a database table.

    + +

    See Database.indexes(on:)

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct IndexInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ForeignKeyViolation + +
    +
    +
    +
    +
    +
    +

    A foreign key violation produced by PRAGMA foreign_key_check

    + +

    See https://www.sqlite.org/pragma.html#pragma_foreign_key_check

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ForeignKeyViolation : FetchableRecord, CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + PrimaryKeyInfo + +
    +
    +
    +
    +
    +
    +

    Primary keys are returned from the Database.primaryKey(_:) method.

    + +

    When the table’s primary key is the rowid:

    +
    // CREATE TABLE item (name TEXT)
    +let pk = try db.primaryKey("item")
    +pk.columns     // ["rowid"]
    +pk.rowIDColumn // nil
    +pk.isRowID     // true
    +
    +// CREATE TABLE citizen (
    +//   id INTEGER PRIMARY KEY,
    +//   name TEXT
    +// )
    +let pk = try db.primaryKey("citizen")!
    +pk.columns     // ["id"]
    +pk.rowIDColumn // "id"
    +pk.isRowID     // true
    +
    + +

    When the table’s primary key is not the rowid:

    +
    // CREATE TABLE country (
    +//   isoCode TEXT NOT NULL PRIMARY KEY
    +//   name TEXT
    +// )
    +let pk = db.primaryKey("country")!
    +pk.columns     // ["isoCode"]
    +pk.rowIDColumn // nil
    +pk.isRowID     // false
    +
    +// CREATE TABLE citizenship (
    +//   citizenID INTEGER NOT NULL REFERENCES citizen(id)
    +//   countryIsoCode TEXT NOT NULL REFERENCES country(isoCode)
    +//   PRIMARY KEY (citizenID, countryIsoCode)
    +// )
    +let pk = db.primaryKey("citizenship")!
    +pk.columns     // ["citizenID", "countryIsoCode"]
    +pk.rowIDColumn // nil
    +pk.isRowID     // false
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PrimaryKeyInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ForeignKeyInfo + +
    +
    +
    +
    +
    +
    +

    You get foreign keys from table names, with the +foreignKeys(on:) method.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ForeignKeyInfo
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ResultCode + +
    +
    +
    +
    +
    +
    +

    An SQLite result code.

    + +

    See https://www.sqlite.org/rescode.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseError + +
    +
    +
    +
    +
    +
    +

    DatabaseError wraps an SQLite error.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseError : Error, CustomStringConvertible, CustomNSError
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + DatabaseRegion + +
    +
    +
    +
    +
    +
    +

    DatabaseRegion defines a region in the database. DatabaseRegion is dedicated +to help transaction observers recognize impactful database changes in their +observes(eventsOfKind:) and databaseDidChange(with:) methods.

    + +

    A database region is the union of any number of “table regions”, which can +cover a full table, or the combination of columns and rows:

    +
    |Table1 |   |Table2 |   |Table3 |   |Table4 |   |Table5 |
    +|-------|   |-------|   |-------|   |-------|   |-------|
    +|x|x|x|x|   |x| | | |   |x|x|x|x|   |x|x| |x|   | | | | |
    +|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | |x| | |
    +|x|x|x|x|   |x| | | |   | | | | |   |x|x| |x|   | | | | |
    +|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | | | | |
    +
    + +

    To create a database region, you use one of those methods:

    + +
      +
    • DatabaseRegion.fullDatabase: the region that covers all database tables.

    • +
    • DatabaseRegion(): the empty region.

    • +
    • DatabaseRegion(table:): the region that covers one database table.

    • +
    • Statement.databaseRegion:

      +
      let statement = try db.makeStatement(sql: "SELECT name, score FROM player")
      +let region = statement.databaseRegion
      +
    • +
    • FetchRequest.databaseRegion(_:)

      +
      let request = Player.filter(key: 1)
      +let region = try request.databaseRegion(db)
      +
    • +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseRegion : CustomStringConvertible, Equatable
    +
    extension DatabaseRegion: DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseRegionConvertible +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    A type-erased DatabaseRegionConvertible

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AnyDatabaseRegionConvertible : DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    DatabaseRegionObservation tracks changes in the results of database +requests, and notifies each database transaction whenever the +database changes.

    + +

    For example:

    +
    let observation = DatabaseRegionObservation(tracking: Player.all)
    +let observer = try observation.start(in: dbQueue) { db: Database in
    +    print("Players have changed.")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseRegionObservation
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseValue +

+
+
+ +
+
+
+ + +
+ +

PreparedRequest +

+
+
+
    +
  • +
    + + + + PreparedRequest + +
    +
    +
    +
    +
    +
    +

    A PreparedRequest is a request that is ready to be executed.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PreparedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AdaptedFetchRequest +

+
+
+ +
+
+
+ + +
+ +

AnyFetchRequest +

+
+
+
    +
  • +
    + + + + AnyFetchRequest + +
    +
    +
    +
    +
    +
    +

    A type-erased FetchRequest.

    + +

    An AnyFetchRequest forwards its operations to an underlying request, +hiding its specifics.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AnyFetchRequest<RowDecoder> : FetchRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

RowIndex +

+
+
+
    +
  • +
    + + + + RowIndex + +
    +
    +
    +
    +
    +
    +

    Indexes to (ColumnName, DatabaseValue) pairs in a database row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct RowIndex : Comparable, Strideable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + EmptyRowAdapter + +
    +
    +
    +
    +
    +
    +

    EmptyRowAdapter is a row adapter that hides all columns.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct EmptyRowAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ColumnMapping + +
    +
    +
    +
    +
    +
    +

    ColumnMapping is a row adapter that maps column names.

    +
    let adapter = ColumnMapping(["foo": "bar"])
    +let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
    +
    +// [foo:"bar"]
    +try Row.fetchOne(db, sql: sql, adapter: adapter)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ColumnMapping : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SuffixRowAdapter + +
    +
    +
    +
    +
    +
    +

    SuffixRowAdapter is a row adapter that hides the first columns in a row.

    +
    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)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SuffixRowAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + RangeRowAdapter + +
    +
    +
    +
    +
    +
    +

    RangeRowAdapter is a row adapter that only exposes a range of columns.

    +
    let adapter = RangeRowAdapter(1..<3)
    +let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz, 4 as qux"
    +
    +// [bar:2 baz:3]
    +try Row.fetchOne(db, sql: sql, adapter: adapter)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct RangeRowAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ScopeAdapter + +
    +
    +
    +
    +
    +
    +

    ScopeAdapter is a row adapter that lets you define scopes on rows.

    +
    // Two adapters
    +let fooAdapter = ColumnMapping(["value": "foo"])
    +let barAdapter = ColumnMapping(["value": "bar"])
    +
    +// Define scopes
    +let adapter = ScopeAdapter([
    +    "foo": fooAdapter,
    +    "bar": barAdapter])
    +
    +// Fetch
    +let sql = "SELECT 'foo' AS foo, 'bar' AS bar"
    +let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
    +
    +// Scoped rows:
    +if let fooRow = row.scopes["foo"] {
    +    fooRow["value"]    // "foo"
    +}
    +if let barRow = row.scopes["bar"] {
    +    barRow["value"]    // "bar"
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ScopeAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + RenameColumnAdapter + +
    +
    +
    +
    +
    +
    +

    RenameColumnAdapter is a row adapter that renames columns.

    + +

    For example:

    +
    let adapter = RenameColumnAdapter { $0 + "rrr" }
    +let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
    +
    +// [foorrr:"foo", barrrr:"bar", bazrrr:"baz"]
    +try Row.fetchOne(db, sql: sql, adapter: adapter)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct RenameColumnAdapter : RowAdapter
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQL + +
    +
    +
    +
    +
    +
    +

    SQL helps you build SQL literal with +SQL Interpolation.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    let name: String = ...
    +    let id: Int64 = ...
    +    let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
    +    try db.execute(literal: query)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQL
    +
    extension SQL: SQLSpecificExpressible
    +
    extension SQL: SQLSelectable
    +
    extension SQL: SQLOrderingTerm
    +
    extension SQL: ExpressibleByStringInterpolation
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLRequest + +
    +
    +
    +
    +
    +
    +

    A FetchRequest built from raw SQL.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQLRequest<RowDecoder>
    +
    extension SQLRequest: FetchRequest
    +
    extension SQLRequest: ExpressibleByStringInterpolation
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementArguments +

+
+
+
    +
  • +
    + + + + StatementArguments + +
    +
    +
    +
    +
    +
    +

    StatementArguments provide values to argument placeholders in raw +SQL queries.

    + +

    Placeholders can take several forms (see https://www.sqlite.org/lang_expr.html#varparam +for more information):

    + +
      +
    • ?NNN (e.g. ?2): the NNN-th argument (starts at 1)
    • +
    • ?: the N-th argument, where N is one greater than the largest argument +number already assigned
    • +
    • :AAAA (e.g. :name): named argument

    • +
    • $AAAA (e.g. $name): named argument

    • +
    +

    Positional Arguments

    + +

    To fill question marks placeholders, feed StatementArguments with an array:

    +
    db.execute(
    +    sql: "INSERT ... (?, ?)",
    +    arguments: StatementArguments(["Arthur", 41]))
    +
    +// Array literals are automatically converted:
    +db.execute(
    +    sql: "INSERT ... (?, ?)",
    +    arguments: ["Arthur", 41])
    +
    +

    Named Arguments

    + +

    To fill named arguments, feed StatementArguments with a dictionary:

    +
    db.execute(
    +    sql: "INSERT ... (:name, :score)",
    +    arguments: StatementArguments(["name": "Arthur", "score": 41]))
    +
    +// Dictionary literals are automatically converted:
    +db.execute(
    +    sql: "INSERT ... (:name, :score)",
    +    arguments: ["name": "Arthur", "score": 41])
    +
    +

    Concatenating Arguments

    + +

    Several arguments can be concatenated and mixed with the +append(contentsOf:) method and the +, &+, += operators:

    +
    var arguments: StatementArguments = ["Arthur"]
    +arguments += [41]
    +db.execute(sql: "INSERT ... (?, ?)", arguments: arguments)
    +
    + +

    + and += operators consider that overriding named arguments is a +programmer error:

    +
    var arguments: StatementArguments = ["name": "Arthur"]
    +arguments += ["name": "Barbara"]
    +// fatal error: already defined statement argument: name
    +
    + +

    &+ and append(contentsOf:) allow overriding named arguments:

    +
    var arguments: StatementArguments = ["name": "Arthur"]
    +arguments = arguments &+ ["name": "Barbara"]
    +print(arguments)
    +// Prints ["name": "Barbara"]
    +
    +

    Mixed Arguments

    + +

    It is possible to mix named and positional arguments. Yet this is usually +confusing, and it is best to avoid this practice:

    +
    let sql = "SELECT ?2 AS two, :foo AS foo, ?1 AS one, :foo AS foo2, :bar AS bar"
    +var arguments: StatementArguments = [1, 2, "bar"] + ["foo": "foo"]
    +let row = try Row.fetchOne(db, sql: sql, arguments: arguments)!
    +print(row)
    +// Prints [two:2 foo:"foo" one:1 foo2:"foo" bar:"bar"]
    +
    + +

    Mixed arguments exist as a support for requests like the following:

    +
    let players = try Player
    +    .filter(sql: "team = :team", arguments: ["team": "Blue"])
    +    .filter(sql: "score > ?", arguments: [1000])
    +    .fetchAll(db)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct StatementArguments: CustomStringConvertible, Equatable,
    +                                  ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    DatabaseDateComponents reads and stores DateComponents in the database.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseDateComponents : DatabaseValueConvertible, StatementColumnConvertible, Codable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database events +

+
+
+
    +
  • +
    + + + + DatabaseEvent + +
    +
    +
    +
    +
    +
    +

    A database event, notified to TransactionObserver.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseEvent
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS3 + +
    +
    +
    +
    +
    +
    +

    FTS3 lets you define “fts3” virtual tables.

    +
    // CREATE VIRTUAL TABLE document USING fts3(content)
    +try db.create(virtualTable: "document", using: FTS3()) { t in
    +    t.column("content")
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS3 : VirtualTableModule
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS3Pattern + +
    +
    +
    +
    +
    +
    +

    A full text pattern that can query FTS3 and FTS4 virtual tables.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS3Pattern
    +
    extension FTS3Pattern: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    An FTS3 tokenizer, suitable for FTS3 and FTS4 table definitions:

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .simple // FTS3TokenizerDescriptor
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS3TokenizerDescriptor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS4 + +
    +
    +
    +
    +
    +
    +

    FTS4 lets you define “fts4” virtual tables.

    +
    // CREATE VIRTUAL TABLE document USING fts4(content)
    +try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct FTS4 : VirtualTableModule
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5 + +
    +
    +
    +
    +
    +
    +

    FTS5 lets you define “fts5” virtual tables.

    +
    // CREATE VIRTUAL TABLE document USING fts5(content)
    +try db.create(virtualTable: "document", using: FTS5()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5Pattern + +
    +
    +
    +
    +
    +
    +

    A full text pattern that can query FTS5 virtual tables.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    + +
    +
    +
    +
    +
  • +
  • +
    + + + + FTS5Tokenization + +
    +
    +
    +
    +
    +
    +

    The reason why FTS5 is requesting tokenization.

    + +

    See https://www.sqlite.org/fts5.html#custom_tokenizers

    + + See more +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    An FTS5 tokenizer, suitable for FTS5 table definitions:

    +
    db.create(virtualTable: "book", using: FTS5()) { t in
    +    t.tokenizer = .unicode61() // FTS5TokenizerDescriptor
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html#tokenizers

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + FTS5TokenFlags + +
    +
    +
    +
    +
    +
    +

    Flags that tell SQLite how to register a token.

    + +

    See the FTS5_TOKEN_* flags in https://www.sqlite.org/fts5.html#custom_tokenizers.

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + DatabaseMigrator + +
    +
    +
    +
    +
    +
    +

    A DatabaseMigrator registers and applies database migrations.

    + +

    Migrations are named blocks of SQL statements that are guaranteed to be +applied in order, once and only once.

    + +

    When a user upgrades your application, only non-applied migration are run.

    + +

    Usage:

    +
    var migrator = DatabaseMigrator()
    +
    +// 1st migration
    +migrator.registerMigration("createLibrary") { db in
    +    try db.create(table: "author") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("creationDate", .datetime)
    +        t.column("name", .text).notNull()
    +    }
    +
    +    try db.create(table: "book") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("authorId", .integer)
    +            .notNull()
    +            .references("author", onDelete: .cascade)
    +        t.column("title", .text).notNull()
    +    }
    +}
    +
    +// 2nd migration
    +migrator.registerMigration("AddBirthYearToAuthors") { db in
    +    try db.alter(table: "author") { t
    +        t.add(column: "birthYear", .integer)
    +    }
    +}
    +
    +// Migrations for future versions will be inserted here:
    +//
    +// // 3rd migration
    +// migrator.registerMigration("...") { db in
    +//     ...
    +// }
    +
    +try migrator.migrate(dbQueue)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct DatabaseMigrator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ForeignKey + +
    +
    +
    +
    +
    +
    +

    A ForeignKey helps building associations when GRDB can’t infer a foreign +key from the database schema.

    + +

    Sometimes the database schema does not define any foreign key between two +tables. And sometimes, there are several foreign keys from a table +to another:

    +
    | Table book   |       | Table person |
    +| ------------ |       | ------------ |
    +| id           |   +-->• id           |
    +| authorId     •---+   | name         |
    +| translatorId •---+
    +| title        |
    +
    + +

    When this happens, associations can’t be automatically inferred from the +database schema. GRDB will complain with a fatal error such as “Ambiguous +foreign key from book to person”, or “Could not infer foreign key from book +to person”.

    + +

    Your help is needed. You have to instruct GRDB which foreign key to use:

    +
    struct Book: TableRecord {
    +    // Define foreign keys
    +    static let authorForeignKey = ForeignKey(["authorId"]))
    +    static let translatorForeignKey = ForeignKey(["translatorId"]))
    +
    +    // Use foreign keys to define associations:
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +    static let translator = belongsTo(Person.self, using: translatorForeignKey)
    +}
    +
    + +

    Foreign keys are always defined from the table that contains the columns at +the origin of the foreign key. Person’s symmetric HasMany associations reuse +Book’s foreign keys:

    +
    struct Person: TableRecord {
    +    static let writtenBooks = hasMany(Book.self, using: Book.authorForeignKey)
    +    static let translatedBooks = hasMany(Book.self, using: Book.translatorForeignKey)
    +}
    +
    + +

    Foreign keys can also be defined from query interface columns:

    +
    struct Book: TableRecord {
    +    enum Columns: String, ColumnExpression {
    +        case id, title, authorId, translatorId
    +    }
    +
    +    static let authorForeignKey = ForeignKey([Columns.authorId]))
    +    static let translatorForeignKey = ForeignKey([Columns.translatorId]))
    +}
    +
    + +

    When the destination table of a foreign key does not define any primary key, +you need to provide the full definition of a foreign key:

    +
    struct Book: TableRecord {
    +    static let authorForeignKey = ForeignKey(["authorId"], to: ["id"]))
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ForeignKey : Equatable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + AssociationAggregate + +
    +
    +
    +
    +
    +
    +

    An AssociationAggregate is able to compute aggregated values from a +population of associated records.

    + +

    For example:

    +
    struct Author: TableRecord {
    +    static let books = hasMany(Book.self)
    +}
    +
    +let bookCount = Author.books.count // AssociationAggregate<Author>
    +
    + +

    Association aggregates can be used in the annotated(with:) and +having(_:) request methods:

    +
    let request = Author.annotated(with: bookCount)
    +let request = Author.having(bookCount >= 10)
    +
    + +

    The RowDecoder generic type helps the compiler prevent incorrect use +of aggregates:

    +
    // Won't compile because Fruit is not Author.
    +let request = Fruit.annotated(with: bookCount)
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + BelongsToAssociation + +
    +
    +
    +
    +
    +
    +

    The BelongsTo association sets up a one-to-one connection from a record +type to another record type, such as each instance of the declaring record +“belongs to” an instance of the other record.

    + +

    For example, if your application includes authors and books, and each book +is assigned its author, you’d declare the association this way:

    +
    struct Author: TableRecord { ... }
    +struct Book: TableRecord {
    +    static let author = belongsTo(Author.self)
    +    ...
    +}
    +
    + +

    A BelongsTo associations should be supported by an SQLite foreign key.

    + +

    Foreign keys are the recommended way to declare relationships between +database tables because not only will SQLite guarantee the integrity of your +data, but GRDB will be able to use those foreign keys to automatically +configure your association.

    + +

    You define the foreign key when you create database tables. For example:

    +
    try db.create(table: "author") { t in
    +    t.autoIncrementedPrimaryKey("id")             // (1)
    +    t.column("name", .text)
    +}
    +try db.create(table: "book") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("authorId", .integer)                // (2)
    +        .notNull()                                // (3)
    +        .indexed()                                // (4)
    +        .references("author", onDelete: .cascade) // (5)
    +    t.column("title", .text)
    +}
    +
    + +
      +
    1. The author table has a primary key.
    2. +
    3. The book.authorId column is used to link a book to the author it +belongs to.
    4. +
    5. Make the book.authorId column not null if you want SQLite to guarantee +that all books have an author.
    6. +
    7. Create an index on the book.authorId column in order to ease the +selection of an author’s books.
    8. +
    9. Create a foreign key from book.authorId column to authors.id, so that +SQLite guarantees that no book refers to a missing author. The +onDelete: .cascade option has SQLite automatically delete all of an +author’s books when that author is deleted. +See https://sqlite.org/foreignkeys.html#fk_actions for more information.
    10. +
    + +

    The example above uses auto-incremented primary keys. But generally +speaking, all primary keys are supported.

    + +

    If the database schema does not define foreign keys between tables, you can +still use BelongsTo associations. But your help is needed to define the +missing foreign key:

    +
    struct Book: FetchableRecord, TableRecord {
    +    static let author = belongsTo(Author.self, using: ForeignKey(...))
    +}
    +
    + +

    See ForeignKey for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct BelongsToAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HasManyAssociation + +
    +
    +
    +
    +
    +
    +

    The HasMany association indicates a one-to-many connection between two +record types, such as each instance of the declaring record “has many” +instances of the other record.

    + +

    For example, if your application includes authors and books, and each author +is assigned zero or more books, you’d declare the association this way:

    +
    struct Book: TableRecord { ... }
    +struct Author: TableRecord {
    +    static let books = hasMany(Book.self)
    +    ...
    +}
    +
    + +

    HasMany associations should be supported by an SQLite foreign key.

    + +

    Foreign keys are the recommended way to declare relationships between +database tables because not only will SQLite guarantee the integrity of your +data, but GRDB will be able to use those foreign keys to automatically +configure your association.

    + +

    You define the foreign key when you create database tables. For example:

    +
    try db.create(table: "author") { t in
    +    t.autoIncrementedPrimaryKey("id")             // (1)
    +    t.column("name", .text)
    +}
    +try db.create(table: "book") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("authorId", .integer)                // (2)
    +        .notNull()                                // (3)
    +        .indexed()                                // (4)
    +        .references("author", onDelete: .cascade) // (5)
    +    t.column("title", .text)
    +}
    +
    + +
      +
    1. The author table has a primary key.
    2. +
    3. The book.authorId column is used to link a book to the author it +belongs to.
    4. +
    5. Make the book.authorId column not null if you want SQLite to guarantee +that all books have an author.
    6. +
    7. Create an index on the book.authorId column in order to ease the +selection of an author’s books.
    8. +
    9. Create a foreign key from book.authorId column to authors.id, so that +SQLite guarantees that no book refers to a missing author. The +onDelete: .cascade option has SQLite automatically delete all of an +author’s books when that author is deleted. +See https://sqlite.org/foreignkeys.html#fk_actions for more information.
    10. +
    + +

    The example above uses auto-incremented primary keys. But generally +speaking, all primary keys are supported.

    + +

    If the database schema does not define foreign keys between tables, you can +still use HasMany associations. But your help is needed to define the +missing foreign key:

    +
    struct Author: TableRecord {
    +    static let books = hasMany(Book.self, using: ForeignKey(...))
    +}
    +
    + +

    See ForeignKey for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasManyAssociation<Origin, Destination> : AssociationToMany
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The HasManyThrough association is often used to set up a many-to-many +connection with another record. This association indicates that the +declaring record can be matched with zero or more instances of another +record by proceeding through a third record.

    + +

    For example, consider the practice of passport delivery. One coutry +“has many” citizens “through” its passports:

    +
    struct Country: TableRecord {
    +    static let passports = hasMany(Passport.self)
    +    static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen)
    +    ...
    +}
    +
    +struct Passport: TableRecord {
    +    static let citizen = belongsTo(Citizen.self)
    +    ...
    +}
    +
    +struct Citizen: TableRecord { ... }
    +
    + +

    The HasManyThrough association is also useful for setting up +“shortcuts” through nested HasMany associations. For example, if a document +has many sections, and a section has many paragraphs, you may sometimes want +to get a simple collection of all paragraphs in the document. You could set +that up this way:

    +
    struct Document: TableRecord {
    +    static let sections = hasMany(Section.self)
    +    static let paragraphs = hasMany(Paragraph.self, through: sections, using: Section.paragraphs)
    +}
    +
    +struct Section: TableRecord {
    +    static let paragraphs = hasMany(Paragraph.self)
    +}
    +
    +struct Paragraph: TableRecord {
    +}
    +
    + +

    As in the examples above, HasManyThrough association is always built from +two other associations: the through: and using: arguments. Those +associations can be any other association (BelongsTo, HasMany, +HasManyThrough, etc).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasManyThroughAssociation<Origin, Destination> : AssociationToMany
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HasOneAssociation + +
    +
    +
    +
    +
    +
    +

    The HasOne association indicates a one-to-one connection between two +record types, such as each instance of the declaring record “has one” +instances of the other record.

    + +

    For example, if your application has one database table for countries, and +another for their demographic profiles, you’d declare the association +this way:

    +
    struct Demographics: TableRecord { ... }
    +struct Country: TableRecord {
    +    static let demographics = hasOne(Demographics.self)
    +    ...
    +}
    +
    + +

    HasOne associations should be supported by an SQLite foreign key.

    + +

    Foreign keys are the recommended way to declare relationships between +database tables because not only will SQLite guarantee the integrity of your +data, but GRDB will be able to use those foreign keys to automatically +configure your association.

    + +

    You define the foreign key when you create database tables. For example:

    +
    try db.create(table: "country") { t in
    +    t.column("code", .text).primaryKey()           // (1)
    +    t.column("name", .text)
    +}
    +try db.create(table: "demographics") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("countryCode", .text)                 // (2)
    +        .notNull()                                 // (3)
    +        .unique()                                  // (4)
    +        .references("country", onDelete: .cascade) // (5)
    +    t.column("population", .integer)
    +    t.column("density", .double)
    +}
    +
    + +
      +
    1. The country table has a primary key.
    2. +
    3. The demographics.countryCode column is used to link a demographic +profile to the country it belongs to.
    4. +
    5. Make the demographics.countryCode column not null if you want SQLite to +guarantee that all profiles are linked to a country.
    6. +
    7. Create a unique index on the demographics.countryCode column in order to +guarantee the unicity of any country’s profile.
    8. +
    9. Create a foreign key from demographics.countryCode column to +country.code, so that SQLite guarantees that no profile refers to a +missing country. The onDelete: .cascade option has SQLite automatically +delete a profile when its country is deleted. +See https://sqlite.org/foreignkeys.html#fk_actions for more information.
    10. +
    + +

    The example above uses a string primary for the country table. But generally +speaking, all primary keys are supported.

    + +

    If the database schema does not follow this convention, and does not define +foreign keys between tables, you can still use HasOne associations. But +your help is needed to define the missing foreign key:

    +
    struct Country: FetchableRecord, TableRecord {
    +    static let demographics = hasOne(Demographics.self, using: ForeignKey(...))
    +}
    +
    + +

    See ForeignKey for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasOneAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A HasOneThrough association sets up a one-to-one connection with +another record. This association indicates that the declaring record can be +matched with one instance of another record by proceeding through a third +record. For example, if each book belongs to a library, and each library has +one address, then one knows where the book should be returned to:

    +
    struct Book: TableRecord {
    +    static let library = belongsTo(Library.self)
    +    static let returnAddress = hasOne(Address.self, through: library, using: Library.address)
    +    ...
    +}
    +
    +struct Library: TableRecord {
    +    static let address = hasOne(Address.self)
    +    ...
    +}
    +
    +struct Address: TableRecord { ... }
    +
    + +

    As in the example above, HasOneThrough association is always built from +two other associations: the through: and using: arguments. Those +associations can be any other association to one (BelongsTo, HasOne, +HasOneThrough).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct HasOneThroughAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + JoinAssociation + +
    +
    +
    +
    +
    +
    +

    The Join association is used to join common table expression to regular +tables or other common table expressions.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct JoinAssociation<Origin, Destination> : AssociationToOne
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + CommonTableExpression + +
    +
    +
    +
    +
    +
    +

    A common table expression that can be +used with the GRDB query interface.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct CommonTableExpression<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + QueryInterfaceRequest + +
    +
    +
    +
    +
    +
    +

    QueryInterfaceRequest is a request that generates SQL for you.

    + +

    For example:

    +
    try dbQueue.read { db in
    +    let request = Player
    +        .filter(Column("score") > 1000)
    +        .order(Column("name"))
    +    let players = try request.fetchAll(db) // [Player]
    +}
    +
    + +

    See https://github.com/groue/GRDB.swift#the-query-interface

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct QueryInterfaceRequest<RowDecoder>
    +
    extension QueryInterfaceRequest: FetchRequest
    +
    extension QueryInterfaceRequest: SelectionRequest
    +
    extension QueryInterfaceRequest: FilteredRequest
    +
    extension QueryInterfaceRequest: OrderedRequest
    +
    extension QueryInterfaceRequest: AggregatingRequest
    +
    extension QueryInterfaceRequest: JoinableRequest
    +
    extension QueryInterfaceRequest: TableRequest
    +
    extension QueryInterfaceRequest: DerivableRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ColumnAssignment +

+
+
+ +
+
+
+ + +
+ +

PersistenceContainer +

+
+
+
    +
  • +
    + + + + PersistenceContainer + +
    +
    +
    +
    +
    +
    +

    Use persistence containers in the encode(to:) method of your +encodable records:

    +
    struct Player: EncodableRecord {
    +    var id: Int64?
    +    var name: String?
    +
    +    func encode(to container: inout PersistenceContainer) {
    +        container["id"] = id
    +        container["name"] = name
    +    }
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PersistenceContainer
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLSelection + +
    +
    +
    +
    +
    +
    +

    The type that can be selected, as described at +https://www.sqlite.org/syntax/result-column.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQLSelection
    +
    extension SQLSelection: SQLSelectable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AllColumns +

+
+
+
    +
  • +
    + + + + AllColumns + +
    +
    +
    +
    +
    +
    +

    AllColumns is the * in SELECT *.

    + +

    You use AllColumns in your custom implementation of +TableRecord.databaseSelection.

    + +

    For example:

    +
    struct Player : TableRecord {
    +    static var databaseTableName = "player"
    +    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
    +}
    +
    +// SELECT *, rowid FROM player
    +let request = Player.all()
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AllColumns : SQLSelectable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLSubquery + +
    +
    +
    +
    +
    +
    +

    The type that can be embedded as a subquery.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct SQLSubquery
    +
    extension SQLSubquery: SQLSubqueryable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Table + +
    +
    +
    +
    +
    +
    +

    Table can build query interface requests.

    +
    // SELECT * FROM player WHERE score >= 1000
    +let table = Table("player")
    +let rows: [Row] = try dbQueue.read { db in
    +    table.all()
    +        .filter(Column("score") >= 1000)
    +        .fetchAll(db)
    +}
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct Table<RowDecoder>
    +
    extension Table: DatabaseRegionConvertible
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct VirtualTableConfiguration
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The MutablePersistableRecord protocol uses this type in order to handle +SQLite conflicts when records are inserted or updated.

    + +

    See MutablePersistableRecord.persistenceConflictPolicy.

    + +

    See https://www.sqlite.org/lang_conflict.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct PersistenceConflictPolicy
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Inflections + +
    +
    +
    +
    +
    +
    +

    Experimental

    + +

    A type that controls GRDB string inflections.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct Inflections
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ValueObservation + +
    +
    +
    +
    +
    +
    +

    ValueObservation tracks changes in the results of database requests, and +notifies fresh values whenever the database changes.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed.")
    +    })
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct ValueObservation<Reducer> where Reducer : ValueReducer
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AdaptedFetchRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AdaptedFetchRequest.html new file mode 100644 index 000000000..1b4255eb3 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AdaptedFetchRequest.html @@ -0,0 +1,1236 @@ + + + + AdaptedFetchRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AdaptedFetchRequest

+
+
+ +
public struct AdaptedFetchRequest<Base> : FetchRequest where Base : FetchRequest
+ +
+
+

An adapted request.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AllColumns.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AllColumns.html new file mode 100644 index 000000000..e402eebc6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AllColumns.html @@ -0,0 +1,1193 @@ + + + + AllColumns Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AllColumns

+
+
+ +
public struct AllColumns : SQLSelectable
+ +
+
+

AllColumns is the * in SELECT *.

+ +

You use AllColumns in your custom implementation of +TableRecord.databaseSelection.

+ +

For example:

+
struct Player : TableRecord {
+    static var databaseTableName = "player"
+    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
+}
+
+// SELECT *, rowid FROM player
+let request = Player.all()
+
+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    The * selection.

    + +

    For example:

    +
    // SELECT * FROM player
    +Player.select(AllColumns())
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSelection + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSelection: SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AnyDatabaseRegionConvertible.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AnyDatabaseRegionConvertible.html new file mode 100644 index 000000000..28c2e0874 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AnyDatabaseRegionConvertible.html @@ -0,0 +1,1176 @@ + + + + AnyDatabaseRegionConvertible Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyDatabaseRegionConvertible

+
+
+ +
public struct AnyDatabaseRegionConvertible : DatabaseRegionConvertible
+ +
+
+

A type-erased DatabaseRegionConvertible

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AnyFetchRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AnyFetchRequest.html new file mode 100644 index 000000000..ea8f2997a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AnyFetchRequest.html @@ -0,0 +1,1307 @@ + + + + AnyFetchRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AnyFetchRequest

+
+
+ +
public struct AnyFetchRequest<RowDecoder> : FetchRequest
+ +
+
+

A type-erased FetchRequest.

+ +

An AnyFetchRequest forwards its operations to an underlying request, +hiding its specifics.

+ + +
+
+
+
    +
  • +
    + + + + asRequest(of:) + +
    +
    +
    +
    +
    +
    +

    Creates a request bound to type RowDecoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asRequest<RowDecoder>(of type: RowDecoder.Type) -> AnyFetchRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + type + + +
    +

    The fetched type RowDecoder

    +
    +
    +
    +
    +

    Return Value

    +

    A request bound to type RowDecoder.

    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSubquery + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSubquery: SQLSubquery { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCount(_ db: Database) throws -> Int
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makePreparedRequest(
    +    _ db: Database,
    +    forSingleResult singleResult: Bool = false)
    +throws -> PreparedRequest
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

AnyFetchRequest +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that wraps and forwards operations to request.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Request: FetchRequest>(_ request: Request)
    +where Request.RowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AssociationAggregate.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AssociationAggregate.html new file mode 100644 index 000000000..0b5a86ff3 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/AssociationAggregate.html @@ -0,0 +1,1219 @@ + + + + AssociationAggregate Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociationAggregate

+
+
+ +
public struct AssociationAggregate<RowDecoder>
+ +
+
+

An AssociationAggregate is able to compute aggregated values from a +population of associated records.

+ +

For example:

+
struct Author: TableRecord {
+    static let books = hasMany(Book.self)
+}
+
+let bookCount = Author.books.count // AssociationAggregate<Author>
+
+ +

Association aggregates can be used in the annotated(with:) and +having(_:) request methods:

+
let request = Author.annotated(with: bookCount)
+let request = Author.having(bookCount >= 10)
+
+ +

The RowDecoder generic type helps the compiler prevent incorrect use +of aggregates:

+
// Won't compile because Fruit is not Author.
+let request = Fruit.annotated(with: bookCount)
+
+ + +
+
+
+
    +
  • +
    + + + + forKey(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that is selected in a column with the given name.

    + +

    For example:

    +
    let aggregate = Author.books.count.forKey("numberOfBooks")
    +let request = Author.annotated(with: aggregate)
    +if let row = try Row.fetchOne(db, request) {
    +    let numberOfBooks: Int = row["numberOfBooks"]
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: String) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + forKey(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an aggregate that is selected in a column named like the given +coding key.

    + +

    For example:

    +
    struct AuthorInfo: Decodable, FetchableRecord {
    +    var author: Author
    +    var numberOfBooks: Int
    +
    +    static func fetchAll(_ db: Database) throws -> [AuthorInfo] {
    +        let aggregate = Author.books.count.forKey(CodingKeys.numberOfBooks)
    +        let request = Author.annotated(with: aggregate)
    +        return try AuthorInfo.fetchAll(db, request)
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func forKey(_ key: CodingKey) -> AssociationAggregate<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Column.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Column.html new file mode 100644 index 000000000..a96a76350 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Column.html @@ -0,0 +1,1271 @@ + + + + Column Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Column

+
+
+ +
public struct Column : ColumnExpression, Equatable
+ +
+
+

A column in a database table.

+ +

When you need to introduce your own column type, don’t wrap a Column. +Instead, adopt the ColumnExpression protocol.

+ +

See https://github.com/groue/GRDB.swift#the-query-interface

+ + +
+
+
+
    +
  • +
    + + + + rowID + +
    +
    +
    +
    +
    +
    +

    The hidden rowID column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let rowID: Column
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the column

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a column given its name.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ name: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a column given a CodingKey.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ codingKey: CodingKey)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @_disfavoredOverload
    +public static func == (lhs: Column, rhs: Column) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ColumnInfo.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ColumnInfo.html new file mode 100644 index 000000000..6fd0ecfd3 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ColumnInfo.html @@ -0,0 +1,1323 @@ + + + + ColumnInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnInfo

+
+
+ +
public struct ColumnInfo : FetchableRecord
+ +
+
+

A column of a database table.

+ +

This type closely matches the information returned by the +table_info and table_xinfo pragmas.

+
sqlite> CREATE TABLE player (
+   ...>   id INTEGER PRIMARY KEY,
+   ...>   firstName TEXT,
+   ...>   lastName TEXT);
+sqlite> PRAGMA table_info(player);
+cid     name        type        notnull     dflt_value  pk
+------  ----------  ----------  ----------  ----------  -----
+0       id          INTEGER     0                       1
+1       firstName   TEXT        0                       0
+2       lastName    TEXT        0                       0
+sqlite> PRAGMA table_xinfo(player);
+cid     name        type        notnull     dflt_value  pk     hidden
+------  ----------  ----------  ----------  ----------  -----  ----------
+0       id          INTEGER     0                       1      0
+1       firstName   TEXT        0                       0      0
+2       lastName    TEXT        0                       0      0
+
+ +

See Database.columns(in:) and https://www.sqlite.org/pragma.html#pragma_table_info

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The column name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + type + +
    +
    +
    +
    +
    +
    +

    The column data type

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let type: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isNotNull + +
    +
    +
    +
    +
    +
    +

    True if and only if the column is constrained to be not null.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let isNotNull: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + defaultValueSQL + +
    +
    +
    +
    +
    +
    +

    The SQL snippet that defines the default value, if any.

    + +

    When nil, the column has no default value.

    + +

    When not nil, it contains an SQL string that defines an expression. That +expression may be a literal, as 1, or 'foo'. It may also contain a +non-constant expression such as CURRENT_TIMESTAMP.

    + +

    For example:

    +
    try db.execute(sql: """
    +    CREATE TABLE player(
    +        id INTEGER PRIMARY KEY,
    +        name TEXT DEFAULT 'Anonymous',
    +        score INT DEFAULT 0,
    +        creationDate DATE DEFAULT CURRENT_TIMESTAMP
    +    )
    +    """)
    +let columnInfos = try db.columns(in: "player")
    +columnInfos[0].defaultValueSQL // nil
    +columnInfos[1].defaultValueSQL // "'Anoynymous'"
    +columnInfos[2].defaultValueSQL // "0"
    +columnInfos[3].defaultValueSQL // "CURRENT_TIMESTAMP"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let defaultValueSQL: String?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + primaryKeyIndex + +
    +
    +
    +
    +
    +
    +

    Zero for columns that are not part of the primary key.

    + +

    Before SQLite 3.7.16, it is 1 for columns that are part of the +primary key.

    + +

    Starting from SQLite 3.7.16, it is the one-based index of the column in +the primary key for columns that are part of the primary key.

    + +

    References:

    + + + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let primaryKeyIndex: Int
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ColumnMapping.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ColumnMapping.html new file mode 100644 index 000000000..9aa8567b2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ColumnMapping.html @@ -0,0 +1,1153 @@ + + + + ColumnMapping Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ColumnMapping

+
+
+ +
public struct ColumnMapping : RowAdapter
+ +
+
+

ColumnMapping is a row adapter that maps column names.

+
let adapter = ColumnMapping(["foo": "bar"])
+let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
+
+// [foo:"bar"]
+try Row.fetchOne(db, sql: sql, adapter: adapter)
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a ColumnMapping with a dictionary from mapped column names to +column names in a base row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ mapping: [String : String])
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/CommonTableExpression.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/CommonTableExpression.html new file mode 100644 index 000000000..de2121407 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/CommonTableExpression.html @@ -0,0 +1,2359 @@ + + + + CommonTableExpression Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

CommonTableExpression

+
+
+ +
public struct CommonTableExpression<RowDecoder>
+ +
+
+

A common table expression that can be +used with the GRDB query interface.

+ + +
+
+
+
    +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name of the common table expression.

    + +

    For example:

    +
    // WITH answer AS (SELECT 42) ...
    +let answer = CommonTableExpression(
    +    named: "answer",
    +    sql: "SELECT 42")
    +answer.tableName // "answer"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from a request.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    request: Player.all())
    +
    +// WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    request: SQLRequest<Player>(sql: "SELECT * FROM player"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Request: SQLSubqueryable>(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    request: Request)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + request + + +
    +

    A request.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL string and +optional arguments.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    sql: "SELECT * FROM player WHERE name = ?",
    +    arguments: ["O'Brien"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let name = "O'Brien"
    +let p = CommonTableExpression<Void>(
    +    named: "p",
    +    literal: "SELECT * FROM player WHERE name = \(name)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    literal sqlLiteral: SQL)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + all() + +
    +
    +
    +
    +
    +
    +

    Creates a request for all rows of the common table expression.

    + +

    You can fetch from this request:

    +
    // WITH answer AS (SELECT 42 AS value)
    +// SELECT * FROM answer
    +struct Answer: Decodable, FetchableRecord {
    +    var value: Int
    +}
    +let cte = CommonTableExpression<Answer>(
    +    named: "answer",
    +    sql: "SELECT 42 AS value")
    +let answer = try cte.all().with(cte).fetchOne(db)!
    +print(answer.value) // prints 42
    +
    + +

    You can embed this request as a subquery:

    +
    // WITH answer AS (SELECT 42 AS value)
    +// SELECT * FROM player
    +// WHERE score = (SELECT * FROM answer)
    +let answer = CommonTableExpression(
    +    named: "answer",
    +    sql: "SELECT 42 AS value")
    +let players = try Player
    +    .filter(Column("score") == answer.all())
    +    .with(answer)
    +    .fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func all() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + contains(_:) + +
    +
    +
    +
    +
    +
    +

    An SQL expression that checks the inclusion of an expression in a +common table expression.

    +
    let playerNameCTE = CommonTableExpression(
    +    named: "playerName",
    +    request: Player.select(Column("name"))
    +
    +// name IN playerName
    +playerNameCTE.contains(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func contains(_ element: SQLExpressible) -> SQLExpression
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table record that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Destination.Type,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of +the association.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table record that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Destination.Type)
    +-> JoinAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of +the association.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Table<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a table that you can join +or include in another request.

    + +

    The key of the returned association is the table name of Destination.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to destination: Table<Destination>)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from a request.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression(
    +    named: "p",
    +    request: Player.all())
    +
    +// WITH p AS (SELECT * FROM player) ...
    +let p = CommonTableExpression(
    +    named: "p",
    +    request: SQLRequest<Player>(sql: "SELECT * FROM player"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Request: SQLSubqueryable>(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    request: Request)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + request + + +
    +

    A request.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL string and +optional arguments.

    + +

    For example:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let p = CommonTableExpression(
    +    named: "p",
    +    sql: "SELECT * FROM player WHERE name = ?",
    +    arguments: ["O'Brien"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a common table expression from an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // WITH p AS (SELECT * FROM player WHERE name = 'O''Brien') ...
    +let name = "O'Brien"
    +let p = CommonTableExpression(
    +    named: "p",
    +    literal: "SELECT * FROM player WHERE name = \(name)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    recursive: Bool = false,
    +    named tableName: String,
    +    columns: [String]? = nil,
    +    literal sqlLiteral: SQL)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + recursive + + +
    +

    Whether this common table expression needs a +WITH RECURSIVE sql clause.

    +
    +
    + + tableName + + +
    +

    The table name of the common table expression.

    +
    +
    + + columns + + +
    +

    The columns of the common table expression. If nil, +the columns are the columns of the request.

    +
    +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Configuration.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Configuration.html new file mode 100644 index 000000000..2fb515972 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Configuration.html @@ -0,0 +1,1733 @@ + + + + Configuration Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Configuration

+
+
+ +
public struct Configuration
+ +
+
+

Configuration for a DatabaseQueue or DatabasePool.

+ + +
+
+
+
+ + +
+ +

Misc options +

+
+
+
    +
  • +
    + + + + foreignKeysEnabled + +
    +
    +
    +
    +
    +
    +

    If true, foreign key constraints are checked.

    + +

    Default: true

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var foreignKeysEnabled: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + readonly + +
    +
    +
    +
    +
    +
    +

    If true, database modifications are disallowed.

    + +

    Default: false

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var readonly: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + label + +
    +
    +
    +
    +
    +
    +

    The configuration label.

    + +

    You can query this label at runtime:

    +
    var configuration = Configuration()
    +configuration.label = "MyDatabase"
    +let dbQueue = try DatabaseQueue(path: ..., configuration: configuration)
    +
    +try dbQueue.read { db in
    +    print(db.configuration.label) // Prints "MyDatabase"
    +}
    +
    + +

    The configuration label is also used to name Database connections (the +Database.description property), and the various dispatch queues +created by GRDB, visible in debugging sessions and crash logs.

    + +

    Those connection names and dispatch queue labels are intended for +debugging only. Their format may change between GRDB releases. +Applications should not depend on connection names and dispatch +queue labels.

    + +

    If the configuration label is nil, the current GRDB implementation uses +the following names:

    + +
      +
    • GRDB.DatabaseQueue: the (unique) connection of a DatabaseQueue
    • +
    • GRDB.DatabasePool.writer: the (unique) writer connection of +a DatabasePool
    • +
    • GRDB.DatabasePool.reader.N, where N is 1, 2, …: one of the reader +connection(s) of a DatabasePool. N may get bigger than the maximum +number of concurrent readers, as SQLite connections get closed and new +ones are opened.
    • +
    • GRDB.DatabasePool.snapshot.N: the connection of a DatabaseSnapshot. +N grows with the number of snapshots.
    • +
    + +

    If the configuration label is not nil, for example “MyDatabase”, the +current GRDB implementation uses the following names:

    + +
      +
    • MyDatabase: the (unique) connection of a DatabaseQueue
    • +
    • MyDatabase.writer: the (unique) writer connection of a DatabasePool
    • +
    • MyDatabase.reader.N, where N is 1, 2, …: one of the reader +connection(s) of a DatabasePool. N may get bigger than the maximum +number of concurrent readers, as SQLite connections get closed and new +ones are opened.
    • +
    • MyDatabase.snapshot.N: the connection of a DatabaseSnapshot. N grows +with the number of snapshots.
    • +
    + +

    The default configuration label is nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var label: String?
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    If false, SQLite from version 3.29.0 will not interpret a double-quoted +string as a string literal if it does not match any valid identifier.

    + +

    For example:

    +
    // Error: no such column: foo
    +let name = try String.fetchOne(db, sql: """
    +    SELECT "foo" FROM "player"
    +    """)
    +
    + +

    When true, or before version 3.29.0, such strings are interpreted as +string literals, as in the example below. This is a well known SQLite +misfeature.

    +
    // Success: "foo"
    +let name = try String.fetchOne(db, sql: """
    +    SELECT "foo" FROM "player"
    +    """)
    +
    +
      +
    • Default value: false
    • +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var acceptsDoubleQuotedStringLiterals: Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    When true, the Database.suspendNotification and +Database.resumeNotification suspend and resume the database. Database +suspension helps avoiding the 0xdead10cc +exception.

    + +

    During suspension, all database accesses but reads in WAL mode may throw +a DatabaseError of code SQLITE_INTERRUPT, or SQLITE_ABORT. You can +check for those error codes with the +DatabaseError.isInterruptionError property.

    + +

    Experimental

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var observesSuspensionNotifications: Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Managing SQLite Connections +

+
+
+
    +
  • +
    + + + + prepareDatabase(_:) + +
    +
    +
    +
    +
    +
    +

    The function argument is run when an SQLite connection is opened, +before the connection is made available for database access methods.

    + +

    This method can be called several times. The preparation functions are +run in the same order.

    + +

    For example:

    +
    var config = Configuration()
    +config.prepareDatabase { db in
    +    try db.execute(sql: "PRAGMA kdf_iter = 10000")
    +}
    +
    + +

    When you use a DatabasePool, preparation functions are called for +the writer connection and all reader connections. You can distinguish +them by querying db.configuration.readonly:

    +
    var config = Configuration()
    +config.prepareDatabase { db in
    +    if db.configuration.readonly {
    +        // reader connection
    +    } else {
    +        // writer connection
    +    }
    +}
    +
    + +

    On newly created databases, DatabasePool the WAL mode is activated +after the preparation functions have run.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func prepareDatabase(_ setup: @escaping (Database) throws -> Void)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Transactions +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    The default kind of transaction.

    + +

    Default: deferred

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var defaultTransactionKind: Database.TransactionKind
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    If false, it is a programmer error to leave a transaction opened at the +end of a database access block.

    + +

    For example:

    +
    let dbQueue = DatabaseQueue()
    +
    +// fatal error: A transaction has been left opened at the end of a database access
    +try dbQueue.inDatabase { db in
    +    try db.beginTransaction()
    +}
    +
    + +

    If true, one can leave opened transaction at the end of database access +blocks:

    +
    var config = Configuration()
    +config.allowsUnsafeTransactions = true
    +let dbQueue = DatabaseQueue(configuration: config)
    +
    +try dbQueue.inDatabase { db in
    +    try db.beginTransaction()
    +}
    +
    +try dbQueue.inDatabase { db in
    +    try db.commit()
    +}
    +
    + +

    This configuration flag has no effect on DatabasePool readers: those +never allow leaving a transaction opened at the end of a read access.

    + +

    Default: false

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var allowsUnsafeTransactions: Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Concurrency +

+
+
+
    +
  • +
    + + + + busyMode + +
    +
    +
    +
    +
    +
    +

    The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy

    + +

    Default: immediateError

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var busyMode: Database.BusyMode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + maximumReaderCount + +
    +
    +
    +
    +
    +
    +

    The maximum number of concurrent readers (applies to database +pools only).

    + +

    Default: 5

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var maximumReaderCount: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + qos + +
    +
    +
    +
    +
    +
    +

    The quality of service class for the work performed by the database.

    + +

    The quality of service is ignored if you supply a target queue.

    + +

    Default: .default

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var qos: DispatchQoS
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + targetQueue + +
    +
    +
    +
    +
    +
    +

    The target queue for all database accesses.

    + +

    When you use a database pool, make sure the queue is concurrent. If +it is serial, no concurrent database access can happen, and you may +experience deadlocks.

    + +

    If the queue is nil, all database accesses happen in unspecified +dispatch queues whose quality of service and label are determined by the +qos and label Configuration properties.

    + +

    Default: nil

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var targetQueue: DispatchQueue?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Factory Configuration +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a factory configuration

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseDateComponents.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseDateComponents.html new file mode 100644 index 000000000..8f12d4ba2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseDateComponents.html @@ -0,0 +1,1543 @@ + + + + DatabaseDateComponents Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseDateComponents

+
+
+ +
public struct DatabaseDateComponents : DatabaseValueConvertible, StatementColumnConvertible, Codable
+ +
+
+

DatabaseDateComponents reads and stores DateComponents in the database.

+ + +
+
+
+
    +
  • +
    + + + + Format + +
    +
    +
    +
    +
    +
    +

    The available formats for reading and storing date components.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum Format : String
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

NSDateComponents conversion +

+
+
+
    +
  • +
    + + + + dateComponents + +
    +
    +
    +
    +
    +
    +

    The date components

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let dateComponents: DateComponents
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + format + +
    +
    +
    +
    +
    +
    +

    The database format

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let format: Format
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:format:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseDateComponents from a DateComponents and a format.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ dateComponents: DateComponents, format: Format)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + dateComponents + + +
    +

    An optional DateComponents.

    +
    +
    + + format + + +
    +

    The format used for storing the date components in +the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementColumnConvertible adoption +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a value initialized from a raw SQLite statement pointer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @inline(__always)
    +@inlinable
    +public init?(sqliteStatement: SQLiteStatement, index: Int32)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + sqliteStatement + + +
    +

    A pointer to an SQLite statement.

    +
    +
    + + index + + +
    +

    The column index.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseValueConvertible adoption +

+
+
+
    +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a DatabaseDateComponents if dbValue contains a +valid date.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseDateComponents?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Codable adoption +

+
+
+
    +
  • +
    + + + + init(from:) + +
    +
    +
    +
    +
    +
    +

    Creates a new instance by decoding from the given decoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(from decoder: Decoder) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + decoder + + +
    +

    The decoder to read data from.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + encode(to:) + +
    +
    +
    +
    +
    +
    +

    Encodes this value into the given encoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func encode(to encoder: Encoder) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + encoder + + +
    +

    The encoder to write data to.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseDateComponents/Format.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseDateComponents/Format.html new file mode 100644 index 000000000..dd4474d41 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseDateComponents/Format.html @@ -0,0 +1,1332 @@ + + + + Format Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Format

+
+
+ +
public enum Format : String
+ +
+
+

The available formats for reading and storing date components.

+ + +
+
+
+
    +
  • +
    + + + + YMD + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD = "yyyy-MM-dd"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + YMD_HM + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd HH:mm”.

    + +

    This format is lexically comparable with SQLite’s CURRENT_TIMESTAMP.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD_HM = "yyyy-MM-dd HH:mm"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + YMD_HMS + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd HH:mm:ss”.

    + +

    This format is lexically comparable with SQLite’s CURRENT_TIMESTAMP.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD_HMS = "yyyy-MM-dd HH:mm:ss"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + YMD_HMSS + +
    +
    +
    +
    +
    +
    +

    The format “yyyy-MM-dd HH:mm:ss.SSS”.

    + +

    This format is lexically comparable with SQLite’s CURRENT_TIMESTAMP.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case YMD_HMSS = "yyyy-MM-dd HH:mm:ss.SSS"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HM + +
    +
    +
    +
    +
    +
    +

    The format “HH:mm”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case HM = "HH:mm"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HMS + +
    +
    +
    +
    +
    +
    +

    The format “HH:mm:ss”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case HMS = "HH:mm:ss"
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + HMSS + +
    +
    +
    +
    +
    +
    +

    The format “HH:mm:ss.SSS”.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case HMSS = "HH:mm:ss.SSS"
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseError.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseError.html new file mode 100644 index 000000000..f0af28bed --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseError.html @@ -0,0 +1,4298 @@ + + + + DatabaseError Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseError

+
+
+ +
public struct DatabaseError : Error, CustomStringConvertible, CustomNSError
+ +
+
+

DatabaseError wraps an SQLite error.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseEvent.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseEvent.html new file mode 100644 index 000000000..19878805f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseEvent.html @@ -0,0 +1,1304 @@ + + + + DatabaseEvent Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseEvent

+
+
+ +
public struct DatabaseEvent
+ +
+
+

A database event, notified to TransactionObserver.

+ + +
+
+
+
    +
  • +
    + + + + Kind + +
    +
    +
    +
    +
    +
    +

    An event kind

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum Kind : Int32
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + kind + +
    +
    +
    +
    +
    +
    +

    The event kind

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let kind: Kind
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseName + +
    +
    +
    +
    +
    +
    +

    The database name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rowID + +
    +
    +
    +
    +
    +
    +

    The rowID of the changed row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let rowID: Int64
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns an event that can be stored:

    +
    class MyObserver: TransactionObserver {
    +    var events: [DatabaseEvent]
    +    func databaseDidChange(with event: DatabaseEvent) {
    +        events.append(event.copy())
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func copy() -> DatabaseEvent
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseEvent/Kind.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseEvent/Kind.html new file mode 100644 index 000000000..139b195a7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseEvent/Kind.html @@ -0,0 +1,1206 @@ + + + + Kind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Kind

+
+
+ +
public enum Kind : Int32
+ +
+
+

An event kind

+ + +
+
+
+
    +
  • +
    + + + + insert + +
    +
    +
    +
    +
    +
    +

    SQLITE_INSERT

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case insert = 18
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + delete + +
    +
    +
    +
    +
    +
    +

    SQLITE_DELETE

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case delete = 9
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + update + +
    +
    +
    +
    +
    +
    +

    SQLITE_UPDATE

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case update = 23
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseMigrator.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseMigrator.html new file mode 100644 index 000000000..bc3f98a74 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseMigrator.html @@ -0,0 +1,2122 @@ + + + + DatabaseMigrator Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseMigrator

+
+
+ +
public struct DatabaseMigrator
+ +
+
+

A DatabaseMigrator registers and applies database migrations.

+ +

Migrations are named blocks of SQL statements that are guaranteed to be +applied in order, once and only once.

+ +

When a user upgrades your application, only non-applied migration are run.

+ +

Usage:

+
var migrator = DatabaseMigrator()
+
+// 1st migration
+migrator.registerMigration("createLibrary") { db in
+    try db.create(table: "author") { t in
+        t.autoIncrementedPrimaryKey("id")
+        t.column("creationDate", .datetime)
+        t.column("name", .text).notNull()
+    }
+
+    try db.create(table: "book") { t in
+        t.autoIncrementedPrimaryKey("id")
+        t.column("authorId", .integer)
+            .notNull()
+            .references("author", onDelete: .cascade)
+        t.column("title", .text).notNull()
+    }
+}
+
+// 2nd migration
+migrator.registerMigration("AddBirthYearToAuthors") { db in
+    try db.alter(table: "author") { t
+        t.add(column: "birthYear", .integer)
+    }
+}
+
+// Migrations for future versions will be inserted here:
+//
+// // 3rd migration
+// migrator.registerMigration("...") { db in
+//     ...
+// }
+
+try migrator.migrate(dbQueue)
+
+ + +
+
+
+
    +
  • +
    + + + + ForeignKeyChecks + +
    +
    +
    +
    +
    +
    +

    Controls how migrations handle foreign keys constraints.

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum ForeignKeyChecks
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    When the eraseDatabaseOnSchemaChange flag is true, the migrator will +automatically wipe out the full database content, and recreate the whole +database from scratch, if it detects that a migration has changed its +definition.

    + +

    This flag can destroy your precious users’ data!

    + +

    But it may be useful in two situations:

    + +
      +
    1. During application development, as you are still designing +migrations, and the schema changes often.

      + +

      In this case, it is recommended that you make sure this flag does +not ship in the distributed application, in order to avoid undesired +data loss:

      +
      var migrator = DatabaseMigrator()
      +#if DEBUG
      +// Speed up development by nuking the database when migrations change
      +migrator.eraseDatabaseOnSchemaChange = true
      +#endif
      +
    2. +
    3. When the database content can easily be recreated, such as a cache +for some downloaded data.

    4. +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var eraseDatabaseOnSchemaChange: Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    A new migrator.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Disabling Foreign Key Checks +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns a migrator that will not perform deferred foreign key checks in +all newly registered migrations.

    + +

    The returned migrator is unsafe, because it no longer guarantees the +integrity of the database. It is your responsibility to register +migrations that do not break foreign key constraints.

    + +

    Running migrations without foreign key checks can improve migration +performance on huge databases.

    + +

    Example:

    +
    var migrator = DatabaseMigrator()
    +migrator.registerMigration("A") { db in
    +    // Runs with deferred foreign key checks
    +}
    +migrator.registerMigration("B", foreignKeyChecks: .immediate) { db in
    +    // Runs with immediate foreign key checks
    +}
    +
    +migrator = migrator.disablingDeferredForeignKeyChecks()
    +migrator.registerMigration("C") { db in
    +    // Runs with disabled foreign key checks
    +}
    +migrator.registerMigration("D", foreignKeyChecks: .immediate) { db in
    +    // Runs with immediate foreign key checks
    +}
    +
    +
    +

    Warning

    + Before using this unsafe method, try to run your migrations with +.immediate foreign key checks, if possible. This may enhance migration +performances, while preserving the database integrity guarantee. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func disablingDeferredForeignKeyChecks() -> DatabaseMigrator
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Registering Migrations +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Registers a migration.

    +
    migrator.registerMigration("createAuthors") { db in
    +    try db.create(table: "author") { t in
    +        t.autoIncrementedPrimaryKey("id")
    +        t.column("creationDate", .datetime)
    +        t.column("name", .text).notNull()
    +    }
    +}
    +
    +
    +

    Precondition

    +

    No migration with the same same as already been registered.

    + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func registerMigration(
    +    _ identifier: String,
    +    foreignKeyChecks: ForeignKeyChecks = .deferred,
    +    migrate: @escaping (Database) throws -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + identifier + + +
    +

    The migration identifier.

    +
    +
    + + foreignKeyChecks + + +
    +

    This parameter is ignored if the database has +not enabled foreign keys.

    +
    +
    + + block + + +
    +

    The migration block that performs SQL statements.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Applying Migrations +

+
+
+
    +
  • +
    + + + + migrate(_:) + +
    +
    +
    +
    +
    +
    +

    Iterate migrations in the same order as they were registered. If a +migration has not yet been applied, its block is executed in +a transaction.

    +
    +

    Throws

    + An eventual error thrown by the registered migration blocks. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func migrate(_ writer: DatabaseWriter) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + migrate(_:upTo:) + +
    +
    +
    +
    +
    +
    +

    Iterate migrations in the same order as they were registered, up to the +provided target. If a migration has not yet been applied, its block is +executed in a transaction.

    +
    +

    Throws

    + An eventual error thrown by the registered migration blocks. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func migrate(_ writer: DatabaseWriter, upTo targetIdentifier: String) throws
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    + + targetIdentifier + + +
    +

    The identifier of a registered migration.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Iterate migrations in the same order as they were registered. If a +migration has not yet been applied, its block is executed in +a transaction.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asyncMigrate(
    +    _ writer: DatabaseWriter,
    +    completion: @escaping (Database, Error?) -> Void)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    + + completion + + +
    +

    A closure that is called in a protected dispatch +queue that can write in the database, with the eventual +migration error.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Querying Migrations +

+
+
+
    +
  • +
    + + + + migrations + +
    +
    +
    +
    +
    +
    +

    The list of registered migration identifiers, in the same order as they +have been registered.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var migrations: [String] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + appliedMigrations(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the identifiers of registered and applied migrations, in the +order of registration.

    + +

    See also appliedIdentifiers(_:).

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func appliedMigrations(_ db: Database) throws -> [String]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the applied migration identifiers, even unregistered ones.

    + +

    See also appliedMigrations(_:).

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func appliedIdentifiers(_ db: Database) throws -> Set<String>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the identifiers of completed migrations, of which all previous +migrations have been applied.

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func completedMigrations(_ db: Database) throws -> [String]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns true if all migrations are applied.

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasCompletedMigrations(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasBeenSuperseded(_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether database contains unknown migration +identifiers, which is likely the sign that the database +has migrated further than the migrator itself supports.

    +
    +

    Throws

    + An eventual database error. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasBeenSuperseded(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Migrations +

+
+
+
    +
  • +
    + + + + migratePublisher(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously migrates a database.

    +
    let migrator: DatabaseMigrator = ...
    +let dbQueue: DatabaseQueue = ...
    +let publisher = migrator.migratePublisher(dbQueue)
    +
    + +

    It completes on the main dispatch queue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func migratePublisher(_ writer: DatabaseWriter) -> DatabasePublishers.Migrate
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a Publisher that asynchronously migrates a database.

    +
    let migrator: DatabaseMigrator = ...
    +let dbQueue: DatabaseQueue = ...
    +let publisher = migrator.migratePublisher(dbQueue, receiveOn: DispatchQueue.global())
    +
    + +

    It completes on scheduler.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func migratePublisher<S>(_ writer: DatabaseWriter, receiveOn scheduler: S)
    +-> DatabasePublishers.Migrate
    +where S: Scheduler
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + writer + + +
    +

    A DatabaseWriter (DatabaseQueue or DatabasePool) +where migrations should apply.

    +
    +
    + + scheduler + + +
    +

    A Combine Scheduler.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseMigrator/ForeignKeyChecks.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseMigrator/ForeignKeyChecks.html new file mode 100644 index 000000000..28942a369 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseMigrator/ForeignKeyChecks.html @@ -0,0 +1,1188 @@ + + + + ForeignKeyChecks Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyChecks

+
+
+ +
public enum ForeignKeyChecks
+ +
+
+

Controls how migrations handle foreign keys constraints.

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabasePreUpdateEvent.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabasePreUpdateEvent.html new file mode 100644 index 000000000..d069de89f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabasePreUpdateEvent.html @@ -0,0 +1,1382 @@ + + + + DatabasePreUpdateEvent Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabasePreUpdateEvent

+ +
+
+
+
    +
  • +
    + + + + Kind + +
    +
    +
    +
    +
    +
    +

    An event kind

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + kind + +
    +
    +
    +
    +
    +
    +

    The event kind

    + +
    +
    +
    +
  • +
  • +
    + + + + databaseName + +
    +
    +
    +
    +
    +
    +

    The database name

    + +
    +
    +
    +
  • +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name

    + +
    +
    +
    +
  • +
  • +
    + + + + count + +
    +
    +
    +
    +
    +
    +

    The number of columns in the row that is being inserted, updated, or deleted.

    + +
    +
    +
    +
  • +
  • +
    + + + + depth + +
    +
    +
    +
    +
    +
    +

    1 for inserts, updates, or deletes invoked by top-level triggers; +2 for changes resulting from triggers called by top-level triggers; +… and so forth

    + +
    +
    +
    +
  • +
  • +
    + + + + initialRowID + +
    +
    +
    +
    +
    +
    +

    The initial rowID of the row being changed for .Update and .Delete changes, +and nil for .Insert changes.

    + +
    +
    +
    +
  • +
  • +
    + + + + finalRowID + +
    +
    +
    +
    +
    +
    +

    The final rowID of the row being changed for .Update and .Insert changes, +and nil for .Delete changes.

    + +
    +
    +
    +
  • +
  • +
    + + + + initialDatabaseValues + +
    +
    +
    +
    +
    +
    +

    The initial database values in the row.

    + +

    Values appear in the same order as the columns in the table.

    + +

    The result is nil if the event is an .Insert event.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the initial DatabaseValue at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    The result is nil if the event is an .Insert event.

    + +
    +
    +
    +
  • +
  • +
    + + + + finalDatabaseValues + +
    +
    +
    +
    +
    +
    +

    The final database values in the row.

    + +

    Values appear in the same order as the columns in the table.

    + +

    The result is nil if the event is a .Delete event.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns the final DatabaseValue at given index.

    + +

    Indexes span from 0 for the leftmost column to (row.count - 1) for the +righmost column.

    + +

    The result is nil if the event is a .Delete event.

    + +
    +
    +
    +
  • +
  • +
    + + + + copy() + +
    +
    +
    +
    +
    +
    +

    Returns an event that can be stored:

    +
    class MyObserver: TransactionObserver {
    +    var events: [DatabasePreUpdateEvent]
    +    func databaseWillChange(with event: DatabasePreUpdateEvent) {
    +        events.append(event.copy())
    +    }
    +}
    +
    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabasePreUpdateEvent/Kind.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabasePreUpdateEvent/Kind.html new file mode 100644 index 000000000..dca3743d7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabasePreUpdateEvent/Kind.html @@ -0,0 +1,1163 @@ + + + + Kind Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Kind

+

An event kind

+ +
+
+
+
    +
  • +
    + + + + insert + +
    +
    +
    +
    +
    +
    +

    SQLITE_INSERT

    + +
    +
    +
    +
  • +
  • +
    + + + + delete + +
    +
    +
    +
    +
    +
    +

    SQLITE_DELETE

    + +
    +
    +
    +
  • +
  • +
    + + + + update + +
    +
    +
    +
    +
    +
    +

    SQLITE_UPDATE

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseRegion.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseRegion.html new file mode 100644 index 000000000..58ec31b9e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseRegion.html @@ -0,0 +1,1457 @@ + + + + DatabaseRegion Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegion

+
+
+ +
public struct DatabaseRegion : CustomStringConvertible, Equatable
+
extension DatabaseRegion: DatabaseRegionConvertible
+ +
+
+

DatabaseRegion defines a region in the database. DatabaseRegion is dedicated +to help transaction observers recognize impactful database changes in their +observes(eventsOfKind:) and databaseDidChange(with:) methods.

+ +

A database region is the union of any number of “table regions”, which can +cover a full table, or the combination of columns and rows:

+
|Table1 |   |Table2 |   |Table3 |   |Table4 |   |Table5 |
+|-------|   |-------|   |-------|   |-------|   |-------|
+|x|x|x|x|   |x| | | |   |x|x|x|x|   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | |x| | |
+|x|x|x|x|   |x| | | |   | | | | |   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | | | | |
+
+ +

To create a database region, you use one of those methods:

+ +
    +
  • DatabaseRegion.fullDatabase: the region that covers all database tables.

  • +
  • DatabaseRegion(): the empty region.

  • +
  • DatabaseRegion(table:): the region that covers one database table.

  • +
  • Statement.databaseRegion:

    +
    let statement = try db.makeStatement(sql: "SELECT name, score FROM player")
    +let region = statement.databaseRegion
    +
  • +
  • FetchRequest.databaseRegion(_:)

    +
    let request = Player.filter(key: 1)
    +let region = try request.databaseRegion(db)
    +
  • +
+ + +
+
+
+
    +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    Returns whether the region is empty.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isFullDatabase + +
    +
    +
    +
    +
    +
    +

    Returns whether the region covers the full database: all columns and all +rows from all tables.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isFullDatabase: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fullDatabase + +
    +
    +
    +
    +
    +
    +

    The region that covers the full database: all columns and all rows +from all tables.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let fullDatabase: DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an empty database region.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(table:) + +
    +
    +
    +
    +
    +
    +

    Creates a region that spans all rows and columns of a database table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(table: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + table + + +
    +

    A table name.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + union(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the union of this region and the given one.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func union(_ other: DatabaseRegion) -> DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + formUnion(_:) + +
    +
    +
    +
    +
    +
    +

    Inserts the given region into this region

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func formUnion(_ other: DatabaseRegion)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Database Events +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Returns whether the content in the region would be impacted if the +database were modified by an event of this kind.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isModified(byEventsOfKind eventKind: DatabaseEventKind) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isModified(by:) + +
    +
    +
    +
    +
    +
    +

    Returns whether the content in the region is impacted by this event.

    +
    +

    Precondition

    + event has been filtered by the same region +in the TransactionObserver.observes(eventsOfKind:) method, by calling +region.isModified(byEventsOfKind:) + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isModified(by event: DatabaseEvent) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseRegionObservation.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseRegionObservation.html new file mode 100644 index 000000000..4dcc5d249 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseRegionObservation.html @@ -0,0 +1,1407 @@ + + + + DatabaseRegionObservation Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseRegionObservation

+
+
+ +
public struct DatabaseRegionObservation
+ +
+
+

DatabaseRegionObservation tracks changes in the results of database +requests, and notifies each database transaction whenever the +database changes.

+ +

For example:

+
let observation = DatabaseRegionObservation(tracking: Player.all)
+let observer = try observation.start(in: dbQueue) { db: Database in
+    print("Players have changed.")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + extent + +
    +
    +
    +
    +
    +
    +

    The extent of the database observation. The default is +.observerLifetime: the observation lasts until the +observer returned by the start(in:onChange:) method +is deallocated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var extent: Database.TransactionObservationExtent
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(tracking:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseRegionObservation which observes regions, and +notifies whenever one of the observed regions is modified by a +database transaction.

    + +

    For example, this sample code counts the number of a times the player +table is modified:

    +
    let observation = DatabaseRegionObservation(tracking: Player.all())
    +
    +var count = 0
    +let observer = observation.start(in: dbQueue) { _ in
    +    count += 1
    +    print("Players have been modified \(count) times.")
    +}
    +
    + +

    The observation lasts until the observer returned by start is +deallocated. See the extent property for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(tracking regions: DatabaseRegionConvertible...)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + regions + + +
    +

    A list of observed regions.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(tracking:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseRegionObservation which observes regions, and +notifies whenever one of the observed regions is modified by a +database transaction.

    + +

    For example, this sample code counts the number of a times the player +table is modified:

    +
    let observation = DatabaseRegionObservation(tracking: [Player.all()])
    +
    +var count = 0
    +let observer = observation.start(in: dbQueue) { _ in
    +    count += 1
    +    print("Players have been modified \(count) times.")
    +}
    +
    + +

    The observation lasts until the observer returned by start is +deallocated. See the extent property for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(tracking regions: [DatabaseRegionConvertible])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + regions + + +
    +

    A list of observed regions.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + start(in:onChange:) + +
    +
    +
    +
    +
    +
    +

    Starts the observation in the provided database writer (such as +a database queue or database pool), and returns a transaction observer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func start(
    +    in dbWriter: DatabaseWriter,
    +    onChange: @escaping (Database) -> Void)
    +throws -> TransactionObserver
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseWriter.

    +
    +
    + + onChange + + +
    +

    A closure that is provided a database connection +with write access each time the observed region has been modified.

    +
    +
    +
    +
    +

    Return Value

    +

    a TransactionObserver

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Impactful Transactions +

+
+
+
    +
  • +
    + + + + publisher(in:) + +
    +
    +
    +
    +
    +
    +

    Returns a publisher that tracks changes in a database region.

    + +

    It emits database connections on a protected dispatch queue.

    + +

    Error completion, if any, is only emitted, synchronously, +on subscription.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func publisher(in writer: DatabaseWriter) -> DatabasePublishers.DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseValue.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseValue.html new file mode 100644 index 000000000..6a55b53a1 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseValue.html @@ -0,0 +1,1474 @@ + + + + DatabaseValue Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

DatabaseValue

+
+
+ +
public struct DatabaseValue : Hashable, CustomStringConvertible, DatabaseValueConvertible, SQLSpecificExpressible
+
extension DatabaseValue: StatementBinding
+ +
+
+

DatabaseValue is the intermediate type between SQLite and your values.

+ +

See https://www.sqlite.org/datatype3.html

+ + +
+
+
+
    +
  • +
    + + + + storage + +
    +
    +
    +
    +
    +
    +

    The SQLite storage

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let storage: Storage
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + null + +
    +
    +
    +
    +
    +
    +

    The NULL DatabaseValue.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let null: DatabaseValue
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + Storage + +
    +
    +
    +
    +
    +
    +

    An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @frozen
    +public enum Storage : Equatable
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(value:) + +
    +
    +
    +
    +
    +
    +

    Creates a DatabaseValue from Any.

    + +

    The result is nil unless object adopts DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(value: Any)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Extracting Value +

+
+
+
    +
  • +
    + + + + isNull + +
    +
    +
    +
    +
    +
    +

    Returns true if databaseValue is NULL.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isNull: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

DatabaseValue +

+
+
+ +
+
+
+ + +
+ +

Hashable & Equatable +

+
+
+
    +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns whether two DatabaseValues are equal.

    +
    1.databaseValue == "foo".databaseValue // false
    +1.databaseValue == 1.databaseValue     // true
    +
    + +

    When comparing integers and doubles, the result is true if and only +values are equal, and if converting one type to the other does +not lose information:

    +
    1.databaseValue == 1.0.databaseValue   // true
    +
    + +

    For a comparison that distinguishes integer and doubles, compare +storages instead:

    +
    1.databaseValue.storage == 1.0.databaseValue.storage // false
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func == (lhs: DatabaseValue, rhs: DatabaseValue) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns self

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns the database value

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> DatabaseValue?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlExpression + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseValue/Storage.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseValue/Storage.html new file mode 100644 index 000000000..25889fa08 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/DatabaseValue/Storage.html @@ -0,0 +1,1331 @@ + + + + Storage Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Storage

+
+
+ +
@frozen
+public enum Storage : Equatable
+ +
+
+

An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).

+ + +
+
+
+
    +
  • +
    + + + + null + +
    +
    +
    +
    +
    +
    +

    The NULL storage class.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case null
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + int64(_:) + +
    +
    +
    +
    +
    +
    +

    The INTEGER storage class, wrapping an Int64.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case int64(Int64)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + double(_:) + +
    +
    +
    +
    +
    +
    +

    The REAL storage class, wrapping a Double.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case double(Double)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + string(_:) + +
    +
    +
    +
    +
    +
    +

    The TEXT storage class, wrapping a String.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case string(String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + blob(_:) + +
    +
    +
    +
    +
    +
    +

    The BLOB storage class, wrapping Data.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case blob(Data)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + value + +
    +
    +
    +
    +
    +
    +

    Returns Int64, Double, String, Data or nil.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var value: DatabaseValueConvertible? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ==(_:_:) + +
    +
    +
    +
    +
    +
    +

    Return true if the storages are identical.

    + +

    Unlike DatabaseValue equality that considers the integer 1 to be +equal to the 1.0 double (as SQLite does), int64 and double storages +are never equal.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func == (lhs: Storage, rhs: Storage) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/EmptyRowAdapter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/EmptyRowAdapter.html new file mode 100644 index 000000000..5e23ea184 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/EmptyRowAdapter.html @@ -0,0 +1,1146 @@ + + + + EmptyRowAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

EmptyRowAdapter

+
+
+ +
public struct EmptyRowAdapter : RowAdapter
+ +
+
+

EmptyRowAdapter is a row adapter that hides all columns.

+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates an EmptyRowAdapter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3.html new file mode 100644 index 000000000..3b1242682 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3.html @@ -0,0 +1,1409 @@ + + + + FTS3 Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3

+
+
+ +
public struct FTS3 : VirtualTableModule
+ +
+
+

FTS3 lets you define “fts3” virtual tables.

+
// CREATE VIRTUAL TABLE document USING fts3(content)
+try db.create(virtualTable: "document", using: FTS3()) { t in
+    t.column("content")
+}
+
+ + +
+
+
+
    +
  • +
    + + + + Diacritics + +
    +
    +
    +
    +
    +
    +

    Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

    + +

    See https://www.sqlite.org/fts3.html

    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public enum Diacritics
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a FTS3 module suitable for the Database +create(virtualTable:using:) method.

    +
    // CREATE VIRTUAL TABLE document USING fts3(content)
    +try db.create(virtualTable: "document", using: FTS3()) { t in
    +    t.column("content")
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns an array of tokens found in the string argument.

    + +

    For example:

    +
    FTS3.tokenize("SQLite database")  // ["sqlite", "database"]
    +FTS3.tokenize("Gustave Doré")     // ["gustave", "doré"])
    +
    + +

    Results can be altered with an explicit tokenizer - default is .simple. +See https://www.sqlite.org/fts3.html#tokenizer.

    +
    FTS3.tokenize("SQLite database", withTokenizer: .porter)   // ["sqlite", "databas"]
    +FTS3.tokenize("Gustave Doré", withTokenizer: .unicode61()) // ["gustave", "dore"])
    +
    + +

    Tokenization is performed by the fts3tokenize virtual table described +at https://www.sqlite.org/fts3.html#querying_tokenizers.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tokenize(
    +    _ string: String,
    +    withTokenizer tokenizer: FTS3TokenizerDescriptor = .simple)
    +-> [String]
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

VirtualTableModule Adoption +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3/Diacritics.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3/Diacritics.html new file mode 100644 index 000000000..476e62fb7 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3/Diacritics.html @@ -0,0 +1,1234 @@ + + + + Diacritics Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Diacritics

+
+
+ +
public enum Diacritics
+ +
+
+

Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+
    +
  • +
    + + + + keep + +
    +
    +
    +
    +
    +
    +

    Do not remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=0” tokenizer argument.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case keep
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + removeLegacy + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=1” tokenizer argument.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case removeLegacy
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + remove + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=2” tokenizer argument, +available from SQLite 3.27.0

    + +
    +
    +
    +
  • +
  • +
    + + + + remove + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=2” tokenizer argument, +available from SQLite 3.27.0

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    case remove
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3Pattern.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3Pattern.html new file mode 100644 index 000000000..2ea43f50b --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3Pattern.html @@ -0,0 +1,1456 @@ + + + + FTS3Pattern Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3Pattern

+
+
+ +
public struct FTS3Pattern
+
extension FTS3Pattern: DatabaseValueConvertible
+ +
+
+

A full text pattern that can query FTS3 and FTS4 virtual tables.

+ + +
+
+
+
    +
  • +
    + + + + rawPattern + +
    +
    +
    +
    +
    +
    +

    The raw pattern string. Guaranteed to be a valid FTS3/4 pattern.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let rawPattern: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(rawPattern:) + +
    +
    +
    +
    +
    +
    +

    Creates a pattern from a raw pattern string; throws DatabaseError on +invalid syntax.

    + +

    The pattern syntax is documented at https://www.sqlite.org/fts3.html#full_text_index_queries

    +
    try FTS3Pattern(rawPattern: "and") // OK
    +try FTS3Pattern(rawPattern: "AND") // malformed MATCH expression: [AND]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawPattern: String) throws
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches any token found in the input string; +returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAnyTokenIn: "")        // nil
    +FTS3Pattern(matchingAnyTokenIn: "foo bar") // foo OR bar
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingAnyTokenIn string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all tokens found in the input string; +returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAllTokensIn: "")        // nil
    +FTS3Pattern(matchingAllTokensIn: "foo bar") // foo bar
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingAllTokensIn string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all token prefixes found in the input +string; returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAllTokensIn: "")        // nil
    +FTS3Pattern(matchingAllTokensIn: "foo bar") // foo* bar*
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingAllPrefixesIn string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(matchingPhrase:) + +
    +
    +
    +
    +
    +
    +

    Creates a pattern that matches a contiguous string; returns nil if no +pattern could be built.

    +
    FTS3Pattern(matchingPhrase: "")        // nil
    +FTS3Pattern(matchingPhrase: "foo bar") // "foo bar"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(matchingPhrase string: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + string + + +
    +

    The string to turn into an FTS3 pattern

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var databaseValue: DatabaseValue { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an FTS3Pattern initialized from dbValue, if it contains +a suitable value.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> FTS3Pattern?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3TokenizerDescriptor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3TokenizerDescriptor.html new file mode 100644 index 000000000..7e42e7e69 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS3TokenizerDescriptor.html @@ -0,0 +1,1280 @@ + + + + FTS3TokenizerDescriptor Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS3TokenizerDescriptor

+
+
+ +
public struct FTS3TokenizerDescriptor
+ +
+
+

An FTS3 tokenizer, suitable for FTS3 and FTS4 table definitions:

+
db.create(virtualTable: "book", using: FTS4()) { t in
+    t.tokenizer = .simple // FTS3TokenizerDescriptor
+}
+
+ +

See https://www.sqlite.org/fts3.html#tokenizer

+ + +
+
+
+
    +
  • +
    + + + + simple + +
    +
    +
    +
    +
    +
    +

    The “simple” tokenizer.

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .simple
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let simple: FTS3TokenizerDescriptor
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + porter + +
    +
    +
    +
    +
    +
    +

    The “porter” tokenizer.

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .porter
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let porter: FTS3TokenizerDescriptor
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The “unicode61” tokenizer.

    +
    db.create(virtualTable: "book", using: FTS4()) { t in
    +    t.tokenizer = .unicode61()
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html#tokenizer

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func unicode61(
    +    diacritics: FTS3.Diacritics = .removeLegacy,
    +    separators: Set<Character> = [],
    +    tokenCharacters: Set<Character> = [])
    +-> FTS3TokenizerDescriptor
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + diacritics + + +
    +

    By default SQLite will strip diacritics from +latin characters.

    +
    +
    + + separators + + +
    +

    Unless empty (the default), SQLite will consider these +characters as token separators.

    +
    +
    + + tokenCharacters + + +
    +

    Unless empty (the default), SQLite will consider +these characters as token characters.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS4.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS4.html new file mode 100644 index 000000000..0af2b45fe --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS4.html @@ -0,0 +1,1332 @@ + + + + FTS4 Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS4

+
+
+ +
public struct FTS4 : VirtualTableModule
+ +
+
+

FTS4 lets you define “fts4” virtual tables.

+
// CREATE VIRTUAL TABLE document USING fts4(content)
+try db.create(virtualTable: "document", using: FTS4()) { t in
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts3.html

+ + +
+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a FTS4 module suitable for the Database +create(virtualTable:using:) method.

    +
    // CREATE VIRTUAL TABLE document USING fts4(content)
    +try db.create(virtualTable: "document", using: FTS4()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts3.html

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

VirtualTableModule Adoption +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5.html new file mode 100644 index 000000000..caf057d57 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5.html @@ -0,0 +1,1277 @@ + + + + FTS5 Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5

+

FTS5 lets you define “fts5” virtual tables.

+
// CREATE VIRTUAL TABLE document USING fts5(content)
+try db.create(virtualTable: "document", using: FTS5()) { t in
+    t.column("content")
+}
+
+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+
    +
  • +
    + + + + Diacritics + +
    +
    +
    +
    +
    +
    +

    Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

    + +

    See https://www.sqlite.org/fts5.html

    + + See more +
    +
    +
    +
  • +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates a FTS5 module suitable for the Database +create(virtualTable:using:) method.

    +
    // CREATE VIRTUAL TABLE document USING fts5(content)
    +try db.create(virtualTable: "document", using: FTS5()) { t in
    +    t.column("content")
    +}
    +
    + +

    See https://www.sqlite.org/fts5.html

    + +
    +
    +
    +
  • +
+
+
+
+ + +
+ +

VirtualTableModule Adoption +

+
+
+
    +
  • +
    + + + + moduleName + +
    +
    +
    +
    +
    +
    +

    The virtual table module name

    + +
    +
    +
    +
  • +
  • +
    + + + + makeTableDefinition() + +
    +
    +
    +
    +
    +
    +

    Reserved; part of the VirtualTableModule protocol.

    + +

    See Database.create(virtualTable:using:)

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Reserved; part of the VirtualTableModule protocol.

    + +

    See Database.create(virtualTable:using:)

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Don’t use this method.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Reserved; part of the VirtualTableModule protocol.

    + +

    See Database.create(virtualTable:using:)

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5/Diacritics.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5/Diacritics.html new file mode 100644 index 000000000..d5e5a5edf --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5/Diacritics.html @@ -0,0 +1,1170 @@ + + + + Diacritics Enumeration Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Diacritics

+

Options for Latin script characters. Matches the raw “remove_diacritics” +tokenizer argument.

+ +

See https://www.sqlite.org/fts5.html

+ +
+
+
+
    +
  • +
    + + + + keep + +
    +
    +
    +
    +
    +
    +

    Do not remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=0” tokenizer argument.

    + +
    +
    +
    +
  • +
  • +
    + + + + removeLegacy + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=1” tokenizer argument.

    + +
    +
    +
    +
  • +
  • +
    + + + + remove + +
    +
    +
    +
    +
    +
    +

    Remove diacritics from Latin script characters. This +option matches the raw “remove_diacritics=2” tokenizer argument, +available from SQLite 3.27.0

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5Pattern.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5Pattern.html new file mode 100644 index 000000000..d94e3b6ae --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5Pattern.html @@ -0,0 +1,1288 @@ + + + + FTS5Pattern Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5Pattern

+
+
+ + +
+
+

A full text pattern that can query FTS5 virtual tables.

+ +
+
+
+
    +
  • +
    + + + + rawPattern + +
    +
    +
    +
    +
    +
    +

    The raw pattern string. Guaranteed to be a valid FTS5 pattern.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches any token found in the input string; +returns nil if no pattern could be built.

    +
    FTS5Pattern(matchingAnyTokenIn: "")        // nil
    +FTS5Pattern(matchingAnyTokenIn: "foo bar") // foo OR bar
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all tokens found in the input string; +returns nil if no pattern could be built.

    +
    FTS5Pattern(matchingAllTokensIn: "")        // nil
    +FTS5Pattern(matchingAllTokensIn: "foo bar") // foo bar
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches all token prefixes found in the input +string; returns nil if no pattern could be built.

    +
    FTS3Pattern(matchingAllTokensIn: "")        // nil
    +FTS3Pattern(matchingAllTokensIn: "foo bar") // foo* bar*
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + init(matchingPhrase:) + +
    +
    +
    +
    +
    +
    +

    Creates a pattern that matches a contiguous string; returns nil if no +pattern could be built.

    +
    FTS5Pattern(matchingPhrase: "")        // nil
    +FTS5Pattern(matchingPhrase: "foo bar") // "foo bar"
    +
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a pattern that matches the prefix of an indexed document; +returns nil if no pattern could be built.

    +
    FTS5Pattern(matchingPrefixPhrase: "")         // nil
    +FTS5Pattern(matchingPrefixPhrase: "the word") // ^"the word"
    +
    + +

    This pattern matches a prefix made of full tokens: “the bat” matches +“the bat is happy”, but not “mind the bat”, or “the batcave is dark”.

    + +
    +
    +
    +
  • +
  • +
    + + + + databaseValue + +
    +
    +
    +
    +
    +
    +

    Returns a value that can be stored in the database.

    + +
    +
    +
    +
  • +
  • +
    + + + + fromDatabaseValue(_:) + +
    +
    +
    +
    +
    +
    +

    Returns an FTS5Pattern initialized from dbValue, if it +contains a suitable value.

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5TokenFlags.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5TokenFlags.html new file mode 100644 index 000000000..e8ee354e6 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5TokenFlags.html @@ -0,0 +1,1163 @@ + + + + FTS5TokenFlags Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5TokenFlags

+

Flags that tell SQLite how to register a token.

+ +

See the FTS5_TOKEN_* flags in https://www.sqlite.org/fts5.html#custom_tokenizers.

+ +
+
+
+
    +
  • +
    + + + + rawValue + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + colocated + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKEN_COLOCATED

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5Tokenization.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5Tokenization.html new file mode 100644 index 000000000..f488ca176 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5Tokenization.html @@ -0,0 +1,1220 @@ + + + + FTS5Tokenization Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5Tokenization

+

The reason why FTS5 is requesting tokenization.

+ +

See https://www.sqlite.org/fts5.html#custom_tokenizers

+ +
+
+
+
    +
  • +
    + + + + rawValue + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    + + + + query + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_QUERY

    + +
    +
    +
    +
  • +
  • +
    + + + + prefix + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_PREFIX

    + +
    +
    +
    +
  • +
  • +
    + + + + document + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_DOCUMENT

    + +
    +
    +
    +
  • +
  • +
    + + + + aux + +
    +
    +
    +
    +
    +
    +

    FTS5_TOKENIZE_AUX

    + +
    +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5TokenizerDescriptor.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5TokenizerDescriptor.html new file mode 100644 index 000000000..265bf499f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/FTS5TokenizerDescriptor.html @@ -0,0 +1,1235 @@ + + + + FTS5TokenizerDescriptor Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

FTS5TokenizerDescriptor

+

An FTS5 tokenizer, suitable for FTS5 table definitions:

+
db.create(virtualTable: "book", using: FTS5()) { t in
+    t.tokenizer = .unicode61() // FTS5TokenizerDescriptor
+}
+
+ +

See https://www.sqlite.org/fts5.html#tokenizers

+ +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKey.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKey.html new file mode 100644 index 000000000..2ab4f2f68 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKey.html @@ -0,0 +1,1324 @@ + + + + ForeignKey Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKey

+
+
+ +
public struct ForeignKey : Equatable
+ +
+
+

A ForeignKey helps building associations when GRDB can’t infer a foreign +key from the database schema.

+ +

Sometimes the database schema does not define any foreign key between two +tables. And sometimes, there are several foreign keys from a table +to another:

+
| Table book   |       | Table person |
+| ------------ |       | ------------ |
+| id           |   +-->• id           |
+| authorId     •---+   | name         |
+| translatorId •---+
+| title        |
+
+ +

When this happens, associations can’t be automatically inferred from the +database schema. GRDB will complain with a fatal error such as “Ambiguous +foreign key from book to person”, or “Could not infer foreign key from book +to person”.

+ +

Your help is needed. You have to instruct GRDB which foreign key to use:

+
struct Book: TableRecord {
+    // Define foreign keys
+    static let authorForeignKey = ForeignKey(["authorId"]))
+    static let translatorForeignKey = ForeignKey(["translatorId"]))
+
+    // Use foreign keys to define associations:
+    static let author = belongsTo(Person.self, using: authorForeignKey)
+    static let translator = belongsTo(Person.self, using: translatorForeignKey)
+}
+
+ +

Foreign keys are always defined from the table that contains the columns at +the origin of the foreign key. Person’s symmetric HasMany associations reuse +Book’s foreign keys:

+
struct Person: TableRecord {
+    static let writtenBooks = hasMany(Book.self, using: Book.authorForeignKey)
+    static let translatedBooks = hasMany(Book.self, using: Book.translatorForeignKey)
+}
+
+ +

Foreign keys can also be defined from query interface columns:

+
struct Book: TableRecord {
+    enum Columns: String, ColumnExpression {
+        case id, title, authorId, translatorId
+    }
+
+    static let authorForeignKey = ForeignKey([Columns.authorId]))
+    static let translatorForeignKey = ForeignKey([Columns.translatorId]))
+}
+
+ +

When the destination table of a foreign key does not define any primary key, +you need to provide the full definition of a foreign key:

+
struct Book: TableRecord {
+    static let authorForeignKey = ForeignKey(["authorId"], to: ["id"]))
+    static let author = belongsTo(Person.self, using: authorForeignKey)
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:to:) + +
    +
    +
    +
    +
    +
    +

    Creates a ForeignKey intended to define a record association.

    +
    struct Book: TableRecord {
    +    // Define foreign keys
    +    static let authorForeignKey = ForeignKey(["authorId"]))
    +    static let translatorForeignKey = ForeignKey(["translatorId"]))
    +
    +    // Use foreign keys to define associations:
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +    static let translator = belongsTo(Person.self, using: translatorForeignKey)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ originColumns: [String], to destinationColumns: [String]? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + originColumns + + +
    +

    The columns at the origin of the foreign key.

    +
    +
    + + destinationColumns + + +
    +

    The columns at the destination of the +foreign key. When nil (the default), GRDB automatically uses the +primary key.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:to:) + +
    +
    +
    +
    +
    +
    +

    Creates a ForeignKey intended to define a record association.

    +
    struct Book: TableRecord {
    +    // Define columns
    +    enum Columns: String, ColumnExpression {
    +        case id, title, authorId, translatorId
    +    }
    +
    +    // Define foreign keys
    +    static let authorForeignKey = ForeignKey([Columns.authorId]))
    +    static let translatorForeignKey = ForeignKey([Columns.translatorId]))
    +
    +    // Use foreign keys to define associations:
    +    static let author = belongsTo(Person.self, using: authorForeignKey)
    +    static let translator = belongsTo(Person.self, using: translatorForeignKey)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ originColumns: [ColumnExpression], to destinationColumns: [ColumnExpression]? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + originColumns + + +
    +

    The columns at the origin of the foreign key.

    +
    +
    + + destinationColumns + + +
    +

    The columns at the destination of the +foreign key. When nil (the default), GRDB automatically uses the +primary key.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKeyInfo.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKeyInfo.html new file mode 100644 index 000000000..08fbe9d4e --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKeyInfo.html @@ -0,0 +1,1267 @@ + + + + ForeignKeyInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyInfo

+
+
+ +
public struct ForeignKeyInfo
+ +
+
+

You get foreign keys from table names, with the +foreignKeys(on:) method.

+ + +
+
+
+
    +
  • +
    + + + + id + +
    +
    +
    +
    +
    +
    +

    The first column in the output of the foreign_key_list pragma

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var id: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + destinationTable + +
    +
    +
    +
    +
    +
    +

    The name of the destination table

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let destinationTable: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + mapping + +
    +
    +
    +
    +
    +
    +

    The column to column mapping

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let mapping: [(origin: String, destination: String)]
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + originColumns + +
    +
    +
    +
    +
    +
    +

    The origin columns

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var originColumns: [String] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + destinationColumns + +
    +
    +
    +
    +
    +
    +

    The destination columns

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var destinationColumns: [String] { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKeyViolation.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKeyViolation.html new file mode 100644 index 000000000..8724c3cad --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ForeignKeyViolation.html @@ -0,0 +1,1362 @@ + + + + ForeignKeyViolation Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ForeignKeyViolation

+
+
+ +
public struct ForeignKeyViolation : FetchableRecord, CustomStringConvertible
+ +
+
+

A foreign key violation produced by PRAGMA foreign_key_check

+ +

See https://www.sqlite.org/pragma.html#pragma_foreign_key_check

+ + +
+
+
+
    +
  • +
    + + + + originTable + +
    +
    +
    +
    +
    +
    +

    The name of the table that contains the REFERENCES clause

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var originTable: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + originRowID + +
    +
    +
    +
    +
    +
    +

    The rowid of the row that contains the invalid REFERENCES clause, or +nil if the origin table is a WITHOUT ROWID table.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var originRowID: Int64?
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + destinationTable + +
    +
    +
    +
    +
    +
    +

    The name of the table that is referred to.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var destinationTable: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + foreignKeyId + +
    +
    +
    +
    +
    +
    +

    The id of the specific foreign key constraint that failed. This id +matches ForeignKeyInfo.id. See Database.foreignKeys(on:) for more +information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var foreignKeyId: Int
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(row:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(row: Row)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + description + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var description: String { get }
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a precise description of the foreign key violation.

    + +

    For example: ‘FOREIGN KEY constraint violation - from player(teamId) to team(id), +in [id:1 teamId:2 name:“O'Brien” score: 1000]’

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func failureDescription(_ db: Database) throws -> String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseError(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseError(_ db: Database) -> DatabaseError
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/IndexInfo.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/IndexInfo.html new file mode 100644 index 000000000..88ed50992 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/IndexInfo.html @@ -0,0 +1,1208 @@ + + + + IndexInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

IndexInfo

+
+
+ +
public struct IndexInfo
+ +
+
+

An index on a database table.

+ +

See Database.indexes(on:)

+ + +
+
+
+
    +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    The name of the index

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let name: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + columns + +
    +
    +
    +
    +
    +
    +

    The indexed columns

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let columns: [String]
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isUnique + +
    +
    +
    +
    +
    +
    +

    True if the index is unique

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let isUnique: Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Inflections.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Inflections.html new file mode 100644 index 000000000..ab5c74901 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Inflections.html @@ -0,0 +1,1540 @@ + + + + Inflections Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Inflections

+
+
+ +
public struct Inflections
+ +
+
+

Experimental

+ +

A type that controls GRDB string inflections.

+ + +
+
+
+
+ + +
+ +

Initialization +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Configuration +

+
+
+
    +
  • +
    + + + + plural(_:options:_:) + +
    +
    +
    +
    +
    +
    +

    Appends a pluralization rule.

    +
    var inflections = Inflections()
    +inflections.plural("$", "s")
    +inflections.pluralize("player") // "players"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func plural(
    +    _ pattern: String,
    +    options: NSRegularExpression.Options = [.caseInsensitive],
    +    _ template: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + pattern + + +
    +

    A regular expression pattern.

    +
    +
    + + options + + +
    +

    Regular expression options (defaults to +[.caseInsensitive]).

    +
    +
    + + template + + +
    +

    A replacement template string.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Appends a singularization rule.

    +
    var inflections = Inflections()
    +inflections.singular("s$", "")
    +inflections.singularize("players") // "player"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func singular(
    +    _ pattern: String,
    +    options: NSRegularExpression.Options = [.caseInsensitive],
    +    _ template: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + pattern + + +
    +

    A regular expression pattern.

    +
    +
    + + options + + +
    +

    Regular expression options (defaults to +[.caseInsensitive]).

    +
    +
    + + template + + +
    +

    A replacement template string.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + uncountableWords(_:) + +
    +
    +
    +
    +
    +
    +

    Appends uncountable words.

    +
    var inflections = Inflections()
    +inflections.plural("$", "s")
    +inflections.uncountableWords(["foo"])
    +inflections.pluralize("foo") // "foo"
    +inflections.pluralize("bar") // "bars"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func uncountableWords(_ words: [String])
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + irregularSuffix(_:_:) + +
    +
    +
    +
    +
    +
    +

    Appends an irregular singular/plural pair.

    +
    var inflections = Inflections()
    +inflections.plural("$", "s")
    +inflections.irregularSuffix("man", "men")
    +inflections.pluralize("man")      // "men"
    +inflections.singularizes("women") // "woman"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func irregularSuffix(_ singular: String, _ plural: String)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + singular + + +
    +

    The singular form.

    +
    +
    + + plural + + +
    +

    The plural form.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Inflections +

+
+
+
    +
  • +
    + + + + pluralize(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a pluralized string.

    +
    Inflections.default.pluralize("player") // "players"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func pluralize(_ string: String) -> String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + singularize(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a singularized string.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func singularize(_ string: String) -> String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + default + +
    +
    +
    +
    +
    +
    +

    The default inflections

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static var `default`: Inflections
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PersistenceConflictPolicy.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PersistenceConflictPolicy.html new file mode 100644 index 000000000..e19a5765f --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PersistenceConflictPolicy.html @@ -0,0 +1,1211 @@ + + + + PersistenceConflictPolicy Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistenceConflictPolicy

+
+
+ +
public struct PersistenceConflictPolicy
+ +
+
+

The MutablePersistableRecord protocol uses this type in order to handle +SQLite conflicts when records are inserted or updated.

+ +

See MutablePersistableRecord.persistenceConflictPolicy.

+ +

See https://www.sqlite.org/lang_conflict.html

+ + +
+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PersistenceContainer.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PersistenceContainer.html new file mode 100644 index 000000000..fe67e7dd4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PersistenceContainer.html @@ -0,0 +1,1195 @@ + + + + PersistenceContainer Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PersistenceContainer

+
+
+ +
public struct PersistenceContainer
+ +
+
+

Use persistence containers in the encode(to:) method of your +encodable records:

+
struct Player: EncodableRecord {
+    var id: Int64?
+    var name: String?
+
+    func encode(to container: inout PersistenceContainer) {
+        container["id"] = id
+        container["name"] = name
+    }
+}
+
+ + +
+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Accesses the value associated with the given column.

    + +

    It is undefined behavior to set different values for the same column. +Column names are case insensitive, so defining both “name” and “NAME” +is considered undefined behavior.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript(column: String) -> DatabaseValueConvertible? { get set }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Accesses the value associated with the given column.

    + +

    It is undefined behavior to set different values for the same column. +Column names are case insensitive, so defining both “name” and “NAME” +is considered undefined behavior.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public subscript<Column>(column: Column) -> DatabaseValueConvertible? where Column : ColumnExpression { get set }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PreparedRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PreparedRequest.html new file mode 100644 index 000000000..2fde21956 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PreparedRequest.html @@ -0,0 +1,1176 @@ + + + + PreparedRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PreparedRequest

+
+
+ +
public struct PreparedRequest
+ +
+
+

A PreparedRequest is a request that is ready to be executed.

+ + +
+
+
+
    +
  • +
    + + + + statement + +
    +
    +
    +
    +
    +
    +

    A prepared statement

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var statement: Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + adapter + +
    +
    +
    +
    +
    +
    +

    An eventual adapter for rows fetched by the select statement

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var adapter: RowAdapter?
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PrimaryKeyInfo.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PrimaryKeyInfo.html new file mode 100644 index 000000000..e09523ebe --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/PrimaryKeyInfo.html @@ -0,0 +1,1244 @@ + + + + PrimaryKeyInfo Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

PrimaryKeyInfo

+
+
+ +
public struct PrimaryKeyInfo
+ +
+
+

Primary keys are returned from the Database.primaryKey(_:) method.

+ +

When the table’s primary key is the rowid:

+
// CREATE TABLE item (name TEXT)
+let pk = try db.primaryKey("item")
+pk.columns     // ["rowid"]
+pk.rowIDColumn // nil
+pk.isRowID     // true
+
+// CREATE TABLE citizen (
+//   id INTEGER PRIMARY KEY,
+//   name TEXT
+// )
+let pk = try db.primaryKey("citizen")!
+pk.columns     // ["id"]
+pk.rowIDColumn // "id"
+pk.isRowID     // true
+
+ +

When the table’s primary key is not the rowid:

+
// CREATE TABLE country (
+//   isoCode TEXT NOT NULL PRIMARY KEY
+//   name TEXT
+// )
+let pk = db.primaryKey("country")!
+pk.columns     // ["isoCode"]
+pk.rowIDColumn // nil
+pk.isRowID     // false
+
+// CREATE TABLE citizenship (
+//   citizenID INTEGER NOT NULL REFERENCES citizen(id)
+//   countryIsoCode TEXT NOT NULL REFERENCES country(isoCode)
+//   PRIMARY KEY (citizenID, countryIsoCode)
+// )
+let pk = db.primaryKey("citizenship")!
+pk.columns     // ["citizenID", "countryIsoCode"]
+pk.rowIDColumn // nil
+pk.isRowID     // false
+
+ + +
+
+
+
    +
  • +
    + + + + columns + +
    +
    +
    +
    +
    +
    +

    The columns in the primary key; this array is never empty.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var columns: [String] { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + rowIDColumn + +
    +
    +
    +
    +
    +
    +

    When not nil, the name of the column that contains the INTEGER PRIMARY KEY.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var rowIDColumn: String? { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isRowID + +
    +
    +
    +
    +
    +
    +

    When true, the primary key is the rowid:

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isRowID: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/QueryInterfaceRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/QueryInterfaceRequest.html new file mode 100644 index 000000000..19987b78a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/QueryInterfaceRequest.html @@ -0,0 +1,2336 @@ + + + + QueryInterfaceRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

QueryInterfaceRequest

+
+
+ +
public struct QueryInterfaceRequest<RowDecoder>
+
extension QueryInterfaceRequest: FetchRequest
+
extension QueryInterfaceRequest: SelectionRequest
+
extension QueryInterfaceRequest: FilteredRequest
+
extension QueryInterfaceRequest: OrderedRequest
+
extension QueryInterfaceRequest: AggregatingRequest
+
extension QueryInterfaceRequest: JoinableRequest
+
extension QueryInterfaceRequest: TableRequest
+
extension QueryInterfaceRequest: DerivableRequest
+ +
+
+

QueryInterfaceRequest is a request that generates SQL for you.

+ +

For example:

+
try dbQueue.read { db in
+    let request = Player
+        .filter(Column("score") > 1000)
+        .order(Column("name"))
+    let players = try request.fetchAll(db) // [Player]
+}
+
+ +

See https://github.com/groue/GRDB.swift#the-query-interface

+ + +
+
+
+ +
+
+
+ + +
+ +

Request Derivation +

+
+
+
    +
  • +
    + + + + select(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection promise.

    +
    // SELECT id, email FROM player
    +var request = Player.all()
    +request = request.select { db in [Column("id"), Column("email")] }
    +
    + +

    Any previous selection is replaced:

    +
    // SELECT email FROM player
    +request
    +    .select { db in [Column("id")] }
    +    .select { db in [Column("email")] }
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.all().select([max(Column("score"))], as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(_ selection: [SQLSelectable], as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.all().select(max(Column("score")), as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(_ selection: SQLSelectable..., as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which selects sql, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let request = Player.all().select(sql: "max(score)", as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal, and fetches values of +type type.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +let defaultName = "Anonymous"
    +let request = Player.all().select(
    +    literal: "IFNULL(name, \(defaultName))",
    +    as: String.self)
    +let name: String? = try request.fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    literal sqlLiteral: SQL,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection promise.

    +
    // SELECT id, email, name FROM player
    +var request = Player.all()
    +request = request
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: { db in [Column("name")] })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: @escaping (Database) throws -> [SQLSelectable]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    +
    // SELECT * FROM player WHERE 1
    +var request = Player.all()
    +request = request.filter { db in true }
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided orderings promise.

    +
    // SELECT * FROM player ORDER BY name
    +var request = Player.all()
    +request = request.order { _ in [Column("name")] }
    +
    + +

    Any previous ordering is replaced:

    +
    // SELECT * FROM player ORDER BY name
    +request
    +    .order{ _ in [Column("email")] }
    +    .reversed()
    +    .order{ _ in [Column("name")] }
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + reversed() + +
    +
    +
    +
    +
    +
    +

    Creates a request that reverses applied orderings.

    +
    // SELECT * FROM player ORDER BY name DESC
    +var request = Player.all().order(Column("name"))
    +request = request.reversed()
    +
    + +

    If no ordering was applied, the returned request is identical.

    +
    // SELECT * FROM player
    +var request = Player.all()
    +request = request.reversed()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func reversed() -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + unordered() + +
    +
    +
    +
    +
    +
    +

    Creates a request without any ordering.

    +
    // SELECT * FROM player
    +var request = Player.all().order(Column("name"))
    +request = request.unordered()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func unordered() -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + group(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request grouped according to expressions promise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate promise added to the +eventual set of already applied predicates.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: @escaping (Database) throws -> SQLExpressible) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    In the example below, the “team.avgScore < player.score” condition in +the ON clause could be not achieved without table aliases.

    +
    struct Player: TableRecord {
    +    static let team = belongsTo(Team.self)
    +}
    +
    +// SELECT player.*, team.*
    +// JOIN team ON ... AND team.avgScore < player.score
    +let playerAlias = TableAlias()
    +let request = Player
    +    .all()
    +    .aliased(playerAlias)
    +    .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func aliased(_ alias: TableAlias) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + distinct() + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func distinct() -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + limit(_:offset:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches limit rows, starting at offset.

    +
    // SELECT * FROM player LIMIT 10 OFFSET 20
    +var request = Player.all()
    +request = request.limit(10, offset: 20)
    +
    + +

    Any previous limit is replaced.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func limit(_ limit: Int, offset: Int?) -> QueryInterfaceRequest
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func with<RowDecoder>(_ cte: CommonTableExpression<RowDecoder>) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + asRequest(of:) + +
    +
    +
    +
    +
    +
    +

    Creates a request bound to type RowDecoder.

    + +

    The returned request can fetch if the type RowDecoder is fetchable (Row, +value, record).

    +
    // Int?
    +let maxScore = try Player
    +    .select(max(scoreColumn))
    +    .asRequest(of: Int.self)    // <--
    +    .fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func asRequest<RowDecoder>(of type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + type + + +
    +

    The fetched type RowDecoder

    +
    +
    +
    +
    +

    Return Value

    +

    A request bound to type RowDecoder.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence +

+
+
+
    +
  • +
    + + + + isEmpty(_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the request matches no row in the database.

    +
    try Player.filter(Column("name") == "Arthur").isEmpty(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func isEmpty(_ db: Database) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether the request matches no row in the database.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Delete +

+
+
+
    +
  • +
    + + + + deleteAll(_:) + +
    +
    +
    +
    +
    +
    +

    Deletes matching rows; returns the number of deleted rows.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Update +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Updates matching rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.all().updateAll(db, [Column("score").set(to: 0)])
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignments: [ColumnAssignment]) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignments + + +
    +

    An array of column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Updates matching rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Player.all().updateAll(db, Column("score").set(to: 0))
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignment: ColumnAssignment,
    +    _ otherAssignments: ColumnAssignment...)
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignment + + +
    +

    A column assignment.

    +
    +
    + + otherAssignments + + +
    +

    Eventual other column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player WHERE ...
    +let request = try Player.filter(...).selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player WHERE ...
    +let request = try Player.filter(...).selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID.Wrapped>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/RangeRowAdapter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/RangeRowAdapter.html new file mode 100644 index 000000000..1109ab50a --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/RangeRowAdapter.html @@ -0,0 +1,1182 @@ + + + + RangeRowAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RangeRowAdapter

+
+
+ +
public struct RangeRowAdapter : RowAdapter
+ +
+
+

RangeRowAdapter is a row adapter that only exposes a range of columns.

+
let adapter = RangeRowAdapter(1..<3)
+let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz, 4 as qux"
+
+// [bar:2 baz:3]
+try Row.fetchOne(db, sql: sql, adapter: adapter)
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a RangeRowAdapter that only exposes a range of columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ range: CountableRange<Int>)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a RangeRowAdapter that only exposes a range of columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ range: CountableClosedRange<Int>)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/RenameColumnAdapter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/RenameColumnAdapter.html new file mode 100644 index 000000000..ec49a1990 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/RenameColumnAdapter.html @@ -0,0 +1,1155 @@ + + + + RenameColumnAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

RenameColumnAdapter

+
+
+ +
public struct RenameColumnAdapter : RowAdapter
+ +
+
+

RenameColumnAdapter is a row adapter that renames columns.

+ +

For example:

+
let adapter = RenameColumnAdapter { $0 + "rrr" }
+let sql = "SELECT 'foo' AS foo, 'bar' AS bar, 'baz' AS baz"
+
+// [foorrr:"foo", barrrr:"bar", bazrrr:"baz"]
+try Row.fetchOne(db, sql: sql, adapter: adapter)
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a RenameColumnAdapter adapter that renames columns according to the +provided transform function.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ transform: @escaping (String) -> String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ResultCode.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ResultCode.html new file mode 100644 index 000000000..8b703c352 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ResultCode.html @@ -0,0 +1,4234 @@ + + + + ResultCode Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ResultCode

+
+
+ +
public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible
+ +
+
+

An SQLite result code.

+ +

See https://www.sqlite.org/rescode.html

+ + +
+
+
+
    +
  • +
    + + + + rawValue + +
    +
    +
    +
    +
    +
    +

    The raw SQLite result code

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public let rawValue: CInt
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(rawValue:) + +
    +
    +
    +
    +
    +
    +

    Creates a ResultCode from a raw SQLite result code.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(rawValue: CInt)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + primaryResultCode + +
    +
    +
    +
    +
    +
    +

    A result code limited to the least significant 8 bits of the receiver. +See https://www.sqlite.org/rescode.html for more information.

    +
    let resultCode = .SQLITE_CONSTRAINT_FOREIGNKEY
    +resultCode.primaryResultCode == .SQLITE_CONSTRAINT // true
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var primaryResultCode: ResultCode { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ~=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the code on the left matches the code on the right.

    + +

    Primary result codes match themselves and their extended result codes, +while extended result codes match only themselves:

    +
    switch error.extendedResultCode {
    +case .SQLITE_CONSTRAINT_FOREIGNKEY: // foreign key constraint error
    +case .SQLITE_CONSTRAINT:            // any other constraint error
    +default:                            // any other database error
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func ~= (pattern: ResultCode, code: ResultCode) -> Bool
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_OK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_OK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ERROR + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_INTERNAL + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_INTERNAL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_PERM + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_PERM: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ABORT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ABORT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_BUSY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_BUSY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_LOCKED + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_LOCKED: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOMEM + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOMEM: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_READONLY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_INTERRUPT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_INTERRUPT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CORRUPT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CORRUPT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOTFOUND + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTFOUND: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_FULL + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_FULL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CANTOPEN + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_PROTOCOL + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_PROTOCOL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_EMPTY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_EMPTY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_SCHEMA + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_SCHEMA: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_TOOBIG + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_TOOBIG: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CONSTRAINT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_MISMATCH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_MISMATCH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_MISUSE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_MISUSE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOLFS + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOLFS: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_AUTH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_AUTH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_FORMAT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_FORMAT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_RANGE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_RANGE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOTADB + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTADB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_NOTICE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTICE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_WARNING + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_WARNING: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ROW + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ROW: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_DONE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_DONE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR_MISSING_COLLSEQ: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ERROR_RETRY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR_RETRY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ERROR_SNAPSHOT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ERROR_SNAPSHOT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_READ + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_READ: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHORT_READ: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_WRITE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_WRITE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_FSYNC + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_FSYNC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DIR_FSYNC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_TRUNCATE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_TRUNCATE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_FSTAT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_FSTAT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_UNLOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_UNLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_RDLOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_RDLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_DELETE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DELETE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_BLOCKED + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_BLOCKED: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_NOMEM + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_NOMEM: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_ACCESS + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_ACCESS: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_CHECKRESERVEDLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_LOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_LOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_CLOSE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_CLOSE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DIR_CLOSE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMOPEN + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMOPEN: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMSIZE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMSIZE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMLOCK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SHMMAP + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SHMMAP: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_SEEK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_SEEK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_DELETE_NOENT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_MMAP + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_MMAP: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_GETTEMPPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_CONVPATH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_CONVPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_VNODE + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_VNODE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_IOERR_AUTH + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_AUTH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_BEGIN_ATOMIC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_COMMIT_ATOMIC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_IOERR_ROLLBACK_ATOMIC: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_LOCKED_SHAREDCACHE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_LOCKED_VTAB + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_LOCKED_VTAB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_BUSY_RECOVERY + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_BUSY_RECOVERY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_BUSY_SNAPSHOT + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_BUSY_SNAPSHOT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_NOTEMPDIR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CANTOPEN_ISDIR + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_ISDIR: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_FULLPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_CONVPATH: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CANTOPEN_DIRTYWAL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_CORRUPT_VTAB + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CORRUPT_VTAB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CORRUPT_SEQUENCE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_RECOVERY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_CANTLOCK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_ROLLBACK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_DBMOVED: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_CANTINIT: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_READONLY_DIRECTORY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_ABORT_ROLLBACK + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_ABORT_ROLLBACK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_CHECK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_COMMITHOOK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_FOREIGNKEY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_FUNCTION: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_NOTNULL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_PRIMARYKEY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_TRIGGER: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_UNIQUE: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_VTAB: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_CONSTRAINT_ROWID: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTICE_RECOVER_WAL: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_NOTICE_RECOVER_ROLLBACK: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_WARNING_AUTOINDEX: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLITE_AUTH_USER + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_AUTH_USER: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let SQLITE_OK_LOAD_PERMANENTLY: ResultCode
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + ~=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns true if the code on the left matches the error on the right.

    + +

    Primary result codes match themselves and their extended result codes, +while extended result codes match only themselves.

    +
    do {
    +    try ...
    +} catch ResultCode.SQLITE_CONSTRAINT_FOREIGNKEY {
    +    // foreign key constraint error
    +} catch ResultCode.SQLITE_CONSTRAINT {
    +    // any other constraint error
    +} catch {
    +    // any other database error
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func ~= (lhs: `Self`, rhs: Error) -> Bool
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQL.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQL.html new file mode 100644 index 000000000..321462bf2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQL.html @@ -0,0 +1,1567 @@ + + + + SQL Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQL

+
+
+ +
public struct SQL
+
extension SQL: SQLSpecificExpressible
+
extension SQL: SQLSelectable
+
extension SQL: SQLOrderingTerm
+
extension SQL: ExpressibleByStringInterpolation
+ +
+
+

SQL helps you build SQL literal with +SQL Interpolation.

+ +

For example:

+
try dbQueue.write { db in
+    let name: String = ...
+    let id: Int64 = ...
+    let query: SQL = "UPDATE player SET name = \(name) WHERE id = \(id)"
+    try db.execute(literal: query)
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init(sql:arguments:) + +
    +
    +
    +
    +
    +
    +

    Creates an SQL literal from a plain SQL string, and +eventual arguments.

    + +

    For example:

    +
    let query = SQL(
    +    sql: "UPDATE player SET name = ? WHERE id = ?",
    +    arguments: [name, id])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(sql: String, arguments: StatementArguments = StatementArguments())
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an SQL literal from an SQL expression.

    + +

    For example:

    +
    let columnLiteral = SQL(Column("username"))
    +let suffixLiteral = SQL("@example.com".databaseValue)
    +let emailLiteral = [columnLiteral, suffixLiteral].joined(separator: " || ")
    +let request = User.select(emailLiteral.sqlExpression)
    +let emails = try String.fetchAll(db, request)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ expression: SQLSpecificExpressible)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    Returns true if this literal generates an empty SQL string

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + build(_:) + +
    +
    +
    +
    +
    +
    +

    Turn a SQL literal into raw SQL and arguments.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func build(_ db: Database) throws -> (sql: String, arguments: StatementArguments)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A tuple made of a raw SQL string, and statement arguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Returns the SQL literal produced by the concatenation of two literals.

    +
    let name = "O'Brien"
    +let selection: SQL = "SELECT * FROM player "
    +let condition: SQL = "WHERE name = \(name)"
    +let query = selection + condition
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func + (lhs: SQL, rhs: SQL) -> SQL
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Appends an SQL literal to the receiver.

    +
    let name = "O'Brien"
    +var query: SQL = "SELECT * FROM player "
    +query += "WHERE name = \(name)"
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func += (lhs: inout SQL, rhs: SQL)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + append(literal:) + +
    +
    +
    +
    +
    +
    +

    Appends an SQL literal to the receiver.

    +
    let name = "O'Brien"
    +var query: SQL = "SELECT * FROM player "
    +query.append(literal: "WHERE name = \(name)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func append(literal sqlLiteral: SQL)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Appends a plain SQL string to the receiver, and eventual arguments.

    +
    let name = "O'Brien"
    +var query: SQL = "SELECT * FROM player "
    +query.append(sql: "WHERE name = ?", arguments: [name])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func append(sql: String, arguments: StatementArguments = StatementArguments())
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlExpression + +
    +
    +
    +
    +
    +
    +

    Creates a literal SQL expression.

    + +

    Use this property when you need an explicit SQLExpression. +For example:

    +
    func date(_ value: SQLExpressible) -> SQLExpression {
    +    SQL("DATE(\(value))").sqlExpression
    +}
    +
    +// SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
    +let createdAt = Column("createdAt")
    +let request = Player.filter(date(createdAt) == "2020-01-23")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSelection + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSelection: SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + sqlOrdering + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlOrdering: SQLOrdering { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

ExpressibleByStringInterpolation +

+
+
+ +
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLExpression.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLExpression.html new file mode 100644 index 000000000..1efc214b0 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLExpression.html @@ -0,0 +1,1201 @@ + + + + SQLExpression Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLExpression

+
+
+ +
public struct SQLExpression
+
extension SQLExpression: SQLSpecificExpressible
+ +
+
+

SQLExpression is the type that represents an SQL expression, as +described at https://www.sqlite.org/lang_expr.html

+ + +
+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    AssociativeBinaryOperator is an associative binary operator, +such as +, *, AND, etc.

    + +

    Use it with the joined(operator:) method. For example:

    +
    // SELECT score + bonus + 1000 FROM player
    +let values = [
    +    scoreColumn,
    +    bonusColumn,
    +    1000.databaseValue]
    +Player.select(values.joined(operator: .add))
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public struct AssociativeBinaryOperator : Hashable
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

SQLExpressible +

+
+
+
    +
  • +
    + + + + sqlExpression + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlExpression: SQLExpression { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLExpression/AssociativeBinaryOperator.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLExpression/AssociativeBinaryOperator.html new file mode 100644 index 000000000..2d8e902f8 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLExpression/AssociativeBinaryOperator.html @@ -0,0 +1,1301 @@ + + + + AssociativeBinaryOperator Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

AssociativeBinaryOperator

+
+
+ +
public struct AssociativeBinaryOperator : Hashable
+ +
+
+

AssociativeBinaryOperator is an associative binary operator, +such as +, *, AND, etc.

+ +

Use it with the joined(operator:) method. For example:

+
// SELECT score + bonus + 1000 FROM player
+let values = [
+    scoreColumn,
+    bonusColumn,
+    1000.databaseValue]
+Player.select(values.joined(operator: .add))
+
+ + +
+
+
+
    +
  • +
    + + + + add + +
    +
    +
    +
    +
    +
    +

    The + binary operator

    + +

    For example:

    +
    // score + bonus
    +[Column("score"), Column("bonus")].joined(operator: .add)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let add: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + multiply + +
    +
    +
    +
    +
    +
    +

    The * binary operator

    + +

    For example:

    +
    // score * factor
    +[Column("score"), Column("factor")].joined(operator: .multiply)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let multiply: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + and + +
    +
    +
    +
    +
    +
    +

    The AND binary operator

    + +

    For example:

    +
    // isBlue AND isTall
    +[Column("isBlue"), Column("isTall")].joined(operator: .and)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let and: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + or + +
    +
    +
    +
    +
    +
    +

    The OR binary operator

    + +

    For example:

    +
    // isBlue OR isTall
    +[Column("isBlue"), Column("isTall")].joined(operator: .or)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let or: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + concat + +
    +
    +
    +
    +
    +
    +

    The || string concatenation operator

    + +

    For example:

    +
    // firstName || ' ' || lastName
    +[Column("firstName"), " ", Column("lastName")].joined(operator: .concat)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static let concat: SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLOrdering.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLOrdering.html new file mode 100644 index 000000000..0e6e7afaa --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLOrdering.html @@ -0,0 +1,1156 @@ + + + + SQLOrdering Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLOrdering

+
+
+ +
public struct SQLOrdering
+
extension SQLOrdering: SQLOrderingTerm
+ +
+
+

The type that can be used as an SQL ordering term, as described at +https://www.sqlite.org/syntax/ordering-term.html

+ + +
+
+
+
+ + +
+ +

SQLOrderingTerm +

+
+
+
    +
  • +
    + + + + sqlOrdering + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlOrdering: SQLOrdering { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLRequest.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLRequest.html new file mode 100644 index 000000000..95a6ab5c8 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLRequest.html @@ -0,0 +1,1655 @@ + + + + SQLRequest Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLRequest

+
+
+ +
public struct SQLRequest<RowDecoder>
+
extension SQLRequest: FetchRequest
+
extension SQLRequest: ExpressibleByStringInterpolation
+ +
+
+

A FetchRequest built from raw SQL.

+ + +
+
+
+
    +
  • +
    + + + + adapter + +
    +
    +
    +
    +
    +
    +

    The request adapter

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var adapter: RowAdapter?
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL string, optional arguments, and +optional row adapter.

    +
    let request = SQLRequest<String>(sql: """
    +    SELECT name FROM player
    +    """)
    +let request = SQLRequest<Player>(sql: """
    +    SELECT * FROM player WHERE id = ?
    +    """, arguments: [1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil,
    +    cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL literal, and optional row adapter.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    let name = "O'brien"
    +let request = SQLRequest<Player>(literal: """
    +    SELECT * FROM player WHERE name = \(name)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(literal sqlLiteral: SQL, adapter: RowAdapter? = nil, cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
  • +
    + + + + sqlSubquery + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSubquery: SQLSubquery { get }
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCount(_ db: Database) throws -> Int
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func makePreparedRequest(
    +    _ db: Database,
    +    forSingleResult singleResult: Bool = false)
    +throws -> PreparedRequest
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    :nodoc

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(unicodeScalarLiteral: String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL string, optional arguments, and +optional row adapter.

    +
    let request = SQLRequest(sql: """
    +    SELECT * FROM player WHERE id = ?
    +    """, arguments: [1])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    adapter: RowAdapter? = nil,
    +    cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + sql + + +
    +

    An SQL query.

    +
    +
    + + arguments + + +
    +

    Statement arguments.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request from an SQL literal, and optional row adapter.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    let name = "O'brien"
    +let request = SQLRequest(literal: """
    +    SELECT * FROM player WHERE name = \(name)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(literal sqlLiteral: SQL, adapter: RowAdapter? = nil, cached: Bool = false)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + sqlLiteral + + +
    +

    An SQL literal.

    +
    +
    + + adapter + + +
    +

    Optional RowAdapter.

    +
    +
    + + cached + + +
    +

    Defaults to false. If true, the request reuses a cached +prepared statement.

    +
    +
    +
    +
    +

    Return Value

    +

    A SQLRequest

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLSelection.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLSelection.html new file mode 100644 index 000000000..618fc8336 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLSelection.html @@ -0,0 +1,1156 @@ + + + + SQLSelection Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSelection

+
+
+ +
public struct SQLSelection
+
extension SQLSelection: SQLSelectable
+ +
+
+

The type that can be selected, as described at +https://www.sqlite.org/syntax/result-column.html

+ + +
+
+
+
+ + +
+ +

SQLSelectable +

+
+
+
    +
  • +
    + + + + sqlSelection + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSelection: SQLSelection { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLSubquery.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLSubquery.html new file mode 100644 index 000000000..c04605b48 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SQLSubquery.html @@ -0,0 +1,1156 @@ + + + + SQLSubquery Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SQLSubquery

+
+
+ +
public struct SQLSubquery
+
extension SQLSubquery: SQLSubqueryable
+ +
+
+

The type that can be embedded as a subquery.

+ + +
+
+
+
+ + +
+ +

SQLSubqueryable +

+
+
+
    +
  • +
    + + + + sqlSubquery + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var sqlSubquery: SQLSubquery { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ScopeAdapter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ScopeAdapter.html new file mode 100644 index 000000000..07beaf5d9 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ScopeAdapter.html @@ -0,0 +1,1270 @@ + + + + ScopeAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ScopeAdapter

+
+
+ +
public struct ScopeAdapter : RowAdapter
+ +
+
+

ScopeAdapter is a row adapter that lets you define scopes on rows.

+
// Two adapters
+let fooAdapter = ColumnMapping(["value": "foo"])
+let barAdapter = ColumnMapping(["value": "bar"])
+
+// Define scopes
+let adapter = ScopeAdapter([
+    "foo": fooAdapter,
+    "bar": barAdapter])
+
+// Fetch
+let sql = "SELECT 'foo' AS foo, 'bar' AS bar"
+let row = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+
+// Scoped rows:
+if let fooRow = row.scopes["foo"] {
+    fooRow["value"]    // "foo"
+}
+if let barRow = row.scopes["bar"] {
+    barRow["value"]    // "bar"
+}
+
+ + +
+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates an adapter that preserves row contents and add scoped rows.

    + +

    For example:

    +
    let adapter = ScopeAdapter(["suffix": SuffixRowAdapter(fromIndex: 1)])
    +let row = try Row.fetchOne(db, sql: "SELECT 1, 2, 3", adapter: adapter)!
    +row                  // [1, 2, 3]
    +row.scopes["suffix"] // [2, 3]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ scopes: [String : RowAdapter])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + scopes + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(base:scopes:) + +
    +
    +
    +
    +
    +
    +

    Creates an adapter based on the base adapter, and add scoped rows.

    + +

    For example:

    +
    let baseAdapter = RangeRowAdapter(0..<1)
    +let adapter = ScopeAdapter(base: baseAdapter, scopes: ["suffix": SuffixRowAdapter(fromIndex: 1)])
    +let row = try Row.fetchOne(db, sql: "SELECT 1, 2, 3", adapter: adapter)!
    +row                   // [1]
    +row.scopes["initial"] // [2, 3]
    +
    + +

    If the base adapter already defines scopes, the given scopes replace +eventual existing scopes with the same name.

    + +

    This initializer is equivalent to baseAdapter.addingScopes(scopes).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(base: RowAdapter, scopes: [String : RowAdapter])
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + base + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    + + scopes + + +
    +

    A dictionary that maps scope names to +row adapters.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/StatementArguments.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/StatementArguments.html new file mode 100644 index 000000000..376a60a8c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/StatementArguments.html @@ -0,0 +1,1963 @@ + + + + StatementArguments Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

StatementArguments

+
+
+ +
public struct StatementArguments: CustomStringConvertible, Equatable,
+                                  ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral
+ +
+
+

StatementArguments provide values to argument placeholders in raw +SQL queries.

+ +

Placeholders can take several forms (see https://www.sqlite.org/lang_expr.html#varparam +for more information):

+ +
    +
  • ?NNN (e.g. ?2): the NNN-th argument (starts at 1)
  • +
  • ?: the N-th argument, where N is one greater than the largest argument +number already assigned
  • +
  • :AAAA (e.g. :name): named argument

  • +
  • $AAAA (e.g. $name): named argument

  • +
+

Positional Arguments

+ +

To fill question marks placeholders, feed StatementArguments with an array:

+
db.execute(
+    sql: "INSERT ... (?, ?)",
+    arguments: StatementArguments(["Arthur", 41]))
+
+// Array literals are automatically converted:
+db.execute(
+    sql: "INSERT ... (?, ?)",
+    arguments: ["Arthur", 41])
+
+

Named Arguments

+ +

To fill named arguments, feed StatementArguments with a dictionary:

+
db.execute(
+    sql: "INSERT ... (:name, :score)",
+    arguments: StatementArguments(["name": "Arthur", "score": 41]))
+
+// Dictionary literals are automatically converted:
+db.execute(
+    sql: "INSERT ... (:name, :score)",
+    arguments: ["name": "Arthur", "score": 41])
+
+

Concatenating Arguments

+ +

Several arguments can be concatenated and mixed with the +append(contentsOf:) method and the +, &+, += operators:

+
var arguments: StatementArguments = ["Arthur"]
+arguments += [41]
+db.execute(sql: "INSERT ... (?, ?)", arguments: arguments)
+
+ +

+ and += operators consider that overriding named arguments is a +programmer error:

+
var arguments: StatementArguments = ["name": "Arthur"]
+arguments += ["name": "Barbara"]
+// fatal error: already defined statement argument: name
+
+ +

&+ and append(contentsOf:) allow overriding named arguments:

+
var arguments: StatementArguments = ["name": "Arthur"]
+arguments = arguments &+ ["name": "Barbara"]
+print(arguments)
+// Prints ["name": "Barbara"]
+
+

Mixed Arguments

+ +

It is possible to mix named and positional arguments. Yet this is usually +confusing, and it is best to avoid this practice:

+
let sql = "SELECT ?2 AS two, :foo AS foo, ?1 AS one, :foo AS foo2, :bar AS bar"
+var arguments: StatementArguments = [1, 2, "bar"] + ["foo": "foo"]
+let row = try Row.fetchOne(db, sql: sql, arguments: arguments)!
+print(row)
+// Prints [two:2 foo:"foo" one:1 foo2:"foo" bar:"bar"]
+
+ +

Mixed arguments exist as a support for requests like the following:

+
let players = try Player
+    .filter(sql: "team = :team", arguments: ["team": "Blue"])
+    .filter(sql: "score > ?", arguments: [1000])
+    .fetchAll(db)
+
+ + +
+
+
+
    +
  • +
    + + + + isEmpty + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var isEmpty: Bool { get }
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Empty Arguments +

+
+
+
    +
  • +
    + + + + init() + +
    +
    +
    +
    +
    +
    +

    Creates empty StatementArguments.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init()
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Positional Arguments +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of optional values.

    +
    let values: [DatabaseValueConvertible?] = ["foo", 1, nil]
    +db.execute(sql: "INSERT ... (?,?,?)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Sequence>(_ sequence: Sequence) where Sequence : Sequence, Sequence.Element == DatabaseValueConvertible?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of DatabaseValueConvertible values.

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of optional values.

    +
    let values: [String] = ["foo", "bar"]
    +db.execute(sql: "INSERT ... (?,?)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Sequence>(_ sequence: Sequence) where Sequence : Sequence, Sequence.Element : DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of DatabaseValueConvertible values.

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from any array. The result is nil unless all +array elements adopt DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(_ array: [Any])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + array + + +
    +

    An array

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Named Arguments +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of (key, value) dictionary, +such as a dictionary.

    +
    let values: [String: DatabaseValueConvertible?] = ["firstName": nil, "lastName": "Miller"]
    +db.execute(sql: "INSERT ... (:firstName, :lastName)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ dictionary: [String : DatabaseValueConvertible?])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of (key, value) pairs

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from a sequence of (key, value) pairs, such +as a dictionary.

    +
    let values: [String: DatabaseValueConvertible?] = ["firstName": nil, "lastName": "Miller"]
    +db.execute(sql: "INSERT ... (:firstName, :lastName)", arguments: StatementArguments(values))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init<Sequence>(_ sequence: Sequence)
    +where Sequence: Swift.Sequence, Sequence.Element == (String, DatabaseValueConvertible?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + sequence + + +
    +

    A sequence of (key, value) pairs

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Creates statement arguments from [AnyHashable: Any].

    + +

    The result is nil unless all dictionary keys are strings, and values +adopt DatabaseValueConvertible.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init?(_ dictionary: [AnyHashable : Any])
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + dictionary + + +
    +

    A dictionary.

    +
    +
    +
    +
    +

    Return Value

    +

    A StatementArguments.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Adding arguments +

+
+
+
    +
  • +
    + + + + append(contentsOf:) + +
    +
    +
    +
    +
    +
    +

    Extends statement arguments with other arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    var arguments: StatementArguments = [1]
    +arguments.append(contentsOf: [2, 3])
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments.append(contentsOf: ["bar": 2])
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    Arguments that were replaced, if any, are returned:

    +
    var arguments: StatementArguments = ["foo": 1, "bar": 2]
    +let replacedValues = arguments.append(contentsOf: ["foo": 3])
    +print(arguments)
    +// Prints ["foo": 3, "bar": 2]
    +print(replacedValues)
    +// Prints ["foo": 1]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments.append(contentsOf: [2, 3])
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public mutating func append(contentsOf arguments: StatementArguments) -> [String : DatabaseValue]
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates a new StatementArguments by extending the left-hand size +arguments with the right-hand side arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    let arguments: StatementArguments = [1] + [2, 3]
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    let arguments: StatementArguments = ["foo": 1] + ["bar": 2]
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    let arguments: StatementArguments = ["foo": 1] + [2, 3]
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +

    If the arguments on the right-hand side has named parameters that are +already defined on the left, a fatal error is raised:

    +
    let arguments: StatementArguments = ["foo": 1] + ["foo": 2]
    +// fatal error: already defined statement argument: foo
    +
    + +

    This fatal error can be avoided with the &+ operator, or the +append(contentsOf:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func + (lhs: StatementArguments, rhs: StatementArguments) -> StatementArguments
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + &+(_:_:) + +
    +
    +
    +
    +
    +
    +

    Creates a new StatementArguments by extending the left-hand size +arguments with the right-hand side arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    let arguments: StatementArguments = [1] &+ [2, 3]
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    let arguments: StatementArguments = ["foo": 1] &+ ["bar": 2]
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    let arguments: StatementArguments = ["foo": 1] &+ [2, 3]
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +

    If a named arguments is defined in both arguments, the right-hand +side wins:

    +
    let arguments: StatementArguments = ["foo": 1] &+ ["foo": 2]
    +print(arguments)
    +// Prints ["foo": 2]
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func &+ (lhs: StatementArguments, rhs: StatementArguments) -> StatementArguments
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + +=(_:_:) + +
    +
    +
    +
    +
    +
    +

    Extends the left-hand size arguments with the right-hand side arguments.

    + +

    Positional arguments (provided as arrays) are concatenated:

    +
    var arguments: StatementArguments = [1]
    +arguments += [2, 3]
    +print(arguments)
    +// Prints [1, 2, 3]
    +
    + +

    Named arguments (provided as dictionaries) are updated:

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments += ["bar": 2]
    +print(arguments)
    +// Prints ["foo": 1, "bar": 2]
    +
    + +

    You can mix named and positional arguments (see documentation of +the StatementArguments type for more information about mixed arguments):

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments.append(contentsOf: [2, 3])
    +print(arguments)
    +// Prints ["foo": 1, 2, 3]
    +
    + +

    If the arguments on the right-hand side has named parameters that are +already defined on the left, a fatal error is raised:

    +
    var arguments: StatementArguments = ["foo": 1]
    +arguments += ["foo": 2]
    +// fatal error: already defined statement argument: foo
    +
    + +

    This fatal error can be avoided with the &+ operator, or the +append(contentsOf:) method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func += (lhs: inout StatementArguments, rhs: StatementArguments)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

StatementArguments +

+
+
+
    +
  • +
    + + + + init(arrayLiteral:) + +
    +
    +
    +
    +
    +
    +

    Returns a StatementArguments from an array literal:

    +
    let arguments: StatementArguments = ["Arthur", 41]
    +try db.execute(
    +    sql: "INSERT INTO player (name, score) VALUES (?, ?)"
    +    arguments: arguments)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(arrayLiteral elements: DatabaseValueConvertible?...)
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a StatementArguments from a dictionary literal:

    +
    let arguments: StatementArguments = ["name": "Arthur", "score": 41]
    +try db.execute(
    +    sql: "INSERT INTO player (name, score) VALUES (:name, :score)"
    +    arguments: arguments)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SuffixRowAdapter.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SuffixRowAdapter.html new file mode 100644 index 000000000..fe6aa7231 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/SuffixRowAdapter.html @@ -0,0 +1,1155 @@ + + + + SuffixRowAdapter Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

SuffixRowAdapter

+
+
+ +
public struct SuffixRowAdapter : RowAdapter
+ +
+
+

SuffixRowAdapter is a row adapter that hides the first columns in a row.

+
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)
+
+ + +
+
+
+
    +
  • +
    + + + + init(fromIndex:) + +
    +
    +
    +
    +
    +
    +

    Creates a SuffixRowAdapter that hides all columns before the +provided index.

    + +

    If index is 0, the layout row is identical to the base row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(fromIndex index: Int)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Table.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Table.html new file mode 100644 index 000000000..521012080 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/Table.html @@ -0,0 +1,6936 @@ + + + + Table Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Table

+
+
+ +
public struct Table<RowDecoder>
+
extension Table: DatabaseRegionConvertible
+ +
+
+

Table can build query interface requests.

+
// SELECT * FROM player WHERE score >= 1000
+let table = Table("player")
+let rows: [Row] = try dbQueue.read { db in
+    table.all()
+        .filter(Column("score") >= 1000)
+        .fetchAll(db)
+}
+
+ + +
+
+
+
    +
  • +
    + + + + tableName + +
    +
    +
    +
    +
    +
    +

    The table name

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var tableName: String
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Create a Table

    +
    let table = Table<Row>("player")
    +let table = Table<Player>("player")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ tableName: String)
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + databaseRegion(_:) + +
    +
    +
    +
    +
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func databaseRegion(_ db: Database) throws -> DatabaseRegion
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Request Derivation +

+
+
+
    +
  • +
    + + + + all() + +
    +
    +
    +
    +
    +
    +

    Creates a request for all rows of the table.

    +
    // Fetch all players
    +let table = Table<Player>("player")
    +let request = table.all()
    +let players: [Player] = try request.fetchAll(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func all() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + none() + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches no row.

    +
    // Fetch no players
    +let table = Table<Player>("player")
    +let request = table.none()
    +let players: [Player] = try request.fetchAll(db) // Empty array
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func none() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let table = Table("player")
    +let request = table.select(Column("id"), Column("email"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: SQLSelectable...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection.

    +
    // SELECT id, email FROM player
    +let table = Table("player")
    +let request = table.select([Column("id"), Column("email")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(_ selection: [SQLSelectable]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which selects sql.

    +
    // SELECT id, email FROM player
    +let table = Table("player")
    +let request = table.select(sql: "id, email")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT id, email, score + 1000 FROM player
    +let table = Table("player")
    +let bonus = 1000
    +let request = table.select(literal: """
    +    id, email, score + \(bonus)
    +    """)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select(literal sqlLiteral: SQL) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let table = Table("player")
    +    let request = table.select([max(Column("score"))], as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    _ selection: [SQLSelectable],
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(_:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects selection, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let table = Table("player")
    +    let request = table.select(max(Column("score")), as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    _ selection: SQLSelectable...,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which selects sql, and fetches values of +type type.

    +
    try dbQueue.read { db in
    +    // SELECT max(score) FROM player
    +    let table = Table("player")
    +    let request = table.select(sql: "max(score)", as: Int.self)
    +    let maxScore: Int? = try request.fetchOne(db)
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments(),
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + select(literal:as:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects an SQL literal, and fetches values of +type type.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +let table = Table("player")
    +let defaultName = "Anonymous"
    +let request = table.select(
    +    literal: "IFNULL(name, \(defaultName))",
    +    as: String.self)
    +let name: String? = try request.fetchOne(db)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func select<RowDecoder>(
    +    literal sqlLiteral: SQL,
    +    as type: RowDecoder.Type = RowDecoder.self)
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let table = Table("player")
    +let request = table
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: [Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which appends selection.

    +
    // SELECT id, email, name FROM player
    +let table = Table("player")
    +let request = table
    +    .select([Column("id"), Column("email")])
    +    .annotated(with: Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with selection: SQLSelectable...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let table = Table<Player>("player")
    +let request = table.filter(Column("email") == "arthur@example.com")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(_ predicate: SQLSpecificExpressible) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id = 1
    +let table = Table<Player>("player")
    +let request = table.filter(key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<PrimaryKeyType>(key: PrimaryKeyType?)
    +-> QueryInterfaceRequest<RowDecoder>
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let table = Table<Player>("player")
    +let request = table.filter(keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Sequence>(keys: Sequence)
    +-> QueryInterfaceRequest<RowDecoder>
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(key:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE personId = 1 AND countryCode = 'FR'
    +let table = Table<Passport>("passport")
    +let request = table.filter(key: ["personId": 1, "countryCode": "FR"])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(key: [String : DatabaseValueConvertible?]?) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(keys:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided primary key predicate.

    +
    // SELECT * FROM passport WHERE (personId = 1 AND countryCode = 'FR') OR ...
    +let table = Table<Passport>("passport")
    +let request = table.filter(keys: [["personId": 1, "countryCode": "FR"], ...])
    +
    + +

    When executed, this request raises a fatal error if there is no unique +index on the key columns.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(keys: [[String : DatabaseValueConvertible?]]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate.

    +
    // SELECT * FROM player WHERE email = 'arthur@example.com'
    +let table = Table<Player>("player")
    +let request = table.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(literal:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided predicate added to the +eventual set of already applied predicates.

    + +

    Literals allow you to safely embed raw values in your SQL, without any +risk of syntax errors or SQL injection:

    +
    // SELECT * FROM player WHERE name = 'O''Brien'
    +let table = Table<Player>("player")
    +let name = "O'Brien"
    +let request = table.filter(literal: "email = \(email)")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(literal sqlLiteral: SQL) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order(Column("name"))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: SQLOrderingTerm...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to the +provided orderings.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order([Column("name")])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(_ orderings: [SQLOrderingTerm]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + orderByPrimaryKey() + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted by primary key.

    +
    // SELECT * FROM player ORDER BY id
    +let table = Table<Player>("player")
    +let request = table.orderByPrimaryKey()
    +
    +// SELECT * FROM country ORDER BY code
    +let request = Country.orderByPrimaryKey()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func orderByPrimaryKey() -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(sql:arguments:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to sql.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order(sql: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(
    +    sql: String,
    +    arguments: StatementArguments = StatementArguments())
    +-> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + order(literal:) + +
    +
    +
    +
    +
    +
    +

    Creates a request sorted according to an SQL literal.

    +
    // SELECT * FROM player ORDER BY name
    +let table = Table<Player>("player")
    +let request = table.order(literal: "name")
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func order(literal sqlLiteral: SQL) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + limit(_:offset:) + +
    +
    +
    +
    +
    +
    +

    Creates a request which fetches limit rows, starting at +offset.

    +
    // SELECT * FROM player LIMIT 1
    +let table = Table<Player>("player")
    +let request = table.limit(1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func limit(_ limit: Int, offset: Int? = nil) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + aliased(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that allows you to define expressions that target +a specific database table.

    + +

    See TableRecord.aliased(_:) for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func aliased(_ alias: TableAlias) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + with(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a request which embeds the common table expression.

    + +

    See TableRecord.with(_:) for more information.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func with<T>(_ cte: CommonTableExpression<T>) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    A request.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Counting All +

+
+
+
    +
  • +
    + + + + fetchCount(_:) + +
    +
    +
    +
    +
    +
    +

    The number of rows.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCount(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to TableRecord +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +type, based on a database foreign key.

    + +

    For more information, see TableRecord.belongsTo(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func belongsTo<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination type, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasMany(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasMany<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination type, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasOne(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasOne<Destination>(
    +    _ destination: Destination.Type,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<RowDecoder, Destination>
    +where Destination: TableRecord
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to Table +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a “Belongs To” association between Self and the destination +table, based on a database foreign key.

    + +

    For more information, see TableRecord.belongsTo(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func belongsTo<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> BelongsToAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key to the destination table, or when the schema defines several +foreign keys to the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasMany(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has many” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasMany(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasMany<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasManyAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.tableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + hasOne(_:key:using:) + +
    +
    +
    +
    +
    +
    +

    Creates a “Has one” association between Self and the destination table, +based on a database foreign key.

    + +

    For more information, see TableRecord.hasOne(_:key:using:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasOne<Destination>(
    +    _ destination: Table<Destination>,
    +    key: String? = nil,
    +    using foreignKey: ForeignKey? = nil)
    +-> HasOneAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The table at the other side of the association.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is destination.databaseTableName.

    +
    +
    + + foreignKey + + +
    +

    An eventual foreign key. You need to provide an +explicit foreign key when GRDB can’t infer one from the database +schema. This happens when the schema does not define any foreign +key from the destination table, or when the schema defines several +foreign keys from the destination table.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Associations to CommonTableExpression +

+
+
+
    +
  • +
    + + + + association(to:on:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    For more information, see TableRecord.association(to:on:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>,
    +    on condition: @escaping (_ left: TableAlias, _ right: TableAlias) -> SQLExpressible)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    + + condition + + +
    +

    A function that returns the joining clause.

    +
    +
    + + left + + +
    +

    A TableAlias for the left table.

    +
    +
    + + right + + +
    +

    A TableAlias for the right table.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
  • +
    + + + + association(to:) + +
    +
    +
    +
    +
    +
    +

    Creates an association to a common table expression that you can join +or include in another request.

    + +

    The key of the returned association is the table name of the common +table expression.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func association<Destination>(
    +    to cte: CommonTableExpression<Destination>)
    +-> JoinAssociation<RowDecoder, Destination>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + cte + + +
    +

    A common table expression.

    +
    +
    +
    +
    +

    Return Value

    +

    An association to the common table expression.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

“Through” Associations +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a “Has Many Through” association between Self and the +destination type.

    + +

    For more information, see TableRecord.hasMany(_:through:using:key:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasMany<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasManyThroughAssociation<RowDecoder, Target.RowDecoder>
    +where Pivot: Association,
    +      Target: Association,
    +      Pivot.OriginRowDecoder == RowDecoder,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a “Has One Through” association between Self and the +destination type.

    + +

    For more information, see TableRecord.hasOne(_:through:using:key:).

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func hasOne<Pivot, Target>(
    +    _ destination: Target.RowDecoder.Type,
    +    through pivot: Pivot,
    +    using target: Target,
    +    key: String? = nil)
    +-> HasOneThroughAssociation<RowDecoder, Target.RowDecoder>
    +where Pivot: AssociationToOne,
    +      Target: AssociationToOne,
    +      Pivot.OriginRowDecoder == RowDecoder,
    +      Pivot.RowDecoder == Target.OriginRowDecoder
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + destination + + +
    +

    The record type at the other side of the association.

    +
    +
    + + pivot + + +
    +

    An association from Self to the intermediate type.

    +
    +
    + + target + + +
    +

    A target association from the intermediate type to the +destination type.

    +
    +
    + + key + + +
    +

    An eventual decoding key for the association. By default, it +is the same key as the target.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Joining Methods +

+
+
+
    +
  • +
    + + + + including(all:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that prefetches an association.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A: AssociationToMany>(all association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(optional:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + including(required:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func including<A: Association>(required association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(optional:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association does not +require that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A: Association>(optional association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + joining(required:) + +
    +
    +
    +
    +
    +
    +

    Creates a request that includes an association. The columns of the +associated record are not selected. The returned association requires +that the associated database table contains a matching row.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func joining<A: Association>(required association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the columns of the table.

    +
    let playerTable = Table("player")
    +let teamTable = Table("team")
    +let playerTeam = playerTable.belongsTo(teamTable)
    +
    +// SELECT player.*, team.color
    +// FROM player LEFT JOIN team ...
    +let teamColor = playerTeam.select(Column("color")
    +let request = playerTable.annotated(withOptional: teamColor))
    +
    + +

    This method performs the same SQL request as including(optional:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String?
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(optional:):

    +
    let teamAlias = TableAlias()
    +let request = playerTable
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(optional: playerTeam.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A: Association>(withOptional association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a request which appends columns of an associated record to +the columns of the table.

    +
    let playerTable = Table("player")
    +let teamTable = Table("team")
    +let playerTeam = playerTable.belongsTo(teamTable)
    +
    +// SELECT player.*, team.color
    +// FROM player JOIN team ...
    +let teamColor = playerTeam.select(Column("color")
    +let request = playerTable.annotated(withRequired: teamColor))
    +
    + +

    This method performs the same SQL request as including(required:). +The difference is in the shape of Decodable records that decode such +a request: the associated columns can be decoded at the same level as +the main record:

    +
    struct PlayerWithTeamColor: FetchableRecord, Decodable {
    +    var player: Player
    +    var color: String
    +}
    +let players = try dbQueue.read { db in
    +    try request
    +        .asRequest(of: PlayerWithTeamColor.self)
    +        .fetchAll(db)
    +}
    +
    + +

    Note: this is a convenience method. You can build the same request with +TableAlias, annotated(with:), and joining(required:):

    +
    let teamAlias = TableAlias()
    +let request = playerTable
    +    .annotated(with: teamAlias[Column("color")])
    +    .joining(required: playerTeam.aliased(teamAlias))
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated<A: Association>(withRequired association: A)
    +-> QueryInterfaceRequest<RowDecoder>
    +where A.OriginRowDecoder == RowDecoder
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Association Aggregates +

+
+
+
    +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let table = Table<Player>("player")
    +let request = table.annotated(with: Player.books.count)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: AssociationAggregate<RowDecoder>...) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + annotated(with:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with aggregates appended to the selection.

    +
    // SELECT player.*, COUNT(DISTINCT book.id) AS bookCount
    +// FROM player LEFT JOIN book ...
    +let table = Table<Player>("player")
    +let request = table.annotated(with: [Player.books.count])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + having(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a request with the provided aggregate predicate.

    +
    // SELECT player.*
    +// FROM player LEFT JOIN book ...
    +// HAVING COUNT(DISTINCT book.id) = 0
    +let table = Table<Player>("player")
    +var request = table.all()
    +request = request.having(Player.books.isEmpty)
    +
    + +

    The selection defaults to all columns. This default can be changed for +all requests by the TableRecord.databaseSelection property, or +for individual requests with the TableRecord.select method.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func having(_ predicate: AssociationAggregate<RowDecoder>) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Delete +

+
+
+
    +
  • +
    + + + + deleteAll(_:) + +
    +
    +
    +
    +
    +
    +

    Deletes all rows; returns the number of deleted rows.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll(_ db: Database) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Table("player").exists(db, key: 123)
    +try Table("country").exists(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Table("document").exists(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Check Existence by Key +

+
+
+
    +
  • +
    + + + + exists(_:key:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this unique key (primary key or any key +with a unique index on it).

    +
    Table("player").exists(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Single-Column Primary Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Table("player").deleteAll(db, keys: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Table("country").deleteAll(db, keys: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Table("document").deleteAll(db, keys: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll<Sequence>(_ db: Database, keys: Sequence)
    +throws -> Int
    +where Sequence: Swift.Sequence, Sequence.Element: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    A sequence of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Table("player").deleteOne(db, key: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Table("country").deleteOne(db, key: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Table("document").deleteOne(db, key: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne<PrimaryKeyType>(_ db: Database, key: PrimaryKeyType?)
    +throws -> Bool
    +where PrimaryKeyType: DatabaseValueConvertible
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Deleting by Key +

+
+
+
    +
  • +
    + + + + deleteAll(_:keys:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by the provided unique keys (primary key or +any key with a unique index on it); returns the number of deleted rows.

    +
    try Table("player").deleteAll(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll(_ db: Database, keys: [[String : DatabaseValueConvertible?]]) throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + keys + + +
    +

    An array of key dictionaries.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:key:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by a unique key (the primary key or any key +with a unique index on it); returns whether a database row was deleted.

    +
    Table("player").deleteOne(db, key: ["name": Arthur"])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne(_ db: Database, key: [String : DatabaseValueConvertible?]) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + key + + +
    +

    A dictionary of values.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Batch Update +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Updates all rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Table("player").updateAll(db, [Column("score").set(to: 0)])
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignments: [ColumnAssignment])
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignments + + +
    +

    An array of column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Updates all rows; returns the number of updated rows.

    + +

    For example:

    +
    try dbQueue.write { db in
    +    // UPDATE player SET score = 0
    +    try Table("player").updateAll(db, Column("score").set(to: 0))
    +}
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func updateAll(
    +    _ db: Database,
    +    onConflict conflictResolution: Database.ConflictResolution? = nil,
    +    _ assignment: ColumnAssignment,
    +    _ otherAssignments: ColumnAssignment...)
    +throws -> Int
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + conflictResolution + + +
    +

    A policy for conflict resolution.

    +
    +
    + + assignment + + +
    +

    A column assignment.

    +
    +
    + + otherAssignments + + +
    +

    Eventual other column assignments.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of updated rows.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • +
    + + + + init(_:) + +
    +
    +
    +
    +
    +
    +

    Create a Table of Row.

    +
    let table = Table("player") // Table<Row>
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(_ tableName: String)
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let table = Table<Player>("player")
    +let request = table.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let table = Table<Player>("player")
    +let request = table.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<RowDecoder>
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let table = Table("player")
    +let request = try table.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + filter(id:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id = 1
    +let table = Table<Player>("player")
    +let request = table.filter(id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter(id: RowDecoder.ID.Wrapped) -> QueryInterfaceRequest<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + id + + +
    +

    A primary key

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + filter(ids:) + +
    +
    +
    +
    +
    +
    +

    Creates a request filtered by primary key.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +let table = Table<Player>("player")
    +let request = table.filter(ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func filter<Collection>(ids: Collection)
    +-> QueryInterfaceRequest<RowDecoder>
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + ids + + +
    +

    A collection of primary keys

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + selectID() + +
    +
    +
    +
    +
    +
    +

    Creates a request which selects the primary key.

    +
    // SELECT id FROM player
    +let table = Table("player")
    +let request = try table.selectID()
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func selectID() -> QueryInterfaceRequest<RowDecoder.ID.Wrapped>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: FetchableRecord +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all records fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table<Player>("player")
    +let players = try table.fetchCursor(db) // Cursor of Player
    +while let player = try players.next() {  // Player
    +    ...
    +}
    +
    + +

    Records are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RecordCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all records fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table<Player>("player")
    +let players = try table.fetchAll(db) // [Player]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The first found record.

    +
    // SELECT * FROM player LIMIT 1
    +let table = Table<Player>("player")
    +let player = try table.fetchOne(db) // Player?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: FetchableRecord & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all records fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table<Player>("player")
    +let players = try table.fetchSet(db) // Set<Player>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder == Row +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all rows fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table("player")
    +let rows = try table.fetchCursor(db) // Cursor of Row
    +while let row = try rows.next() {    // Row
    +    ...
    +}
    +
    + +

    Rows are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> RowCursor
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all rows fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table("player")
    +let players = try table.fetchAll(db) // [Row]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [Row]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The first found row.

    +
    // SELECT * FROM player LIMIT 1
    +let table = Table("player")
    +let row = try table.fetchOne(db) // Row?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> Row?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all rows fetched from the database.

    +
    // SELECT * FROM player
    +let table = Table("player")
    +let rows = try table.fetchSet(db) // Set<Row>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<Row>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchCursor(db) // Cursor of String
    +while let name = try names.next() {   // String
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> DatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String>("name")
    +let name = try table.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchCursor(db) // Cursor of String?
    +while let name = try names.next() {   // String?
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> NullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String?>("name")
    +let name = try table.fetchOne(db) // String?
    +
    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchCursor(db) // Cursor of String
    +while let name = try names.next() {   // String
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastDatabaseValueCursor<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchAll(db) // [String]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String>("name")
    +let name = try table.fetchOne(db) // String?
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String>("name")
    +let names = try table.fetchSet(db) // Set<String>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & StatementColumnConvertible +

+
+
+
    +
  • +
    + + + + fetchCursor(_:) + +
    +
    +
    +
    +
    +
    +

    A cursor over all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchCursor(db) // Cursor of String?
    +while let name = try names.next() {   // String?
    +    ...
    +}
    +
    + +

    Values are iterated in the natural ordering of the table.

    + +

    If the database is modified during the cursor iteration, the remaining +elements are undefined.

    + +

    The cursor must be iterated in a protected dispatch queue.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchCursor(_ db: Database) throws -> FastNullableDatabaseValueCursor<RowDecoder.Wrapped>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    +
    +

    Return Value

    +

    A cursor over fetched records.

    +
    + +
    +
    +
  • +
  • +
    + + + + fetchAll(_:) + +
    +
    +
    +
    +
    +
    +

    An array of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchAll(db) // [String?]
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchAll(_ db: Database) throws -> [RowDecoder.Wrapped?]
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + fetchOne(_:) + +
    +
    +
    +
    +
    +
    +

    The value from the leftmost column of the first row.

    +
    // SELECT * FROM name LIMIT 1
    +let table = Table<String?>("name")
    +let name = try table.fetchOne(db) // String?
    +
    + +

    The result is nil if the query returns no row, or if no value can be +extracted from the first row.

    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchOne(_ db: Database) throws -> RowDecoder.Wrapped?
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: _OptionalProtocol, RowDecoder.Wrapped: DatabaseValueConvertible & StatementColumnConvertible & Hashable +

+
+
+
    +
  • +
    + + + + fetchSet(_:) + +
    +
    +
    +
    +
    +
    +

    A set of all values fetched from the leftmost column.

    +
    // SELECT * FROM name
    +let table = Table<String?>("name")
    +let names = try table.fetchSet(db) // Set<String?>
    +
    +
    +

    Throws

    + A DatabaseError is thrown whenever an SQLite error occurs. + +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func fetchSet(_ db: Database) throws -> Set<RowDecoder.Wrapped?>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Table<Player>("player").exists(db, id: 123)
    +try Table<Country>("player").exists(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Table<Document>("document").exists(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists(_ db: Database, id: RowDecoder.ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + exists(_:id:) + +
    +
    +
    +
    +
    +
    +

    Returns whether a row exists for this primary key.

    +
    try Table<Player>("player").exists(db, id: 123)
    +try Table<Country>("country").exists(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    try Table<Document>("document").exists(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func exists(_ db: Database, id: RowDecoder.ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a row exists for this primary key.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Table<Player>("player").deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Table<Country>("country").deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Table<Document>("document").deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Table<Player>("player").deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Table<Country>("country").deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Table<Document>("document").deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne(_ db: Database, id: RowDecoder.ID) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where RowDecoder: Identifiable, RowDecoder.ID: _OptionalProtocol, RowDecoder.ID.Wrapped: DatabaseValueConvertible +

+
+
+
    +
  • +
    + + + + deleteAll(_:ids:) + +
    +
    +
    +
    +
    +
    +

    Delete rows identified by their primary keys; returns the number of +deleted rows.

    +
    // DELETE FROM player WHERE id IN (1, 2, 3)
    +try Table<Player>("player").deleteAll(db, ids: [1, 2, 3])
    +
    +// DELETE FROM country WHERE code IN ('FR', 'US', 'DE')
    +try Table<Country>("country").deleteAll(db, ids: ["FR", "US", "DE"])
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid IN (1, 2, 3)
    +try Table<Document>("document").deleteAll(db, ids: [1, 2, 3])
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteAll<Collection>(_ db: Database, ids: Collection)
    +throws -> Int
    +where Collection: Swift.Collection, Collection.Element == RowDecoder.ID.Wrapped
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + ids + + +
    +

    A collection of primary keys.

    +
    +
    +
    +
    +

    Return Value

    +

    The number of deleted rows

    +
    + +
    +
    +
  • +
  • +
    + + + + deleteOne(_:id:) + +
    +
    +
    +
    +
    +
    +

    Delete a row, identified by its primary key; returns whether a +database row was deleted.

    +
    // DELETE FROM player WHERE id = 123
    +try Table<Player>("player").deleteOne(db, id: 123)
    +
    +// DELETE FROM country WHERE code = 'FR'
    +try Table<Country>("country").deleteOne(db, id: "FR")
    +
    + +

    When the table has no explicit primary key, GRDB uses the hidden +“rowid” column:

    +
    // DELETE FROM document WHERE rowid = 1
    +try Table<Document>("document").deleteOne(db, id: 1)
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @discardableResult
    +public func deleteOne(_ db: Database, id: RowDecoder.ID.Wrapped) throws -> Bool
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + db + + +
    +

    A database connection.

    +
    +
    + + id + + +
    +

    A primary key value.

    +
    +
    +
    +
    +

    Return Value

    +

    Whether a database row was deleted.

    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ValueObservation.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ValueObservation.html new file mode 100644 index 000000000..973e0949c --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Structs/ValueObservation.html @@ -0,0 +1,2281 @@ + + + + ValueObservation Structure Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

ValueObservation

+
+
+ +
public struct ValueObservation<Reducer> where Reducer : ValueReducer
+ +
+
+

ValueObservation tracks changes in the results of database requests, and +notifies fresh values whenever the database changes.

+ +

For example:

+
let observation = ValueObservation.tracking { db in
+    try Player.fetchAll(db)
+}
+
+let cancellable = try observation.start(
+    in: dbQueue,
+    onError: { error in ... },
+    onChange: { players: [Player] in
+        print("Players have changed.")
+    })
+
+ + +
+
+
+
    +
  • +
    + + + + requiresWriteAccess + +
    +
    +
    +
    +
    +
    +

    Default is false. Set this property to true when the observation +requires write access in order to fetch fresh values. Fetches are then +wrapped inside a savepoint.

    + +

    Don’t set this flag to true unless you really need it. A read/write +observation is less efficient than a read-only observation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var requiresWriteAccess: Bool
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Returns a shared value observation that shares a single underlying +database observation for all subscriptions, and thus spares +database resources.

    + +

    Experimental

    + +

    For example:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(in: dbQueue)
    +
    + +

    The sharing only applies if you start observing the database from the +same SharedValueObservation instance:

    +
    // NOT shared
    +let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
    +
    +// Shared
    +let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
    +let cancellable1 = sharedObservation.start(...)
    +let cancellable2 = sharedObservation.start(...)
    +
    + +

    By default, fresh values are dispatched asynchronously on the +main queue. You can change this behavior by providing a scheduler. +For example, .immediate notifies all values on the main queue as well, +and the first one is immediately notified when the start() method +is called:

    +
    let sharedObservation = ValueObservation
    +    .tracking { db in try Player.fetchAll(db) }
    +    .shared(
    +        in: dbQueue,
    +        scheduling: .immediate) // <-
    +
    +let cancellable = try sharedObservation.start(
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +// <- here "fresh players" is already printed.
    +
    + +

    Note that the .immediate scheduler requires that the observation is +subscribed from the main thread. It raises a fatal error otherwise.

    + +

    A shared observation starts observing the database as soon as it is +subscribed. You can choose if database observation should stop, or not, +when its number of subscriptions drops down to zero, with the extent +parameter. See SharedValueObservationExtent for available options.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func shared(
    +    in reader: DatabaseReader,
    +    scheduling scheduler: ValueObservationScheduler = .async(onQueue: .main),
    +    extent: SharedValueObservationExtent = .whileObserved)
    +-> SharedValueObservation<Reducer.Value>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseReader.

    +
    +
    + + scheduler + + +
    +

    A Scheduler. By default, fresh values are +dispatched asynchronously on the main queue.

    +
    +
    + + extent + + +
    +

    The extent of the shared database observation.

    +
    +
    +
    +
    +

    Return Value

    +

    A SharedValueObservation

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Starting Observation +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Starts the value observation in the provided database reader (such as +a database queue or database pool).

    + +

    The observation lasts until the returned cancellable is cancelled +or deallocated.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +
    + +

    By default, fresh values are dispatched asynchronously on the +main queue. You can change this behavior by providing a scheduler. +For example, .immediate notifies all values on the main queue as well, +and the first one is immediately notified when the start() method +is called:

    +
    let cancellable = try observation.start(
    +    in: dbQueue,
    +    scheduling: .immediate, // <-
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("fresh players: \(players)")
    +    })
    +// <- here "fresh players" is already printed.
    +
    + +

    Note that the .immediate scheduler requires that the observation is +subscribed from the main thread. It raises a fatal error otherwise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func start(
    +    in reader: DatabaseReader,
    +    scheduling scheduler: ValueObservationScheduler = .async(onQueue: .main),
    +    onError: @escaping (Error) -> Void,
    +    onChange: @escaping (Reducer.Value) -> Void) -> DatabaseCancellable
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseReader.

    +
    +
    + + scheduler + + +
    +

    A Scheduler. By default, fresh values are +dispatched asynchronously on the main queue.

    +
    +
    + + onError + + +
    +

    A closure that is provided eventual errors that +happen during observation

    +
    +
    + + onChange + + +
    +

    A closure that is provided fresh values

    +
    +
    +
    +
    +

    Return Value

    +

    a DatabaseCancellable

    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Debugging +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Performs the specified closures when ValueObservation events occur.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func handleEvents(
    +    willStart: (() -> Void)? = nil,
    +    willFetch: (() -> Void)? = nil,
    +    willTrackRegion: ((DatabaseRegion) -> Void)? = nil,
    +    databaseDidChange: (() -> Void)? = nil,
    +    didReceiveValue: ((Reducer.Value) -> Void)? = nil,
    +    didFail: ((Error) -> Void)? = nil,
    +    didCancel: (() -> Void)? = nil)
    +-> ValueObservation<ValueReducers.Trace<Reducer>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + willStart + + +
    +

    A closure that executes when the observation starts. +Defaults to nil.

    +
    +
    + + willFetch + + +
    +

    A closure that executes when the observed value is +about to be fetched. Defaults to nil.

    +
    +
    + + willTrackRegion + + +
    +

    A closure that executes when the observation +starts tracking a database region. Defaults to nil.

    +
    +
    + + databaseDidChange + + +
    +

    A closure that executes after the observation +was impacted by a database change. Defaults to nil.

    +
    +
    + + didReceiveValue + + +
    +

    A closure that executes on fresh values. Defaults +to nil.

    +
    +
    + + didFail + + +
    +

    A closure that executes when the observation fails. +Defaults to nil.

    +
    +
    + + didCancel + + +
    +

    A closure that executes when the observation is +cancelled. Defaults to nil.

    +
    +
    +
    +
    +

    Return Value

    +

    A ValueObservation that performs the specified closures +when ValueObservation events occur.

    +
    + +
    +
    +
  • +
  • +
    + + + + print(_:to:) + +
    +
    +
    +
    +
    +
    +

    Prints log messages for all ValueObservation events.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func print(
    +    _ prefix: String = "",
    +    to stream: TextOutputStream? = nil)
    +-> ValueObservation<ValueReducers.Trace<Reducer>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Publishing Observed Values +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates a publisher which tracks changes in database values.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +let cancellable = observation
    +    .publisher(in: dbQueue)
    +    .sink(
    +        receiveCompletion: { completion in ... },
    +        receiveValue: { players: [Player] in
    +            print("fresh players: \(players)")
    +        })
    +
    + +

    By default, fresh values are dispatched asynchronously on the +main queue. You can change this behavior by by providing a scheduler.

    + +

    For example, .immediate notifies all values on the main queue as well, +and the first one is immediately notified when the publisher +is subscribed:

    +
    let cancellable = observation
    +    .publisher(
    +        in: dbQueue,
    +        scheduling: .immediate) // <-
    +    .sink(
    +        receiveCompletion: { completion in ... },
    +        receiveValue: { players: [Player] in
    +            print("fresh players: \(players)")
    +        })
    +// <- here "fresh players" is already printed.
    +
    + +

    Note that the .immediate scheduler requires that the publisher is +subscribed from the main thread. It raises a fatal error otherwise.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
    +public func publisher(
    +    in reader: DatabaseReader,
    +    scheduling scheduler: ValueObservationScheduler = .async(onQueue: .main))
    +-> DatabasePublishers.Value<Reducer.Value>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + reader + + +
    +

    A DatabaseReader.

    +
    +
    + + scheduler + + +
    +

    A Scheduler. By default, fresh values are +dispatched asynchronously on the main queue.

    +
    +
    +
    +
    +

    Return Value

    +

    A Combine publisher

    +
    + +
    +
    +
  • +
  • +
    + + + + map(_:) + +
    +
    +
    +
    +
    +
    +

    Returns a ValueObservation which notifies the results of calling the +given transformation which each element notified by this +value observation.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func map<T>(_ transform: @escaping (Reducer.Value) -> T)
    +-> ValueObservation<ValueReducers.Map<Reducer, T>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Creating ValueObservation +

+
+
+
    +
  • + +
    +
    +
    +
    +
    +

    Creates an optimized ValueObservation that notifies the values +returned by the fetch function whenever a database transaction +changes them.

    + +

    The optimization only kicks in when the observation is started from a +DatabasePool: fresh values are fetched concurrently, and do not block +database writes.

    +
    +

    Precondition

    + The fetch function must perform requests that fetch +from a single and constant database region. The tracked region is made +of tables, columns, and, when possible, rowids of individual rows. All +changes that happen outside of this region do not impact +the observation. + +
    + +

    For example:

    +
    // Tracks the full 'player' table
    +let observation = ValueObservation.trackingConstantRegion { db -> [Player] in
    +    try Player.fetchAll(db)
    +}
    +
    +// Tracks the row with id 42 in the 'player' table
    +let observation = ValueObservation.trackingConstantRegion { db -> Player? in
    +    try Player.fetchOne(db, key: 42)
    +}
    +
    +// Tracks the 'score' column in the 'player' table
    +let observation = ValueObservation.trackingConstantRegion { db -> Int? in
    +    try Player.select(max(Column("score"))).fetchOne(db)
    +}
    +
    +// Tracks both the 'player' and 'team' tables
    +let observation = ValueObservation.trackingConstantRegion { db -> ([Team], [Player]) in
    +    let teams = try Team.fetchAll(db)
    +    let players = try Player.fetchAll(db)
    +    return (teams, players)
    +}
    +
    + +

    When you want to observe a varying database region, make sure you use +the ValueObservation.tracking(_:) method instead, or else some changes +will not be notified.

    + +

    For example, consider those three observations below that depend on some +user preference. They all track a varying region, and must +use ValueObservation.tracking(_:):

    +
    // Does not always track the same row in the player table.
    +let observation = ValueObservation.tracking { db -> Player? in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    return try Player.fetchOne(db, key: pref.favoritePlayerId)
    +}
    +
    +// Only tracks the 'user' table if there are some blocked emails.
    +let observation = ValueObservation.tracking { db -> [User] in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    let blockedEmails = pref.blockedEmails
    +    return try User.filter(blockedEmails.contains(Column("email"))).fetchAll(db)
    +}
    +
    +// Sometimes tracks the 'food' table, and sometimes the 'beverage' table.
    +let observation = ValueObservation.tracking { db -> Int in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    switch pref.selection {
    +    case .food: return try Food.fetchCount(db)
    +    case .beverage: return try Beverage.fetchCount(db)
    +    }
    +}
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func trackingConstantRegion<Value>(
    +    _ fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction has an impact on the +given regions.

    + +

    The tracked region is not automatically inferred from the requests +performed in the fetch function.

    + +

    For example:

    +
    // Tracks the full database
    +let observation = ValueObservation.tracking
    +    region: .fullDatabase,
    +    fetch: { db in ... })
    +
    +// Tracks the full 'player' table
    +let observation = ValueObservation.tracking
    +    region: Player.all(),
    +    fetch: { db in ... })
    +
    +// Tracks the row with id 42 in the 'player' table
    +let observation = ValueObservation.tracking
    +    region: Player.filter(id: 42),
    +    fetch: { db in ... })
    +
    +// Tracks the 'score' column in the 'player' table
    +let observation = ValueObservation.tracking
    +    region: Player.select(max(Column("score")),
    +    fetch: { db in ... })
    +
    +// Tracks both the 'player' and 'team' tables
    +let observation = ValueObservation.tracking
    +    region: Player.all(), Team.all(),
    +    fetch: { db in ... })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tracking<Value>(
    +    region: DatabaseRegionConvertible...,
    +    fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + region + + +
    +

    A list of observed regions.

    +
    +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction has an impact on the +given regions.

    + +

    The tracked region is not automatically inferred from the requests +performed in the fetch function.

    + +

    For example:

    +
    // Tracks the full database
    +let observation = ValueObservation.tracking
    +    regions: [.fullDatabase],
    +    fetch: { db in ... })
    +
    +// Tracks the full 'player' table
    +let observation = ValueObservation.tracking
    +    regions: [Player.all()],
    +    fetch: { db in ... })
    +
    +// Tracks the row with id 42 in the 'player' table
    +let observation = ValueObservation.tracking
    +    regions: [Player.filter(id: 42)],
    +    fetch: { db in ... })
    +
    +// Tracks the 'score' column in the 'player' table
    +let observation = ValueObservation.tracking
    +    regions: [Player.select(max(Column("score"))],
    +    fetch: { db in ... })
    +
    +// Tracks both the 'player' and 'team' tables
    +let observation = ValueObservation.tracking
    +    regions: [Player.all(), Team.all()],
    +    fetch: { db in ... })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tracking<Value>(
    +    regions: [DatabaseRegionConvertible],
    +    fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + regions + + +
    +

    A list of observed regions.

    +
    +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • +
    + + + + tracking(_:) + +
    +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction changes them.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func tracking<Value>(
    +    _ fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Creates a ValueObservation that notifies the values returned by the +fetch function whenever a database transaction changes them.

    + +

    For example:

    +
    let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +let cancellable = try observation.start(
    +    in: dbQueue,
    +    onError: { error in ... },
    +    onChange: { players: [Player] in
    +        print("Players have changed")
    +    })
    +
    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    @available(*, deprecated, renamed: "tracking(_:﹚")
    +public static func trackingVaryingRegion<Value>(
    +    _ fetch: @escaping (Database) throws -> Value)
    +-> ValueObservation<ValueReducers.Fetch<Value>>
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + fetch + + +
    +

    A function that fetches the observed value from +the database.

    +
    +
    +
    + +
    +
    +
  • +
+
+
+
+ + +
+ +

Available where Reducer.Value: Equatable +

+
+
+
    +
  • +
    + + + + removeDuplicates() + +
    +
    +
    +
    +
    +
    +

    Returns a ValueObservation which filters out consecutive equal values.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func removeDuplicates()
    +-> ValueObservation<ValueReducers.RemoveDuplicates<Reducer>>
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Typealiases.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Typealiases.html new file mode 100644 index 000000000..a306b3ce4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/Typealiases.html @@ -0,0 +1,1358 @@ + + + + Type Aliases Reference + + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+

Type Aliases

+

The following type aliases are available globally.

+ +
+
+
+
    +
  • +
    + + + + SQLiteConnection + +
    +
    +
    +
    +
    +
    +

    A raw SQLite connection, suitable for the SQLite C API.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLiteConnection = OpaquePointer
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLiteStatement + +
    +
    +
    +
    +
    +
    +

    A raw SQLite statement, suitable for the SQLite C API.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLiteStatement = OpaquePointer
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SelectStatement + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SelectStatement = Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + UpdateStatement + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias UpdateStatement = Statement
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + FTS5TokenCallback + +
    +
    +
    +
    +
    +
    +

    A low-level SQLite function that lets FTS5Tokenizer notify tokens.

    + +

    See FTS5Tokenizer.tokenize(context:flags:pText:nText:tokenCallback:)

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    A function that lets FTS5WrapperTokenizer notify tokens.

    + +

    See FTS5WrapperTokenizer.accept(token:flags:tokenCallback:)

    + +
    +
    +
    +
  • +
  • +
    + + + + SQLLiteral + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLLiteral = SQL
    + +
    +
    + +
    +
    +
  • +
  • +
    + + + + SQLiteral + +
    +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLiteral = SQL
    + +
    +
    + +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Undocumented

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public typealias SQLAssociativeBinaryOperator = SQLExpression.AssociativeBinaryOperator
    + +
    +
    + +
    +
    +
  • +
+
+
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/css/highlight.css b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/css/highlight.css new file mode 100644 index 000000000..c170357ce --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/css/highlight.css @@ -0,0 +1,202 @@ +/*! Jazzy - https://github.com/realm/jazzy + * Copyright Realm Inc. + * SPDX-License-Identifier: MIT + */ +/* Credit to https://gist.github.com/wataru420/2048287 */ +.highlight .c { + color: #999988; + font-style: italic; } + +.highlight .err { + color: #a61717; + background-color: #e3d2d2; } + +.highlight .k { + color: #000000; + font-weight: bold; } + +.highlight .o { + color: #000000; + font-weight: bold; } + +.highlight .cm { + color: #999988; + font-style: italic; } + +.highlight .cp { + color: #999999; + font-weight: bold; } + +.highlight .c1 { + color: #999988; + font-style: italic; } + +.highlight .cs { + color: #999999; + font-weight: bold; + font-style: italic; } + +.highlight .gd { + color: #000000; + background-color: #ffdddd; } + +.highlight .gd .x { + color: #000000; + background-color: #ffaaaa; } + +.highlight .ge { + color: #000000; + font-style: italic; } + +.highlight .gr { + color: #aa0000; } + +.highlight .gh { + color: #999999; } + +.highlight .gi { + color: #000000; + background-color: #ddffdd; } + +.highlight .gi .x { + color: #000000; + background-color: #aaffaa; } + +.highlight .go { + color: #888888; } + +.highlight .gp { + color: #555555; } + +.highlight .gs { + font-weight: bold; } + +.highlight .gu { + color: #aaaaaa; } + +.highlight .gt { + color: #aa0000; } + +.highlight .kc { + color: #000000; + font-weight: bold; } + +.highlight .kd { + color: #000000; + font-weight: bold; } + +.highlight .kp { + color: #000000; + font-weight: bold; } + +.highlight .kr { + color: #000000; + font-weight: bold; } + +.highlight .kt { + color: #445588; } + +.highlight .m { + color: #009999; } + +.highlight .s { + color: #d14; } + +.highlight .na { + color: #008080; } + +.highlight .nb { + color: #0086B3; } + +.highlight .nc { + color: #445588; + font-weight: bold; } + +.highlight .no { + color: #008080; } + +.highlight .ni { + color: #800080; } + +.highlight .ne { + color: #990000; + font-weight: bold; } + +.highlight .nf { + color: #990000; } + +.highlight .nn { + color: #555555; } + +.highlight .nt { + color: #000080; } + +.highlight .nv { + color: #008080; } + +.highlight .ow { + color: #000000; + font-weight: bold; } + +.highlight .w { + color: #bbbbbb; } + +.highlight .mf { + color: #009999; } + +.highlight .mh { + color: #009999; } + +.highlight .mi { + color: #009999; } + +.highlight .mo { + color: #009999; } + +.highlight .sb { + color: #d14; } + +.highlight .sc { + color: #d14; } + +.highlight .sd { + color: #d14; } + +.highlight .s2 { + color: #d14; } + +.highlight .se { + color: #d14; } + +.highlight .sh { + color: #d14; } + +.highlight .si { + color: #d14; } + +.highlight .sx { + color: #d14; } + +.highlight .sr { + color: #009926; } + +.highlight .s1 { + color: #d14; } + +.highlight .ss { + color: #990073; } + +.highlight .bp { + color: #999999; } + +.highlight .vc { + color: #008080; } + +.highlight .vg { + color: #008080; } + +.highlight .vi { + color: #008080; } + +.highlight .il { + color: #009999; } diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/css/jazzy.css b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/css/jazzy.css new file mode 100644 index 000000000..2e3871391 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/css/jazzy.css @@ -0,0 +1,439 @@ +/*! Jazzy - https://github.com/realm/jazzy + * Copyright Realm Inc. + * SPDX-License-Identifier: MIT + */ +html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td { + background: transparent; + border: 0; + margin: 0; + outline: 0; + padding: 0; + vertical-align: baseline; } + +body { + background-color: #f2f2f2; + font-family: Helvetica, freesans, Arial, sans-serif; + font-size: 14px; + -webkit-font-smoothing: subpixel-antialiased; + word-wrap: break-word; } + +h1, h2, h3 { + margin-top: 0.8em; + margin-bottom: 0.3em; + font-weight: 100; + color: black; } + +h1 { + font-size: 2.5em; } + +h2 { + font-size: 2em; + border-bottom: 1px solid #e2e2e2; } + +h4 { + font-size: 13px; + line-height: 1.5; + margin-top: 21px; } + +h5 { + font-size: 1.1em; } + +h6 { + font-size: 1.1em; + color: #777; } + +.section-name { + color: gray; + display: block; + font-family: Helvetica; + font-size: 22px; + font-weight: 100; + margin-bottom: 15px; } + +pre, code { + font: 0.95em Menlo, monospace; + color: #777; + word-wrap: normal; } + +p code, li code { + background-color: #eee; + padding: 2px 4px; + border-radius: 4px; } + +pre > code { + padding: 0; } + +a { + color: #0088cc; + text-decoration: none; } + a code { + color: inherit; } + +ul { + padding-left: 15px; } + +li { + line-height: 1.8em; } + +img { + max-width: 100%; } + +blockquote { + margin-left: 0; + padding: 0 10px; + border-left: 4px solid #ccc; } + +hr { + height: 1px; + border: none; + background-color: #e2e2e2; } + +.footnote-ref { + display: inline-block; + scroll-margin-top: 70px; } + +.footnote-def { + scroll-margin-top: 70px; } + +.content-wrapper { + margin: 0 auto; + width: 980px; } + +header { + font-size: 0.85em; + line-height: 32px; + background-color: #414141; + position: fixed; + width: 100%; + z-index: 3; } + header img { + padding-right: 6px; + vertical-align: -3px; + height: 16px; } + header a { + color: #fff; } + header p { + float: left; + color: #999; } + header .header-right { + float: right; + margin-left: 16px; } + +#breadcrumbs { + background-color: #f2f2f2; + height: 21px; + padding-top: 17px; + position: fixed; + width: 100%; + z-index: 2; + margin-top: 32px; } + #breadcrumbs #carat { + height: 10px; + margin: 0 5px; } + +.sidebar { + background-color: #f9f9f9; + border: 1px solid #e2e2e2; + overflow-y: auto; + overflow-x: hidden; + position: fixed; + top: 70px; + bottom: 0; + width: 230px; + word-wrap: normal; } + +.nav-groups { + list-style-type: none; + background: #fff; + padding-left: 0; } + +.nav-group-name { + border-bottom: 1px solid #e2e2e2; + font-size: 1.1em; + font-weight: 100; + padding: 15px 0 15px 20px; } + .nav-group-name > a { + color: #333; } + +.nav-group-tasks { + margin-top: 5px; } + +.nav-group-task { + font-size: 0.9em; + list-style-type: none; + white-space: nowrap; } + .nav-group-task a { + color: #888; } + +.main-content { + background-color: #fff; + border: 1px solid #e2e2e2; + margin-left: 246px; + position: absolute; + overflow: hidden; + padding-bottom: 20px; + top: 70px; + width: 734px; } + .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote { + margin-bottom: 1em; } + .main-content p { + line-height: 1.8em; } + .main-content section .section:first-child { + margin-top: 0; + padding-top: 0; } + .main-content section .task-group-section .task-group:first-of-type { + padding-top: 10px; } + .main-content section .task-group-section .task-group:first-of-type .section-name { + padding-top: 15px; } + .main-content section .heading:before { + content: ""; + display: block; + padding-top: 70px; + margin: -70px 0 0; } + .main-content .section-name p { + margin-bottom: inherit; + line-height: inherit; } + .main-content .section-name code { + background-color: inherit; + padding: inherit; + color: inherit; } + +.section { + padding: 0 25px; } + +.highlight { + background-color: #eee; + padding: 10px 12px; + border: 1px solid #e2e2e2; + border-radius: 4px; + overflow-x: auto; } + +.declaration .highlight { + overflow-x: initial; + padding: 0 40px 40px 0; + margin-bottom: -25px; + background-color: transparent; + border: none; } + +.section-name { + margin: 0; + margin-left: 18px; } + +.task-group-section { + margin-top: 10px; + padding-left: 6px; + border-top: 1px solid #e2e2e2; } + +.task-group { + padding-top: 0px; } + +.task-name-container a[name]:before { + content: ""; + display: block; + padding-top: 70px; + margin: -70px 0 0; } + +.section-name-container { + position: relative; + display: inline-block; } + .section-name-container .section-name-link { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + margin-bottom: 0; } + .section-name-container .section-name { + position: relative; + pointer-events: none; + z-index: 1; } + .section-name-container .section-name a { + pointer-events: auto; } + +.item { + padding-top: 8px; + width: 100%; + list-style-type: none; } + .item a[name]:before { + content: ""; + display: block; + padding-top: 70px; + margin: -70px 0 0; } + .item code { + background-color: transparent; + padding: 0; } + .item .token, .item .direct-link { + display: inline-block; + text-indent: -20px; + padding-left: 3px; + margin-left: 35px; + font-size: 11.9px; + transition: all 300ms; } + .item .token-open { + margin-left: 20px; } + .item .discouraged { + text-decoration: line-through; } + .item .declaration-note { + font-size: .85em; + color: gray; + font-style: italic; } + +.pointer-container { + border-bottom: 1px solid #e2e2e2; + left: -23px; + padding-bottom: 13px; + position: relative; + width: 110%; } + +.pointer { + background: #f9f9f9; + border-left: 1px solid #e2e2e2; + border-top: 1px solid #e2e2e2; + height: 12px; + left: 21px; + top: -7px; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + position: absolute; + width: 12px; } + +.height-container { + display: none; + left: -25px; + padding: 0 25px; + position: relative; + width: 100%; + overflow: hidden; } + .height-container .section { + background: #f9f9f9; + border-bottom: 1px solid #e2e2e2; + left: -25px; + position: relative; + width: 100%; + padding-top: 10px; + padding-bottom: 5px; } + +.aside, .language { + padding: 6px 12px; + margin: 12px 0; + border-left: 5px solid #dddddd; + overflow-y: hidden; } + .aside .aside-title, .language .aside-title { + font-size: 9px; + letter-spacing: 2px; + text-transform: uppercase; + padding-bottom: 0; + margin: 0; + color: #aaa; + -webkit-user-select: none; } + .aside p:last-child, .language p:last-child { + margin-bottom: 0; } + +.language { + border-left: 5px solid #cde9f4; } + .language .aside-title { + color: #4b8afb; } + +.aside-warning, .aside-deprecated, .aside-unavailable { + border-left: 5px solid #ff6666; } + .aside-warning .aside-title, .aside-deprecated .aside-title, .aside-unavailable .aside-title { + color: #ff0000; } + +.graybox { + border-collapse: collapse; + width: 100%; } + .graybox p { + margin: 0; + word-break: break-word; + min-width: 50px; } + .graybox td { + border: 1px solid #e2e2e2; + padding: 5px 25px 5px 10px; + vertical-align: middle; } + .graybox tr td:first-of-type { + text-align: right; + padding: 7px; + vertical-align: top; + word-break: normal; + width: 40px; } + +.slightly-smaller { + font-size: 0.9em; } + +#footer { + position: relative; + top: 10px; + bottom: 0px; + margin-left: 25px; } + #footer p { + margin: 0; + color: #aaa; + font-size: 0.8em; } + +html.dash header, html.dash #breadcrumbs, html.dash .sidebar { + display: none; } + +html.dash .main-content { + width: 980px; + margin-left: 0; + border: none; + width: 100%; + top: 0; + padding-bottom: 0; } + +html.dash .height-container { + display: block; } + +html.dash .item .token { + margin-left: 0; } + +html.dash .content-wrapper { + width: auto; } + +html.dash #footer { + position: static; } + +form[role=search] { + float: right; } + form[role=search] input { + font: Helvetica, freesans, Arial, sans-serif; + margin-top: 6px; + font-size: 13px; + line-height: 20px; + padding: 0px 10px; + border: none; + border-radius: 1em; } + .loading form[role=search] input { + background: white url(../img/spinner.gif) center right 4px no-repeat; } + form[role=search] .tt-menu { + margin: 0; + min-width: 300px; + background: #fff; + color: #333; + border: 1px solid #e2e2e2; + z-index: 4; } + form[role=search] .tt-highlight { + font-weight: bold; } + form[role=search] .tt-suggestion { + font: Helvetica, freesans, Arial, sans-serif; + font-size: 14px; + padding: 0 8px; } + form[role=search] .tt-suggestion span { + display: table-cell; + white-space: nowrap; } + form[role=search] .tt-suggestion .doc-parent-name { + width: 100%; + text-align: right; + font-weight: normal; + font-size: 0.9em; + padding-left: 16px; } + form[role=search] .tt-suggestion:hover, + form[role=search] .tt-suggestion.tt-cursor { + cursor: pointer; + background-color: #4183c4; + color: #fff; } + form[role=search] .tt-suggestion:hover .doc-parent-name, + form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { + color: #fff; } diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/carat.png b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/carat.png new file mode 100755 index 000000000..29d2f7fd4 Binary files /dev/null and b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/carat.png differ diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/dash.png b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/dash.png new file mode 100755 index 000000000..6f694c7a0 Binary files /dev/null and b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/dash.png differ diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/gh.png b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/gh.png new file mode 100755 index 000000000..628da97c7 Binary files /dev/null and b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/gh.png differ diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/spinner.gif b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/spinner.gif new file mode 100644 index 000000000..e3038d0a4 Binary files /dev/null and b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/img/spinner.gif differ diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/index.html b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/index.html new file mode 100644 index 000000000..4ff725ea4 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/index.html @@ -0,0 +1,8761 @@ + + + + GRDB Reference + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+ +

GRDB: A toolkit for SQLite databases, with a focus on application development

+ +

A toolkit for SQLite databases, with a focus on application development

+ +

+ Swift 5.3 + Platforms + License + CI Status +

+ +
+ +

Latest release: December 5, 2021 • version 5.16.0 • CHANGELOG • Migrating From GRDB 4 to GRDB 5

+ +

Requirements: iOS 11.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ • SQLite 3.8.5+ • Swift 5.3+ / Xcode 12+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Swift versionGRDB version
Swift 5.3+v5.16.0
Swift 5.2v5.12.0
Swift 5.1v4.14.0
Swift 5v4.14.0
Swift 4.2v4.14.0
Swift 4.1v3.7.0
Swift 4v2.10.0
Swift 3.2v1.3.0
Swift 3.1v1.3.0
Swift 3v1.0
Swift 2.3v0.81.2
Swift 2.2v0.80.2
+ +

Contact:

+ + +

What is this?

+ +

GRDB provides raw access to SQL and advanced SQLite features, because one sometimes enjoys a sharp tool. It has robust concurrency primitives, so that multi-threaded applications can efficiently use their databases. It grants your application models with persistence and fetching methods, so that you don’t have to deal with SQL and raw database rows when you don’t want to.

+ +

Compared to SQLite.swift or FMDB, GRDB can spare you a lot of glue code. Compared to Core Data or Realm, it can simplify your multi-threaded applications.

+ +

It comes with up-to-date documentation, general guides, and it is fast.

+ +

See Why Adopt GRDB? if you are looking for your favorite database library.

+ +
+ +

+ Features • + Usage • + Installation • + Documentation • + FAQ +

+ +
+

Features

+ +

GRDB ships with:

+ + +

Usage

+ +
+ Start using the database in four easy steps + +“`swift +import GRDB + +// 1. Open a database connection +let dbQueue = try DatabaseQueue(path: ”/path/to/database.sqlite") + +// 2. Define the database schema +try dbQueue.write { db in + try db.create(table: “player”) { t in + t.autoIncrementedPrimaryKey(“id”) + t.column(“name”, .text).notNull() + t.column(“score”, .integer).notNull() + } +} + +// 3. Define a record type +struct Player: Codable, FetchableRecord, PersistableRecord { + var id: Int64 + var name: String + var score: Int +} + +// 4. Access the database +try dbQueue.write { db in + try Player(id: 1, name: “Arthur”, score: 100).insert(db) + try Player(id: 2, name: “Barbara”, score: 1000).insert(db) +} + +let players: [Player] = try dbQueue.read { db in + try Player.fetchAll(db) +} +“` + +
+ +
+ Activate the WAL mode + +”`swift +import GRDB + +// Simple database connection +let dbQueue = try DatabaseQueue(path: “/path/to/database.sqlite”) + +// Enhanced multithreading based on SQLite’s WAL mode +let dbPool = try DatabasePool(path: “/path/to/database.sqlite”) +“` + +See [Database Connections](#database-connections) + +
+ +
+ Access to raw SQL + +”`swift +try dbQueue.write { db in + try db.execute(sql: “”“ + CREATE TABLE place ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + favorite BOOLEAN NOT NULL DEFAULT 0, + latitude DOUBLE NOT NULL, + longitude DOUBLE NOT NULL) + ”“”) + + try db.execute(sql: “”“ + INSERT INTO place (title, favorite, latitude, longitude) + VALUES (?, ?, ?, ?) + ”“”, arguments: [“Paris”, true, 48.85341, 2.3488]) + + let parisId = db.lastInsertedRowID + + // Avoid SQL injection with SQL interpolation + try db.execute(literal: “”“ + INSERT INTO place (title, favorite, latitude, longitude) + VALUES (\("King’s Cross”), \(true), \(51.52151), \(-0.12763)) + “”“) +} +”` + +See [Executing Updates](#executing-updates) + +
+ +
+ Access to raw database rows and values + +“`swift +try dbQueue.read { db in + // Fetch database rows + let rows = try Row.fetchCursor(db, sql: "SELECT * FROM place”) + while let row = try rows.next() { + let title: String = row[“title”] + let isFavorite: Bool = row[“favorite”] + let coordinate = CLLocationCoordinate2D( + latitude: row[“latitude”], + longitude: row[“longitude”]) + } + + // Fetch values + let placeCount = try Int.fetchOne(db, sql: “SELECT COUNT(*) FROM place”)! // Int + let placeTitles = try String.fetchAll(db, sql: “SELECT title FROM place”) // [String] +} + +let placeCount = try dbQueue.read { db in + try Int.fetchOne(db, sql: “SELECT COUNT(*) FROM place”)! +} +“` + +See [Fetch Queries](#fetch-queries) + +
+ +
+ Database model types aka "records” + +“`swift +struct Place { + var id: Int64? + var title: String + var isFavorite: Bool + var coordinate: CLLocationCoordinate2D +} + +// snip: turn Place into a "record” by adopting the protocols that +// provide fetching and persistence methods. + +try dbQueue.write { db in + // Create database table + try db.create(table: “place”) { t in + t.autoIncrementedPrimaryKey(“id”) + t.column(“title”, .text).notNull() + t.column(“favorite”, .boolean).notNull().defaults(to: false) + t.column(“longitude”, .double).notNull() + t.column(“latitude”, .double).notNull() + } + + var berlin = Place( + id: nil, + title: “Berlin”, + isFavorite: false, + coordinate: CLLocationCoordinate2D(latitude: 52.52437, longitude: 13.41053)) + + try berlin.insert(db) + berlin.id // some value + + berlin.isFavorite = true + try berlin.update(db) +} +“` + +See [Records](#records) + +
+ +
+ Query the database with the Swift query interface + +”`swift +try dbQueue.read { db in + // Place? + let paris = try Place.fetchOne(db, id: 1) + + // Place? + let berlin = try Place.filter(Column(“title”) == “Berlin”).fetchOne(db) + + // [Place] + let favoritePlaces = try Place + .filter(Column(“favorite”) == true) + .order(Column(“title”)) + .fetchAll(db) + + // Int + let favoriteCount = try Place.filter(Column(“favorite”)).fetchCount(db) + + // SQL is always welcome + let places = try Place.fetchAll(db, sql: “SELECT * FROM place”) +} +“` + +See the [Query Interface](#the-query-interface) + +
+ +
+ Database changes notifications + +”`swift +// Define the observed value +let observation = ValueObservation.tracking { db in + try Place.fetchAll(db) +} + +// Start observation +let cancellable = observation.start( + in: dbQueue, + onError: { error in … } + onChange: { (places: [Place]) in print(“Fresh places: \(places)”) }) +“` + +Ready-made support for Combine and RxSwift: + +”`swift +// Combine +let cancellable = observation.publisher(in: dbQueue).sink( + receiveCompletion: { completion in … }, + receiveValue: { (places: [Place]) in print(“Fresh places: \(places)”) }) + +// RxSwift +let disposable = observation.rx.observe(in: dbQueue).subscribe( + onNext: { (places: [Place]) in print(“Fresh places: \(places)”) }, + onError: { error in … }) +“` + +See [Database Observation], [Combine Support], [RxGRDB]. + +
+

Documentation

+ +

GRDB runs on top of SQLite: you should get familiar with the SQLite FAQ. For general and detailed information, jump to the SQLite Documentation.

+

Demo Applications & Frequently Asked Questions

+ + +

Reference

+ + +

Getting Started

+ + +

SQLite and SQL

+ + +

Records and the Query Interface

+ + +

Application Tools

+ + +

Good to Know

+ + +

General Guides & Good Practices

+ + + +

FAQ

+ +

Sample Code

+

Installation

+ +

The installation procedures below have GRDB use the version of SQLite that ships with the target operating system.

+ +

See Encryption for the installation procedure of GRDB with SQLCipher.

+ +

See Custom SQLite builds for the installation procedure of GRDB with a customized build of SQLite.

+ +

See Enabling FTS5 Support for the installation procedure of GRDB with support for the FTS5 full-text engine.

+

CocoaPods

+ +

CocoaPods is a dependency manager for Xcode projects. To use GRDB with CocoaPods (version 1.2 or higher), specify in your Podfile:

+
pod 'GRDB.swift'
+
+ +

GRDB can be installed as a framework, or a static library.

+

Swift Package Manager

+ +

The Swift Package Manager automates the distribution of Swift code. To use GRDB with SPM, add a dependency to https://github.com/groue/GRDB.swift.git

+ +
+

:point_up: Note: Linux is not currently supported.

+ +

:warning: Warning: Due to an Xcode bug, you will get “No such module ‘CSQLite’” errors when you want to embed the GRDB package in other targets than the main application (watch extensions, for example). UI and Unit testing targets are OK, though. See #642 for more information.

+
+

Carthage

+ +

Carthage is unsupported. For some context about this decision, see #433.

+

Manually

+ +
    +
  1. Download a copy of GRDB, or clone its repository and make sure you checkout the latest tagged version.

  2. +
  3. Embed the GRDB.xcodeproj project in your own project.

  4. +
  5. Add the GRDBOSX, GRDBiOS, GRDBtvOS, or GRDBWatchOS target in the Target Dependencies section of the Build Phases tab of your application target (extension target for WatchOS).

  6. +
  7. Add the GRDB.framework from the targeted platform to the Embedded Binaries section of the General tab of your application target (extension target for WatchOS).

  8. +
+ +
+

:bulb: Tip: see the Demo Applications for examples of such integration.

+
+

Database Connections

+ +

GRDB provides two classes for accessing SQLite databases: DatabaseQueue and DatabasePool:

+
import GRDB
+
+// Pick one:
+let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
+let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
+
+ +

The differences are:

+ +
    +
  • Database pools allow concurrent database accesses (this can improve the performance of multithreaded applications).
  • +
  • Database pools open your SQLite database in the WAL mode (unless read-only).
  • +
  • Database queues support in-memory databases.
  • +
+ +

If you are not sure, choose DatabaseQueue. You will always be able to switch to DatabasePool later.

+ + +

Database Queues

+ +

Open a database queue with the path to a database file:

+
import GRDB
+
+let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
+let inMemoryDBQueue = DatabaseQueue()
+
+ +

SQLite creates the database file if it does not already exist. The connection is closed when the database queue gets deinitialized.

+ +

A database queue can be used from any thread. The write and read methods are synchronous, and block the current thread until your database statements are executed in a protected dispatch queue:

+
// Modify the database:
+try dbQueue.write { db in
+    try db.create(table: "place") { ... }
+    try Place(...).insert(db)
+}
+
+// Read values:
+try dbQueue.read { db in
+    let places = try Place.fetchAll(db)
+    let placeCount = try Place.fetchCount(db)
+}
+
+ +

Database access methods can return values:

+
let placeCount = try dbQueue.read { db in
+    try Place.fetchCount(db)
+}
+
+let newPlaceCount = try dbQueue.write { db -> Int in
+    try Place(...).insert(db)
+    return try Place.fetchCount(db)
+}
+
+ +

A database queue serializes accesses to the database, which means that there is never more than one thread that uses the database.

+ +
    +
  • When you don’t need to modify the database, prefer the read method. It prevents any modification to the database.

  • +
  • The write method wraps your database statements in a transaction that commits if and only if no error occurs. On the first unhandled error, all changes are reverted, the whole transaction is rollbacked, and the error is rethrown.

    + +

    When precise transaction handling is required, see Transactions and Savepoints.

  • +
+ +

A database queue needs your application to follow rules in order to deliver its safety guarantees. Please refer to the Concurrency guide.

+ +
+

:bulb: Tip: see the Demo Applications for sample code that sets up a database queue on iOS.

+
+

DatabaseQueue Configuration

+
var config = Configuration()
+config.readonly = true
+config.foreignKeysEnabled = true // Default is already true
+config.label = "MyDatabase"      // Useful when your app opens multiple databases
+
+let dbQueue = try DatabaseQueue(
+    path: "/path/to/database.sqlite",
+    configuration: config)
+
+ +

See Configuration for more details.

+

Database Pools

+ +

A database pool allows concurrent database accesses.

+
import GRDB
+let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
+
+ +

SQLite creates the database file if it does not already exist. The connection is closed when the database pool gets deinitialized.

+ +
+

:point_up: Note: unless read-only, a database pool opens your database in the SQLite “WAL mode”. The WAL mode does not fit all situations. Please have a look at https://www.sqlite.org/wal.html.

+
+ +

A database pool can be used from any thread. The write and read methods are synchronous, and block the current thread until your database statements are executed in a protected dispatch queue:

+
// Modify the database:
+try dbPool.write { db in
+    try db.create(table: "place") { ... }
+    try Place(...).insert(db)
+}
+
+// Read values:
+try dbPool.read { db in
+    let places = try Place.fetchAll(db)
+    let placeCount = try Place.fetchCount(db)
+}
+
+ +

Database access methods can return values:

+
let placeCount = try dbPool.read { db in
+    try Place.fetchCount(db)
+}
+
+let newPlaceCount = try dbPool.write { db -> Int in
+    try Place(...).insert(db)
+    return try Place.fetchCount(db)
+}
+
+ +

Database pools allow several threads to access the database at the same time:

+ +
    +
  • When you don’t need to modify the database, prefer the read method, because several threads can perform reads in parallel.

    + +

    Reads are generally non-blocking, unless the maximum number of concurrent reads has been reached. In this case, a read has to wait for another read to complete. That maximum number can be configured.

  • +
  • Reads are guaranteed an immutable view of the last committed state of the database, regardless of concurrent writes. This kind of isolation is called snapshot isolation.

  • +
  • Unlike reads, writes are serialized. There is never more than a single thread that is writing into the database.

  • +
  • The write method wraps your database statements in a transaction that commits if and only if no error occurs. On the first unhandled error, all changes are reverted, the whole transaction is rollbacked, and the error is rethrown.

    + +

    When precise transaction handling is required, see Transactions and Savepoints.

  • +
  • Database pools can take snapshots of the database.

  • +
+ +

A database pool needs your application to follow rules in order to deliver its safety guarantees. See the Concurrency guide for more details about database pools, how they differ from database queues, and advanced use cases.

+ +
+

:bulb: Tip: see the Demo Applications for sample code that sets up a database queue on iOS, and just replace DatabaseQueue with DatabasePool.

+
+

DatabasePool Configuration

+
var config = Configuration()
+config.readonly = true
+config.foreignKeysEnabled = true // Default is already true
+config.label = "MyDatabase"      // Useful when your app opens multiple databases
+config.maximumReaderCount = 10   // The default is 5
+
+let dbPool = try DatabasePool(
+    path: "/path/to/database.sqlite",
+    configuration: config)
+
+ +

See Configuration for more details.

+ +

Database pools are more memory-hungry than database queues. See Memory Management for more information.

+

SQLite API

+ +

In this section of the documentation, we will talk SQL. Jump to the query interface if SQL is not your cup of tea.

+ + + +

Advanced topics:

+ + +

Executing Updates

+ +

Once granted with a database connection, the execute method executes the SQL statements that do not return any database row, such as CREATE TABLE, INSERT, DELETE, ALTER, etc.

+ +

For example:

+
try dbQueue.write { db in
+    try db.execute(sql: """
+        CREATE TABLE player (
+            id INTEGER PRIMARY KEY AUTOINCREMENT,
+            name TEXT NOT NULL,
+            score INT)
+        """)
+
+    try db.execute(
+        sql: "INSERT INTO player (name, score) VALUES (?, ?)",
+        arguments: ["Barbara", 1000])
+
+    try db.execute(
+        sql: "UPDATE player SET score = :score WHERE id = :id",
+        arguments: ["score": 1000, "id": 1])
+    }
+}
+
+ +

The ? and colon-prefixed keys like :score in the SQL query are the statements arguments. You pass arguments with arrays or dictionaries, as in the example above. See Values for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and StatementArguments for a detailed documentation of SQLite arguments.

+ +

You can also embed query arguments right into your SQL queries, with the literal argument label, as in the example below. See SQL Interpolation for more details.

+
try dbQueue.write { db in
+    try db.execute(literal: """
+        INSERT INTO player (name, score) VALUES (\("O'Brien"), \(550))
+        """)
+}
+
+ +

Never ever embed values directly in your raw SQL strings. See Avoiding SQL Injection for more information:

+
// WRONG: don't embed values in raw SQL strings
+let id = 123
+let name = textField.text
+try db.execute(
+    sql: "UPDATE player SET name = '\(name)' WHERE id = \(id)")
+
+// CORRECT: use arguments dictionary
+try db.execute(
+    sql: "UPDATE player SET name = :name WHERE id = :id",
+    arguments: ["name": name, "id": id])
+
+// CORRECT: use arguments array
+try db.execute(
+    sql: "UPDATE player SET name = ? WHERE id = ?",
+    arguments: [name, id])
+
+// CORRECT: use SQL Interpolation
+try db.execute(
+    literal: "UPDATE player SET name = \(name) WHERE id = \(id)")
+
+ +

Join multiple statements with a semicolon:

+
try db.execute(sql: """
+    INSERT INTO player (name, score) VALUES (?, ?);
+    INSERT INTO player (name, score) VALUES (?, ?);
+    """, arguments: ["Arthur", 750, "Barbara", 1000])
+
+try db.execute(literal: """
+    INSERT INTO player (name, score) VALUES (\("Arthur"), \(750));
+    INSERT INTO player (name, score) VALUES (\("Barbara"), \(1000));
+    """)
+
+ +

When you want to make sure that a single statement is executed, use Prepared Statements.

+ +

After an INSERT statement, you can get the row ID of the inserted row:

+
try db.execute(
+    sql: "INSERT INTO player (name, score) VALUES (?, ?)",
+    arguments: ["Arthur", 1000])
+let playerId = db.lastInsertedRowID
+
+ +

Don’t miss Records, that provide classic persistence methods:

+
var player = Player(name: "Arthur", score: 1000)
+try player.insert(db)
+let playerId = player.id
+
+

Fetch Queries

+ +

Database connections let you fetch database rows, plain values, and custom models aka “records”.

+ +

Rows are the raw results of SQL queries:

+
try dbQueue.read { db in
+    if let row = try Row.fetchOne(db, sql: "SELECT * FROM wine WHERE id = ?", arguments: [1]) {
+        let name: String = row["name"]
+        let color: Color = row["color"]
+        print(name, color)
+    }
+}
+
+ +

Values are the Bool, Int, String, Date, Swift enums, etc. stored in row columns:

+
try dbQueue.read { db in
+    let urls = try URL.fetchCursor(db, sql: "SELECT url FROM wine")
+    while let url = try urls.next() {
+        print(url)
+    }
+}
+
+ +

Records are your application objects that can initialize themselves from rows:

+
let wines = try dbQueue.read { db in
+    try Wine.fetchAll(db, sql: "SELECT * FROM wine")
+}
+
+ + +

Fetching Methods

+ +

Throughout GRDB, you can always fetch cursors, arrays, sets, or single values of any fetchable type (database row, simple value, or custom record):

+
try Row.fetchCursor(...) // A Cursor of Row
+try Row.fetchAll(...)    // [Row]
+try Row.fetchSet(...)    // Set<Row>
+try Row.fetchOne(...)    // Row?
+
+ +
    +
  • fetchCursor returns a cursor over fetched values:

    +
    let rows = try Row.fetchCursor(db, sql: "SELECT ...") // A Cursor of Row
    +
  • +
  • fetchAll returns an array:

    +
    let players = try Player.fetchAll(db, sql: "SELECT ...") // [Player]
    +
  • +
  • fetchSet returns a set:

    +
    let names = try String.fetchSet(db, sql: "SELECT ...") // Set<String>
    +
  • +
  • fetchOne returns a single optional value, and consumes a single database row (if any).

    +
    let count = try Int.fetchOne(db, sql: "SELECT COUNT(*) ...") // Int?
    +
  • +
+ +

All those fetching methods require an SQL string that contains a single SQL statement. When you want to fetch from multiple statements joined with a semicolon, iterate the multiple prepared statements found in the SQL string:

+
let statements = try db.allStatements(sql: """
+    SELECT ...; 
+    SELECT ...; 
+    SELECT ...;
+    """)
+while let statement = try statements.next() {
+    let players = try Player.fetchAll(statement)
+}
+
+ +

You can join the results of all statements yielded by the allStatements method, like the SQLite sqlite3_exec function:

+
// A single cursor of all rows from all statements
+let rows = try db
+    .allStatements(sql: "...")
+    .flatMap { statement in try Row.fetchCursor(statement) }
+
+ +

See prepared statements for more information about allStatements().

+

Cursors

+ +

Whenever you consume several rows from the database, you can fetch an Array, a Set, or a Cursor.

+ +

The fetchAll() and fetchSet() methods return regular Swift array and sets, that you iterate like all other arrays and sets:

+
try dbQueue.read { db in
+    // [Player]
+    let players = try Player.fetchAll(db, sql: "SELECT ...")
+    for player in players {
+        // use player
+    }
+}
+
+ +

Unlike arrays and sets, cursors returned by fetchCursor() load their results step after step:

+
try dbQueue.read { db in
+    // Cursor of Player
+    let players = try Player.fetchCursor(db, sql: "SELECT ...")
+    while let player = try players.next() {
+        // use player
+    }
+}
+
+ +
    +
  • Cursors can not be used on any thread: you must consume a cursor on the dispatch queue it was created in. Particularly, don’t extract a cursor out of a database access method:

    +
    // Wrong
    +let cursor = try dbQueue.read { db in
    +    try Player.fetchCursor(db, ...)
    +}
    +while let player = try cursor.next() { ... }
    +
    + +

    Conversely, arrays and sets may be consumed on any thread:

    +
    // OK
    +let array = try dbQueue.read { db in
    +    try Player.fetchAll(db, ...)
    +}
    +for player in array { ... }
    +
  • +
  • Cursors can be iterated only one time. Arrays and sets can be iterated many times.

  • +
  • Cursors iterate database results in a lazy fashion, and don’t consume much memory. Arrays and sets contain copies of database values, and may take a lot of memory when there are many fetched results.

  • +
  • Cursors are granted with direct access to SQLite, unlike arrays and sets that have to take the time to copy database values. If you look after extra performance, you may prefer cursors.

  • +
  • Cursors can feed Swift collections.

    + +

    You will most of the time use fetchAll or fetchSet when you want an array or a set. For more specific needs, you may prefer one of the initializers below. All of them accept an extra optional minimumCapacity argument which helps optimizing your app when you have an idea of the number of elements in a cursor (the built-in fetchAll and fetchSet do not perform such an optimization).

    + +

    Arrays and all types conforming to RangeReplaceableCollection:

    +
    // [String]
    +let cursor = try String.fetchCursor(db, ...)
    +let array = try Array(cursor)
    +
    + +

    Sets:

    +
    // Set<Int>
    +let cursor = try Int.fetchCursor(db, ...)
    +let set = try Set(cursor)
    +
    + +

    Dictionaries:

    +
    // [Int64: [Player]]
    +let cursor = try Player.fetchCursor(db)
    +let dictionary = try Dictionary(grouping: cursor, by: { $0.teamID })
    +
    +// [Int64: Player]
    +let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
    +let dictionary = try Dictionary(uniqueKeysWithValues: cursor)
    +
  • +
  • Cursors adopt the Cursor protocol, which looks a lot like standard lazy sequences of Swift. As such, cursors come with many convenience methods: compactMap, contains, dropFirst, dropLast, drop(while:), enumerated, filter, first, flatMap, forEach, joined, joined(separator:), max, max(by:), min, min(by:), map, prefix, prefix(while:), reduce, reduce(into:), suffix:

    +
    // Prints all Github links
    +try URL
    +    .fetchCursor(db, sql: "SELECT url FROM link")
    +    .filter { url in url.host == "github.com" }
    +    .forEach { url in print(url) }
    +
    +// An efficient cursor of coordinates:
    +let locations = try Row.
    +    .fetchCursor(db, sql: "SELECT latitude, longitude FROM place")
    +    .map { row in
    +        CLLocationCoordinate2D(latitude: row[0], longitude: row[1])
    +    }
    +
  • +
  • Cursors are not Swift sequences. That’s because Swift sequences can’t handle iteration errors, when reading SQLite results may fail at any time.

  • +
  • Cursors require a little care:

    + +
      +
    • Don’t modify the results during a cursor iteration:

      +
      // Undefined behavior
      +while let player = try players.next() {
      +    try db.execute(sql: "DELETE ...")
      +}
      +
    • +
    • Don’t turn a cursor of Row into an array or a set. You would not get the distinct rows you expect. To get a array of rows, use Row.fetchAll(...). To get a set of rows, use Row.fetchSet(...). Generally speaking, make sure you copy a row whenever you extract it from a cursor for later use: row.copy().

    • +
  • +
+ +

If you don’t see, or don’t care about the difference, use arrays. If you care about memory and performance, use cursors when appropriate.

+

Row Queries

+ + +

Fetching Rows

+ +

Fetch cursors of rows, arrays, sets, or single rows (see fetching methods):

+
try dbQueue.read { db in
+    try Row.fetchCursor(db, sql: "SELECT ...", arguments: ...) // A Cursor of Row
+    try Row.fetchAll(db, sql: "SELECT ...", arguments: ...)    // [Row]
+    try Row.fetchSet(db, sql: "SELECT ...", arguments: ...)    // Set<Row>
+    try Row.fetchOne(db, sql: "SELECT ...", arguments: ...)    // Row?
+
+    let rows = try Row.fetchCursor(db, sql: "SELECT * FROM wine")
+    while let row = try rows.next() {
+        let name: String = row["name"]
+        let color: Color = row["color"]
+        print(name, color)
+    }
+}
+
+let rows = try dbQueue.read { db in
+    try Row.fetchAll(db, sql: "SELECT * FROM player")
+}
+
+ +

Arguments are optional arrays or dictionaries that fill the positional ? and colon-prefixed keys like :name in the query:

+
let rows = try Row.fetchAll(db,
+    sql: "SELECT * FROM player WHERE name = ?",
+    arguments: ["Arthur"])
+
+let rows = try Row.fetchAll(db,
+    sql: "SELECT * FROM player WHERE name = :name",
+    arguments: ["name": "Arthur"])
+
+ +

See Values for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and StatementArguments for a detailed documentation of SQLite arguments.

+ +

Unlike row arrays that contain copies of the database rows, row cursors are close to the SQLite metal, and require a little care:

+ +
+

:point_up: Don’t turn a cursor of Row into an array or a set. You would not get the distinct rows you expect. To get a array of rows, use Row.fetchAll(...). To get a set of rows, use Row.fetchSet(...). Generally speaking, make sure you copy a row whenever you extract it from a cursor for later use: row.copy().

+
+

Column Values

+ +

Read column values by index or column name:

+
let name: String = row[0]      // 0 is the leftmost column
+let name: String = row["name"] // Leftmost matching column - lookup is case-insensitive
+let name: String = row[Column("name")] // Using query interface's Column
+
+ +

Make sure to ask for an optional when the value may be NULL:

+
let name: String? = row["name"]
+
+ +

The row[] subscript returns the type you ask for. See Values for more information on supported value types:

+
let bookCount: Int     = row["bookCount"]
+let bookCount64: Int64 = row["bookCount"]
+let hasBooks: Bool     = row["bookCount"] // false when 0
+
+let string: String     = row["date"]      // "2015-09-11 18:14:15.123"
+let date: Date         = row["date"]      // Date
+self.date = row["date"] // Depends on the type of the property.
+
+ +

You can also use the as type casting operator:

+
row[...] as Int
+row[...] as Int?
+
+ +
+

:warning: Warning: avoid the as! and as? operators:

+
if let int = row[...] as? Int { ... } // BAD - doesn't work
+if let int = row[...] as Int? { ... } // GOOD
+
+
+ +

Generally speaking, you can extract the type you need, provided it can be converted from the underlying SQLite value:

+ +
    +
  • Successful conversions include:

    + +
      +
    • All numeric SQLite values to all numeric Swift types, and Bool (zero is the only false boolean).
    • +
    • Text SQLite values to Swift String.
    • +
    • Blob SQLite values to Foundation Data.
    • +
    + +

    See Values for more information on supported types (Bool, Int, String, Date, Swift enums, etc.)

  • +
  • NULL returns nil.

    +
    let row = try Row.fetchOne(db, sql: "SELECT NULL")!
    +row[0] as Int? // nil
    +row[0] as Int  // fatal error: could not convert NULL to Int.
    +
    + +

    There is one exception, though: the DatabaseValue type:

    +
    row[0] as DatabaseValue // DatabaseValue.null
    +
  • +
  • Missing columns return nil.

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'foo' AS foo")!
    +row["missing"] as String? // nil
    +row["missing"] as String  // fatal error: no such column: missing
    +
    + +

    You can explicitly check for a column presence with the hasColumn method.

  • +
  • Invalid conversions throw a fatal error.

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'Mom’s birthday'")!
    +row[0] as String // "Mom’s birthday"
    +row[0] as Date?  // fatal error: could not convert "Mom’s birthday" to Date.
    +row[0] as Date   // fatal error: could not convert "Mom’s birthday" to Date.
    +
    +let row = try Row.fetchOne(db, sql: "SELECT 256")!
    +row[0] as Int    // 256
    +row[0] as UInt8? // fatal error: could not convert 256 to UInt8.
    +row[0] as UInt8  // fatal error: could not convert 256 to UInt8.
    +
    + +

    Those conversion fatal errors can be avoided with the DatabaseValue type:

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'Mom’s birthday'")!
    +let dbValue: DatabaseValue = row[0]
    +if dbValue.isNull {
    +    // Handle NULL
    +} else if let date = Date.fromDatabaseValue(dbValue) {
    +    // Handle valid date
    +} else {
    +    // Handle invalid date
    +}
    +
    + +

    This extra verbosity is the consequence of having to deal with an untrusted database: you may consider fixing the content of your database instead. See Fatal Errors for more information.

  • +
  • SQLite has a weak type system, and provides convenience conversions that can turn String to Int, Double to Blob, etc.

    + +

    GRDB will sometimes let those conversions go through:

    +
    let rows = try Row.fetchCursor(db, sql: "SELECT '20 small cigars'")
    +while let row = try rows.next() {
    +    row[0] as Int   // 20
    +}
    +
    + +

    Don’t freak out: those conversions did not prevent SQLite from becoming the immensely successful database engine you want to use. And GRDB adds safety checks described just above. You can also prevent those convenience conversions altogether by using the DatabaseValue type.

  • +
+

DatabaseValue

+ +

DatabaseValue is an intermediate type between SQLite and your values, which gives information about the raw value stored in the database.

+ +

You get DatabaseValue just like other value types:

+
let dbValue: DatabaseValue = row[0]
+let dbValue: DatabaseValue? = row["name"] // nil if and only if column does not exist
+
+// Check for NULL:
+dbValue.isNull // Bool
+
+// The stored value:
+dbValue.storage.value // Int64, Double, String, Data, or nil
+
+// All the five storage classes supported by SQLite:
+switch dbValue.storage {
+case .null:                 print("NULL")
+case .int64(let int64):     print("Int64: \(int64)")
+case .double(let double):   print("Double: \(double)")
+case .string(let string):   print("String: \(string)")
+case .blob(let data):       print("Data: \(data)")
+}
+
+ +

You can extract regular values (Bool, Int, String, Date, Swift enums, etc.) from DatabaseValue with the DatabaseValueConvertible.fromDatabaseValue() method:

+
let dbValue: DatabaseValue = row["bookCount"]
+let bookCount   = Int.fromDatabaseValue(dbValue)   // Int?
+let bookCount64 = Int64.fromDatabaseValue(dbValue) // Int64?
+let hasBooks    = Bool.fromDatabaseValue(dbValue)  // Bool?, false when 0
+
+let dbValue: DatabaseValue = row["date"]
+let string = String.fromDatabaseValue(dbValue)     // "2015-09-11 18:14:15.123"
+let date   = Date.fromDatabaseValue(dbValue)       // Date?
+
+ +

fromDatabaseValue returns nil for invalid conversions:

+
let row = try Row.fetchOne(db, sql: "SELECT 'Mom’s birthday'")!
+let dbValue: DatabaseValue = row[0]
+let string = String.fromDatabaseValue(dbValue) // "Mom’s birthday"
+let int    = Int.fromDatabaseValue(dbValue)    // nil
+let date   = Date.fromDatabaseValue(dbValue)   // nil
+
+

Rows as Dictionaries

+ +

Row adopts the standard RandomAccessCollection protocol, and can be seen as a dictionary of DatabaseValue:

+
// All the (columnName, dbValue) tuples, from left to right:
+for (columnName, dbValue) in row {
+    ...
+}
+
+ +

You can build rows from dictionaries (standard Swift dictionaries and NSDictionary). See Values for more information on supported types:

+
let row: Row = ["name": "foo", "date": nil]
+let row = Row(["name": "foo", "date": nil])
+let row = Row(/* [AnyHashable: Any] */) // nil if invalid dictionary
+
+ +

Yet rows are not real dictionaries: they may contain duplicate columns:

+
let row = try Row.fetchOne(db, sql: "SELECT 1 AS foo, 2 AS foo")!
+row.columnNames    // ["foo", "foo"]
+row.databaseValues // [1, 2]
+row["foo"]         // 1 (leftmost matching column)
+for (columnName, dbValue) in row { ... } // ("foo", 1), ("foo", 2)
+
+ +

When you build a dictionary from a row, you have to disambiguate identical columns, and choose how to present database values. For example:

+ +
    +
  • A [String: DatabaseValue] dictionary that keeps leftmost value in case of duplicated column name:

    +
    let dict = Dictionary(row, uniquingKeysWith: { (left, _) in left })
    +
  • +
  • A [String: AnyObject] dictionary which keeps rightmost value in case of duplicated column name. This dictionary is identical to FMResultSet’s resultDictionary from FMDB. It contains NSNull values for null columns, and can be shared with Objective-C:

    +
    let dict = Dictionary(
    +    row.map { (column, dbValue) in
    +        (column, dbValue.storage.value as AnyObject)
    +    },
    +    uniquingKeysWith: { (_, right) in right })
    +
  • +
  • A [String: Any] dictionary that can feed, for example, JSONSerialization:

    +
    let dict = Dictionary(
    +    row.map { (column, dbValue) in
    +        (column, dbValue.storage.value)
    +    },
    +    uniquingKeysWith: { (left, _) in left })
    +
  • +
+ +

See the documentation of Dictionary.init(_:uniquingKeysWith:) for more information.

+

Value Queries

+ +

Instead of rows, you can directly fetch values. Like rows, fetch them as cursors, arrays, sets, or single values (see fetching methods). Values are extracted from the leftmost column of the SQL queries:

+
try dbQueue.read { db in
+    try Int.fetchCursor(db, sql: "SELECT ...", arguments: ...) // A Cursor of Int
+    try Int.fetchAll(db, sql: "SELECT ...", arguments: ...)    // [Int]
+    try Int.fetchSet(db, sql: "SELECT ...", arguments: ...)    // Set<Int>
+    try Int.fetchOne(db, sql: "SELECT ...", arguments: ...)    // Int?
+
+    // When database may contain NULL:
+    try Optional<Int>.fetchCursor(db, sql: "SELECT ...", arguments: ...) // A Cursor of Int?
+    try Optional<Int>.fetchAll(db, sql: "SELECT ...", arguments: ...)    // [Int?]
+    try Optional<Int>.fetchSet(db, sql: "SELECT ...", arguments: ...)    // Set<Int?>
+}
+
+let playerCount = try dbQueue.read { db in
+    try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM player")!
+}
+
+ +

fetchOne returns an optional value which is nil in two cases: either the SELECT statement yielded no row, or one row with a NULL value.

+ +

There are many supported value types (Bool, Int, String, Date, Swift enums, etc.). See Values for more information:

+
let count = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM player")! // Int
+let urls = try URL.fetchAll(db, sql: "SELECT url FROM link")          // [URL]
+
+

Values

+ +

GRDB ships with built-in support for the following value types:

+ + + +

Values can be used as statement arguments:

+
let url: URL = ...
+let verified: Bool = ...
+try db.execute(
+    sql: "INSERT INTO link (url, verified) VALUES (?, ?)",
+    arguments: [url, verified])
+
+ +

Values can be extracted from rows:

+
let rows = try Row.fetchCursor(db, sql: "SELECT * FROM link")
+while let row = try rows.next() {
+    let url: URL = row["url"]
+    let verified: Bool = row["verified"]
+}
+
+ +

Values can be directly fetched:

+
let urls = try URL.fetchAll(db, sql: "SELECT url FROM link")  // [URL]
+
+ +

Use values in Records:

+
struct Link: FetchableRecord {
+    var url: URL
+    var isVerified: Bool
+
+    init(row: Row) {
+        url = row["url"]
+        isVerified = row["verified"]
+    }
+}
+
+ +

Use values in the query interface:

+
let url: URL = ...
+let link = try Link.filter(Column("url") == url).fetchOne(db)
+
+

Data (and Memory Savings)

+ +

Data suits the BLOB SQLite columns. It can be stored and fetched from the database just like other values:

+
let rows = try Row.fetchCursor(db, sql: "SELECT data, ...")
+while let row = try rows.next() {
+    let data: Data = row["data"]
+}
+
+ +

At each step of the request iteration, the row[] subscript creates two copies of the database bytes: one fetched by SQLite, and another, stored in the Swift Data value.

+ +

You have the opportunity to save memory by not copying the data fetched by SQLite:

+
while let row = try rows.next() {
+    let data = row.dataNoCopy(named: "data") // Data?
+}
+
+ +

The non-copied data does not live longer than the iteration step: make sure that you do not use it past this point.

+

Date and DateComponents

+ +

Date and DateComponents can be stored and fetched from the database.

+ +

Here is how GRDB supports the various date formats supported by SQLite:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SQLite formatDateDateComponents
YYYY-MM-DDRead ¹Read / Write
YYYY-MM-DD HH:MMRead ¹ ²Read ² / Write
YYYY-MM-DD HH:MM:SSRead ¹ ²Read ² / Write
YYYY-MM-DD HH:MM:SS.SSSRead ¹ ² / Write ¹Read ² / Write
YYYY-MM-DD*T*HH:MMRead ¹ ²Read ²
YYYY-MM-DD*T*HH:MM:SSRead ¹ ²Read ²
YYYY-MM-DD*T*HH:MM:SS.SSSRead ¹ ²Read ²
HH:MMRead ² / Write
HH:MM:SSRead ² / Write
HH:MM:SS.SSSRead ² / Write
Timestamps since unix epochRead ³
now
+ +

¹ Missing components are assumed to be zero. Dates are stored and read in the UTC time zone, unless the format is followed by a timezone indicator ⁽²⁾.

+ +

² This format may be optionally followed by a timezone indicator of the form [+-]HH:MM or just Z.

+ +

³ GRDB 2+ interprets numerical values as timestamps that fuel Date(timeIntervalSince1970:). Previous GRDB versions used to interpret numbers as julian days. Julian days are still supported, with the Date(julianDay:) initializer.

+

Date

+ +

Date can be stored and fetched from the database just like other values:

+
try db.execute(
+    sql: "INSERT INTO player (creationDate, ...) VALUES (?, ...)",
+    arguments: [Date(), ...])
+
+let row = try Row.fetchOne(db, ...)!
+let creationDate: Date = row["creationDate"]
+
+ +

Dates are stored using the format “YYYY-MM-DD HH:MM:SS.SSS” in the UTC time zone. It is precise to the millisecond.

+ +
+

:point_up: Note: this format was chosen because it is the only format that is:

+ +
    +
  • Comparable (ORDER BY date works)
  • +
  • Comparable with the SQLite keyword CURRENT_TIMESTAMP (WHERE date > CURRENT_TIMESTAMP works)
  • +
  • Able to feed SQLite date & time functions
  • +
  • Precise enough
  • +
+
+ +

When the default format does not fit your needs, customize date conversions. For example:

+
try db.execute(
+    sql: "INSERT INTO player (creationDate, ...) VALUES (?, ...)",
+    arguments: [Date().timeIntervalSinceReferenceDate, ...])
+
+let row = try Row.fetchOne(db, ...)!
+let creationDate = Date(timeIntervalSinceReferenceDate: row["creationDate"])
+
+ +

See Codable Records for more date customization options.

+

DateComponents

+ +

DateComponents is indirectly supported, through the DatabaseDateComponents helper type.

+ +

DatabaseDateComponents reads date components from all date formats supported by SQLite, and stores them in the format of your choice, from HH:MM to YYYY-MM-DD HH:MM:SS.SSS.

+ +

DatabaseDateComponents can be stored and fetched from the database just like other values:

+
let components = DateComponents()
+components.year = 1973
+components.month = 9
+components.day = 18
+
+// Store "1973-09-18"
+let dbComponents = DatabaseDateComponents(components, format: .YMD)
+try db.execute(
+    sql: "INSERT INTO player (birthDate, ...) VALUES (?, ...)",
+    arguments: [dbComponents, ...])
+
+// Read "1973-09-18"
+let row = try Row.fetchOne(db, sql: "SELECT birthDate ...")!
+let dbComponents: DatabaseDateComponents = row["birthDate"]
+dbComponents.format         // .YMD (the actual format found in the database)
+dbComponents.dateComponents // DateComponents
+
+

NSNumber, NSDecimalNumber, and Decimal

+ +

NSNumber and Decimal can be stored and fetched from the database just like other values.

+ +

Here is how GRDB supports the various data types supported by SQLite:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
IntegerDoubleString
NSNumberRead / WriteRead / WriteRead
NSDecimalNumberRead / WriteRead / WriteRead
DecimalReadReadRead / Write
+ +
    +
  • All three types can decode database integers and doubles:

    +
    let number = try NSNumber.fetchOne(db, sql: "SELECT 10")            // NSNumber
    +let number = try NSDecimalNumber.fetchOne(db, sql: "SELECT 1.23")   // NSDecimalNumber
    +let number = try Decimal.fetchOne(db, sql: "SELECT -100")           // Decimal
    +
  • +
  • All three types decode database strings as decimal numbers:

    +
    let number = try NSNumber.fetchOne(db, sql: "SELECT '10'")          // NSDecimalNumber (sic)
    +let number = try NSDecimalNumber.fetchOne(db, sql: "SELECT '1.23'") // NSDecimalNumber
    +let number = try Decimal.fetchOne(db, sql: "SELECT '-100'")         // Decimal
    +
  • +
  • NSNumber and NSDecimalNumber send 64-bit signed integers and doubles in the database:

    +
    // INSERT INTO transfer VALUES (10)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSNumber(value: 10)])
    +
    +// INSERT INTO transfer VALUES (10.0)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSNumber(value: 10.0)])
    +
    +// INSERT INTO transfer VALUES (10)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSDecimalNumber(string: "10.0")])
    +
    +// INSERT INTO transfer VALUES (10.5)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSDecimalNumber(string: "10.5")])
    +
    + +
    +

    :warning: Warning: since SQLite does not support decimal numbers, sending a non-integer NSDecimalNumber can result in a loss of precision during the conversion to double.

    + +

    Instead of sending non-integer NSDecimalNumber to the database, you may prefer:

    + +
      +
    • Send Decimal instead (those store decimal strings in the database).
    • +
    • Send integers instead (for example, store amounts of cents instead of amounts of Euros).
    • +
    +
  • +
  • Decimal sends decimal strings in the database:

    +
    // INSERT INTO transfer VALUES ('10')
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [Decimal(10)])
    +
    +// INSERT INTO transfer VALUES ('10.5')
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [Decimal(string: "10.5")!])
    +
  • +
+

UUID

+ +

UUID can be stored and fetched from the database just like other values.

+ +

GRDB stores uuids as 16-bytes data blobs, and decodes them from both 16-bytes data blobs and strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”.

+

Swift Enums

+ +

Swift enums and generally all types that adopt the RawRepresentable protocol can be stored and fetched from the database just like their raw values:

+
enum Color : Int {
+    case red, white, rose
+}
+
+enum Grape : String {
+    case chardonnay, merlot, riesling
+}
+
+// Declare empty DatabaseValueConvertible adoption
+extension Color : DatabaseValueConvertible { }
+extension Grape : DatabaseValueConvertible { }
+
+// Store
+try db.execute(
+    sql: "INSERT INTO wine (grape, color) VALUES (?, ?)",
+    arguments: [Grape.merlot, Color.red])
+
+// Read
+let rows = try Row.fetchCursor(db, sql: "SELECT * FROM wine")
+while let row = try rows.next() {
+    let grape: Grape = row["grape"]
+    let color: Color = row["color"]
+}
+
+ +

When a database value does not match any enum case, you get a fatal error. This fatal error can be avoided with the DatabaseValue type:

+
let row = try Row.fetchOne(db, sql: "SELECT 'syrah'")!
+
+row[0] as String  // "syrah"
+row[0] as Grape?  // fatal error: could not convert "syrah" to Grape.
+row[0] as Grape   // fatal error: could not convert "syrah" to Grape.
+
+let dbValue: DatabaseValue = row[0]
+if dbValue.isNull {
+    // Handle NULL
+} else if let grape = Grape.fromDatabaseValue(dbValue) {
+    // Handle valid grape
+} else {
+    // Handle unknown grape
+}
+
+

Custom Value Types

+ +

Conversion to and from the database is based on the DatabaseValueConvertible protocol:

+
protocol DatabaseValueConvertible {
+    /// Returns a value that can be stored in the database.
+    var databaseValue: DatabaseValue { get }
+
+    /// Returns a value initialized from dbValue, if possible.
+    static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
+}
+
+ +

All types that adopt this protocol can be used like all other values (Bool, Int, String, Date, Swift enums, etc.)

+ +

The databaseValue property returns DatabaseValue, a type that wraps the five values supported by SQLite: NULL, Int64, Double, String and Data. Since DatabaseValue has no public initializer, use DatabaseValue.null, or another type that already adopts the protocol: 1.databaseValue, "foo".databaseValue, etc. Conversion to DatabaseValue must not fail.

+ +

The fromDatabaseValue() factory method returns an instance of your custom type if the database value contains a suitable value. If the database value does not contain a suitable value, such as “foo” for Date, fromDatabaseValue must return nil (GRDB will interpret this nil result as a conversion error, and react accordingly).

+ +

Value types that adopt both DatabaseValueConvertible and an archival protocol (Codable, Encodable or Decodable) are automatically coded and decoded from JSON arrays and objects:

+
// Encoded as a JSON object in the database:
+struct Color: Codable, DatabaseValueConvertible {
+    var r: Double
+    var g: Double
+    var b: Double
+}
+
+ +

For such codable value types, GRDB uses the standard JSONDecoder and JSONEncoder from Foundation. By default, Data values are handled with the .base64 strategy, Date with the .millisecondsSince1970 strategy, and non conforming floats with the .throw strategy.

+ +

In order to customize the JSON format, provide a custom implementation of the DatabaseValueConvertible requirements.

+ +
+

:point_up: Note: standard sequences such as Array, Set, or Dictionary do not conform to DatabaseValueConvertible, even conditionally. You won’t be able to directly fetch or store arrays, sets, or dictionaries as JSON database values. You can get free JSON support from these standard types when they are embedded as properties of Codable Records, though.

+
+

Transactions and Savepoints

+ + +

Transactions and Safety

+ +

A transaction is a fundamental tool of SQLite that guarantees data consistency as well as proper isolation between application threads and database connections.

+ +

GRDB generally opens transactions for you, as a way to enforce its concurrency guarantees, and provide maximal security for both your application data and application logic:

+
// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbQueue.write { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbPool.write { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+ +

Yet you may need to exactly control when transactions take place:

+

Explicit Transactions

+ +

DatabaseQueue.inDatabase() and DatabasePool.writeWithoutTransaction() execute your database statements outside of any transaction:

+
// INSERT INTO credit ...
+// INSERT INTO debit ...
+try dbQueue.inDatabase { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+try dbPool.writeWithoutTransaction { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+ +

Writing outside of any transaction is dangerous, for two reasons:

+ +
    +
  • In our credit/debit example, you may successfully insert a credit, but fail inserting the debit, and end up with unbalanced accounts (oops).

    +
    // UNSAFE DATABASE INTEGRITY
    +try dbQueue.inDatabase { db in // or dbPool.writeWithoutTransaction
    +    try Credit(destinationAccount, amount).insert(db) // may succeed
    +    try Debit(sourceAccount, amount).insert(db)      // may fail
    +}
    +
    + +

    Transactions avoid this kind of bug.

  • +
  • Database pool concurrent reads can see an inconsistent state of the database:

    +
    // UNSAFE CONCURRENCY
    +try dbPool.writeWithoutTransaction { db in
    +    try Credit(destinationAccount, amount).insert(db)
    +    // <- Concurrent dbPool.read sees a partial db update here
    +    try Debit(sourceAccount, amount).insert(db)
    +}
    +
    + +

    Transactions avoid this kind of bug, too.

  • +
+ +

To open explicit transactions, use one of the Database.inTransaction, DatabaseQueue.inTransaction, or DatabasePool.writeInTransaction methods:

+
// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbQueue.inDatabase { db in  // or dbPool.writeWithoutTransaction
+    try db.inTransaction {
+        try Credit(destinationAccount, amount).insert(db)
+        try Debit(sourceAccount, amount).insert(db)
+        return .commit
+    }
+}
+
+// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbQueue.inTransaction { db in  // or dbPool.writeInTransaction
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+    return .commit
+}
+
+ +

If an error is thrown from the transaction block, the transaction is rollbacked and the error is rethrown by the inTransaction method. If you return .rollback instead of .commit, the transaction is also rollbacked, but no error is thrown.

+ +

You can also perform manual transaction management:

+
try dbQueue.inDatabase { db in  // or dbPool.writeWithoutTransaction
+    try db.beginTransaction()
+    ...
+    try db.commit()
+
+    try db.execute(sql: "BEGIN TRANSACTION")
+    ...
+    try db.execute(sql: "ROLLBACK")
+}
+
+ +

Transactions can’t be left opened unless you set the allowsUnsafeTransactions configuration flag:

+
// fatal error: A transaction has been left opened at the end of a database access
+try dbQueue.inDatabase { db in
+    try db.execute(sql: "BEGIN TRANSACTION")
+    // <- no commit or rollback
+}
+
+ +

You can ask if a transaction is currently opened:

+
func myCriticalMethod(_ db: Database) throws {
+    precondition(db.isInsideTransaction, "This method requires a transaction")
+    try ...
+}
+
+ +

Yet, you have a better option than checking for transactions: critical database sections should use savepoints, described below:

+
func myCriticalMethod(_ db: Database) throws {
+    try db.inSavepoint {
+        // Here the database is guaranteed to be inside a transaction.
+        try ...
+    }
+}
+
+

Savepoints

+ +

Statements grouped in a savepoint can be rollbacked without invalidating a whole transaction:

+
try dbQueue.write { db in
+    // Makes sure both inserts succeed, or none:
+    try db.inSavepoint {
+        try Credit(destinationAccount, amount).insert(db)
+        try Debit(sourceAccount, amount).insert(db)
+        return .commit
+    }
+
+    // Other savepoints, etc...
+}
+
+ +

If an error is thrown from the savepoint block, the savepoint is rollbacked and the error is rethrown by the inSavepoint method. If you return .rollback instead of .commit, the savepoint is also rollbacked, but no error is thrown.

+ +

Unlike transactions, savepoints can be nested. They implicitly open a transaction if no one was opened when the savepoint begins. As such, they behave just like nested transactions. Yet the database changes are only written to disk when the outermost transaction is committed:

+
try dbQueue.inDatabase { db in
+    try db.inSavepoint {
+        ...
+        try db.inSavepoint {
+            ...
+            return .commit
+        }
+        ...
+        return .commit  // writes changes to disk
+    }
+}
+
+ +

SQLite savepoints are more than nested transactions, though. For advanced uses, use SQLite savepoint documentation.

+

Transaction Kinds

+ +

SQLite supports three kinds of transactions: deferred (the default), immediate, and exclusive.

+ +

The transaction kind can be changed in the database configuration, or for each transaction:

+
// 1) Default configuration:
+let dbQueue = try DatabaseQueue(path: "...")
+
+// BEGIN DEFERED TRANSACTION ...
+dbQueue.write { db in ... }
+
+// BEGIN EXCLUSIVE TRANSACTION ...
+dbQueue.inTransaction(.exclusive) { db in ... }
+
+// 2) Customized default transaction kind:
+var config = Configuration()
+config.defaultTransactionKind = .immediate
+let dbQueue = try DatabaseQueue(path: "...", configuration: config)
+
+// BEGIN IMMEDIATE TRANSACTION ...
+dbQueue.write { db in ... }
+
+// BEGIN EXCLUSIVE TRANSACTION ...
+dbQueue.inTransaction(.exclusive) { db in ... }
+
+

Prepared Statements

+ +

Prepared Statements let you prepare an SQL query and execute it later, several times if you need, with different arguments.

+
try dbQueue.write { db in
+    let insertSQL = "INSERT INTO player (name, score) VALUES (:name, :score)"
+    let insertStatement = try db.makeStatement(sql: insertSQL)
+
+    let selectSQL = "SELECT * FROM player WHERE name = ?"
+    let selectStatement = try db.makeStatement(sql: selectSQL)
+}
+
+ +

The ? and colon-prefixed keys like :name in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type StatementArguments, which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols).

+
insertStatement.arguments = ["name": "Arthur", "score": 1000]
+selectStatement.arguments = ["Arthur"]
+
+ +

Alternatively, you can create a prepared statement with SQL Interpolation:

+
let insertStatement = try db.makeStatement(literal: "INSERT ...")
+let selectStatement = try db.makeStatement(literal: "SELECT ...")
+//                                         ~~~~~~~
+
+ +

Statements can be executed:

+
try insertStatement.execute()
+
+ +

Statements can be used wherever a raw SQL query string would fit (see fetch queries):

+
let rows = try Row.fetchCursor(selectStatement)    // A Cursor of Row
+let players = try Player.fetchAll(selectStatement) // [Player]
+let players = try Player.fetchSet(selectStatement) // Set<Player>
+let player = try Player.fetchOne(selectStatement)  // Player?
+
+ +

You can set the arguments at the moment of the statement execution:

+
try insertStatement.execute(arguments: ["name": "Arthur", "score": 1000])
+let player = try Player.fetchOne(selectStatement, arguments: ["Arthur"])
+
+ +

When you want to build multiple statements joined with a semicolon, use the allStatements method:

+
let statements = try db.allStatements(sql: """
+    INSERT INTO player (name, score) VALUES (?, ?);
+    INSERT INTO player (name, score) VALUES (?, ?);
+    """, arguments: ["Arthur", 100, "O'Brien", 1000])
+while let statement = try statements.next() {
+    try statement.execute()
+}
+
+ +

allStatements also supports SQL Interpolation:

+
let statements = try db.allStatements(literal: """
+    INSERT INTO player (name, score) VALUES (\("Arthur"), \(100));
+    INSERT INTO player (name, score) VALUES (\("O'Brien"), \(1000));
+    """)
+while let statement = try statements.next() {
+    try statement.execute()
+}
+
+ +

You can turn the cursor returned from allStatements into a regular Swift array, but in this case make sure all individual statements can compile even if the previous ones were not run:

+
// OK: Array of statements
+let statements = try Array(db.allStatements(sql: """
+    INSERT ...; 
+    UPDATE ...; 
+    SELECT ...;
+    """))
+
+// FAILURE: Can't build an array of statements since 
+// the INSERT won't compile until CREATE TABLE is run.
+let statements = try Array(db.allStatements(sql: """
+    CREATE TABLE player ...; 
+    INSERT INTO player ...;
+    """))
+
+ +

See also Database.execute(sql:) in the Executing Updates chapter.

+ +
+

:point_up: Note: it is a programmer error to reuse a prepared statement that has failed: GRDB may crash if you do so.

+
+ +

For more information about prepared statements, see the Statement reference.

+

Prepared Statements Cache

+ +

When the same query will be used several times in the lifetime of your application, you may feel a natural desire to cache prepared statements.

+ +

Don’t cache statements yourself.

+ +
+

:point_up: Note: This is because you don’t have the necessary tools. Statements are tied to specific SQLite connections and dispatch queues which you don’t manage yourself, especially when you use database pools. A change in the database schema may, or may not invalidate a statement.

+
+ +

Instead, use the cachedStatement method. GRDB does all the hard caching and memory management stuff for you:

+
let statement = try db.cachedStatement(sql: sql)
+
+ +

Cached statements also support SQL Interpolation:

+
let statement = try db.cachedStatement(literal: "INSERT ...")
+//                                     ~~~~~~~
+
+ +
+

:warning: Warning: Should a cached prepared statement throw an error, don’t reuse it (it is a programmer error). Instead, reload one from the cache.

+
+

Custom SQL Functions and Aggregates

+ +

SQLite lets you define SQL functions and aggregates.

+ +

A custom SQL function or aggregate extends SQLite:

+
SELECT reverse(name) FROM player;   -- custom function
+SELECT maxLength(name) FROM player; -- custom aggregate
+
+ + +

Custom SQL Functions

+ +

A function argument takes an array of DatabaseValue, and returns any valid value (Bool, Int, String, Date, Swift enums, etc.) The number of database values is guaranteed to be argumentCount.

+ +

SQLite has the opportunity to perform additional optimizations when functions are “pure”, which means that their result only depends on their arguments. So make sure to set the pure argument to true when possible.

+
let reverse = DatabaseFunction("reverse", argumentCount: 1, pure: true) { (values: [DatabaseValue]) in
+    // Extract string value, if any...
+    guard let string = String.fromDatabaseValue(values[0]) else {
+        return nil
+    }
+    // ... and return reversed string:
+    return String(string.reversed())
+}
+
+ +

You make a function available to a database connection through its configuration:

+
var config = Configuration()
+config.prepareDatabase { db in
+    db.add(function: reverse)
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    // "oof"
+    try String.fetchOne(db, sql: "SELECT reverse('foo')")!
+}
+
+ +

Functions can take a variable number of arguments:

+ +

When you don’t provide any explicit argumentCount, the function can take any number of arguments:

+
let averageOf = DatabaseFunction("averageOf", pure: true) { (values: [DatabaseValue]) in
+    let doubles = values.compactMap { Double.fromDatabaseValue($0) }
+    return doubles.reduce(0, +) / Double(doubles.count)
+}
+db.add(function: averageOf)
+
+// 2.0
+try Double.fetchOne(db, sql: "SELECT averageOf(1, 2, 3)")!
+
+ +

Functions can throw:

+
let sqrt = DatabaseFunction("sqrt", argumentCount: 1, pure: true) { (values: [DatabaseValue]) in
+    guard let double = Double.fromDatabaseValue(values[0]) else {
+        return nil
+    }
+    guard double >= 0 else {
+        throw DatabaseError(message: "invalid negative number")
+    }
+    return sqrt(double)
+}
+db.add(function: sqrt)
+
+// SQLite error 1 with statement `SELECT sqrt(-1)`: invalid negative number
+try Double.fetchOne(db, sql: "SELECT sqrt(-1)")!
+
+ +

Use custom functions in the query interface:

+
// SELECT reverseString("name") FROM player
+Player.select(reverseString(nameColumn))
+
+ +

GRDB ships with built-in SQL functions that perform unicode-aware string transformations. See Unicode.

+

Custom Aggregates

+ +

Before registering a custom aggregate, you need to define a type that adopts the DatabaseAggregate protocol:

+
protocol DatabaseAggregate {
+    // Initializes an aggregate
+    init()
+
+    // Called at each step of the aggregation
+    mutating func step(_ dbValues: [DatabaseValue]) throws
+
+    // Returns the final result
+    func finalize() throws -> DatabaseValueConvertible?
+}
+
+ +

For example:

+
struct MaxLength : DatabaseAggregate {
+    var maxLength: Int = 0
+
+    mutating func step(_ dbValues: [DatabaseValue]) {
+        // At each step, extract string value, if any...
+        guard let string = String.fromDatabaseValue(dbValues[0]) else {
+            return
+        }
+        // ... and update the result
+        let length = string.count
+        if length > maxLength {
+            maxLength = length
+        }
+    }
+
+    func finalize() -> DatabaseValueConvertible? {
+        maxLength
+    }
+}
+
+let maxLength = DatabaseFunction(
+    "maxLength",
+    argumentCount: 1,
+    pure: true,
+    aggregate: MaxLength.self)
+
+ +

Like custom SQL Functions, you make an aggregate function available to a database connection through its configuration:

+
var config = Configuration()
+config.prepareDatabase { db in
+    db.add(function: maxLength)
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    // Some Int
+    try Int.fetchOne(db, sql: "SELECT maxLength(name) FROM player")!
+}
+
+ +

The step method of the aggregate takes an array of DatabaseValue. This array contains as many values as the argumentCount parameter (or any number of values, when argumentCount is omitted).

+ +

The finalize method of the aggregate returns the final aggregated value (Bool, Int, String, Date, Swift enums, etc.).

+ +

SQLite has the opportunity to perform additional optimizations when aggregates are “pure”, which means that their result only depends on their inputs. So make sure to set the pure argument to true when possible.

+ +

Use custom aggregates in the query interface:

+
// SELECT maxLength("name") FROM player
+let request = Player.select(maxLength.apply(nameColumn))
+try Int.fetchOne(db, request) // Int?
+
+

Database Schema Introspection

+ +

GRDB comes with a set of schema introspection methods:

+
try dbQueue.read { db in
+    // Bool, true if the table exists
+    try db.tableExists("player")
+
+    // [ColumnInfo], the columns in the table
+    try db.columns(in: "player")
+
+    // PrimaryKeyInfo
+    try db.primaryKey("player")
+
+    // [ForeignKeyInfo], the foreign keys defined on the table
+    try db.foreignKeys(on: "player")
+
+    // [IndexInfo], the indexes defined on the table
+    try db.indexes(on: "player")
+
+    // Bool, true if column(s) is a unique key (primary key or unique index)
+    try db.table("player", hasUniqueKey: ["email"])
+}
+
+// Bool, true if argument is the name of an internal SQLite table
+Database.isSQLiteInternalTable(...)
+
+// Bool, true if argument is the name of an internal GRDB table
+Database.isGRDBInternalTable(...)
+
+

Row Adapters

+ +

Row adapters let you present database rows in the way expected by the row consumers.

+ +

They basically help two incompatible row interfaces to work together. For example, a row consumer expects a column named “consumed”, but the produced row has a column named “produced”.

+ +

In this case, the ColumnMapping row adapter comes in handy:

+
// Turn the 'produced' column into 'consumed':
+let adapter = ColumnMapping(["consumed": "produced"])
+let row = try Row.fetchOne(db, sql: "SELECT 'Hello' AS produced", adapter: adapter)!
+
+// [consumed:"Hello"]
+print(row)
+
+// "Hello"
+print(row["consumed"])
+
+// ▿ [consumed:"Hello"]
+//   unadapted: [produced:"Hello"]
+print(row.debugDescription)
+
+// [produced:"Hello"]
+print(row.unadapted)
+
+ +

Record types are typical row consumers that expect database rows to have a specific layout so that they can decode them:

+
struct MyRecord: Decodable, FetchableRecord {
+    var consumed: String
+}
+let record = try MyRecord.fetchOne(db, sql: "SELECT 'Hello' AS produced", adapter: adapter)!
+print(record.consumed) // "Hello"
+
+ +

There are several situations where row adapters are useful:

+ +
    +
  • They help disambiguate columns with identical names, which may happen when you select columns from several tables. See Joined Queries Support for an example.

  • +
  • They help when SQLite outputs unexpected column names, which may happen with some subqueries. See RenameColumnAdapter for an example.

  • +
+ +

Available row adapters are described below.

+ + +

ColumnMapping

+ +

ColumnMapping renames columns. Build one with a dictionary whose keys are adapted column names, and values the column names in the raw row:

+
// [newA:0, newB:1]
+let adapter = ColumnMapping(["newA": "a", "newB": "b"])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+ +

Note that columns that are not present in the dictionary are not present in the resulting adapted row.

+

EmptyRowAdapter

+ +

EmptyRowAdapter hides all columns.

+
let adapter = EmptyRowAdapter()
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+row.isEmpty // true
+
+ +

This limit adapter may turn out useful in some narrow use cases. You’ll be happy to find it when you need it.

+

RangeRowAdapter

+ +

RangeRowAdapter only exposes a range of columns.

+
// [b:1]
+let adapter = RangeRowAdapter(1..<2)
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+

RenameColumnAdapter

+ +

RenameColumnAdapter lets you transform column names with a function:

+
// [arrr:0, brrr:1, crrr:2]
+let adapter = RenameColumnAdapter { column in column + "rrr" }
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+ +

This adapter may turn out useful, for example, when subqueries contain duplicated column names:

+
let sql = "SELECT * FROM (SELECT 1 AS id, 2 AS id)"
+
+// Prints ["id", "id:1"]
+// Note the "id:1" column, generated by SQLite.
+let row = try Row.fetchOne(db, sql: sql)!
+print(Array(row.columnNames))
+
+// Drop the `:...` suffix, and prints ["id", "id"]
+let adapter = RenameColumnAdapter { String($0.prefix(while: { $0 != ":" })) }
+let adaptedRow = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+print(Array(adaptedRow.columnNames))
+
+

ScopeAdapter

+ +

ScopeAdapter defines row scopes:

+
let adapter = ScopeAdapter([
+    "left": RangeRowAdapter(0..<2),
+    "right": RangeRowAdapter(2..<4)])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
+
+ +

ScopeAdapter does not change the columns and values of the fetched row. Instead, it defines scopes, which you access through the Row.scopes property:

+
row                   // [a:0 b:1 c:2 d:3]
+row.scopes["left"]    // [a:0 b:1]
+row.scopes["right"]   // [c:2 d:3]
+row.scopes["missing"] // nil
+
+ +

Scopes can be nested:

+
let adapter = ScopeAdapter([
+    "left": ScopeAdapter([
+        "left": RangeRowAdapter(0..<1),
+        "right": RangeRowAdapter(1..<2)]),
+    "right": ScopeAdapter([
+        "left": RangeRowAdapter(2..<3),
+        "right": RangeRowAdapter(3..<4)])
+    ])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
+
+let leftRow = row.scopes["left"]!
+leftRow.scopes["left"]  // [a:0]
+leftRow.scopes["right"] // [b:1]
+
+let rightRow = row.scopes["right"]!
+rightRow.scopes["left"]  // [c:2]
+rightRow.scopes["right"] // [d:3]
+
+ +

Any adapter can be extended with scopes:

+
let baseAdapter = RangeRowAdapter(0..<2)
+let adapter = ScopeAdapter(base: baseAdapter, scopes: [
+    "remainder": SuffixRowAdapter(fromIndex: 2)])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
+
+row // [a:0 b:1]
+row.scopes["remainder"] // [c:2 d:3]
+
+ +

To see how ScopeAdapter can be used, see Joined Queries Support.

+

SuffixRowAdapter

+ +

SuffixRowAdapter hides the first columns in a row:

+
// [b:1 c:2]
+let adapter = SuffixRowAdapter(fromIndex: 1)
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+

Raw SQLite Pointers

+ +

If not all SQLite APIs are exposed in GRDB, you can still use the SQLite C Interface and call SQLite C functions.

+ +

Those functions are embedded right into the GRDB module, regardless of the underlying SQLite implementation (system SQLite, SQLCipher, or custom SQLite build):

+
import GRDB
+
+let sqliteVersion = String(cString: sqlite3_libversion())
+
+ +

Raw pointers to database connections and statements are available through the Database.sqliteConnection and Statement.sqliteStatement properties:

+
try dbQueue.read { db in
+    // The raw pointer to a database connection:
+    let sqliteConnection = db.sqliteConnection
+
+    // The raw pointer to a statement:
+    let statement = try db.makeStatement(sql: "SELECT ...")
+    let sqliteStatement = statement.sqliteStatement
+}
+
+ +
+

:point_up: Notes

+ +
    +
  • Those pointers are owned by GRDB: don’t close connections or finalize statements created by GRDB.
  • +
  • GRDB opens SQLite connections in the “multi-thread mode”, which (oddly) means that they are not thread-safe. Make sure you touch raw databases and statements inside their dedicated dispatch queues.
  • +
  • Use the raw SQLite C Interface at your own risk. GRDB won’t prevent you from shooting yourself in the foot.
  • +
+
+

Records

+ +

On top of the SQLite API, GRDB provides protocols and a class that help manipulating database rows as regular objects named “records”:

+
try dbQueue.write { db in
+    if var place = try Place.fetchOne(db, id: 1) {
+        place.isFavorite = true
+        try place.update(db)
+    }
+}
+
+ +

Of course, you need to open a database connection, and create database tables first.

+ +

To define your custom records, you subclass the ready-made Record class, or you extend your structs and classes with protocols that come with focused sets of features: fetching methods, persistence methods, record comparison…

+ +

Extending structs with record protocols is more “swifty”. Subclassing the Record class is more “classic”. You can choose either way. See some examples of record definitions, and the list of record methods for an overview.

+ +
+

:point_up: Note: if you are familiar with Core Data’s NSManagedObject or Realm’s Object, you may experience a cultural shock: GRDB records are not uniqued, do not auto-update, and do not lazy-load. This is both a purpose, and a consequence of protocol-oriented programming. You should read How to build an iOS application with SQLite and GRDB.swift for a general introduction.

+ +

:bulb: Tip: after you have read this chapter, check the Good Practices for Designing Record Types Guide.

+ +

:bulb: Tip: see the Demo Applications for sample apps that uses records.

+
+ +

Overview

+ + + +

Protocols and the Record Class

+ + + +

Records in a Glance

+ + +

Inserting Records

+ +

To insert a record in the database, call the insert method:

+
let player = Player(name: "Arthur", email: "arthur@example.com")
+try player.insert(db)
+
+ +

:point_right: insert is available for subclasses of the Record class, and types that adopt the PersistableRecord protocol.

+

Fetching Records

+ +

To fetch records from the database, call a fetching method:

+
let arthur = try Player.fetchOne(db,            // Player?
+    sql: "SELECT * FROM players WHERE name = ?",
+    arguments: ["Arthur"])
+
+let bestPlayers = try Player                    // [Player]
+    .order(Column("score").desc)
+    .limit(10)
+    .fetchAll(db)
+
+let spain = try Country.fetchOne(db, id: "ES")  // Country?
+
+ +

:point_right: Fetching from raw SQL is available for subclasses of the Record class, and types that adopt the FetchableRecord protocol.

+ +

:point_right: Fetching without SQL, using the query interface, is available for subclasses of the Record class, and types that adopt both FetchableRecord and TableRecord protocol.

+

Updating Records

+ +

To update a record in the database, call the update method:

+
var player: Player = ...
+player.score = 1000
+try player.update(db)
+
+ +

It is possible to avoid useless updates:

+
// does not hit the database if score has not changed
+try player.updateChanges(db) {
+    $0.score = 1000
+}
+
+ +

See the query interface for batch updates:

+
try Player
+    .filter(Column("team") == "red")
+    .updateAll(db, Column("score") += 1)
+
+ +

:point_right: update methods are available for subclasses of the Record class, and types that adopt the PersistableRecord protocol. Batch updates are available on the TableRecord protocol.

+

Deleting Records

+ +

To delete a record in the database, call the delete method:

+
let player: Player = ...
+try player.delete(db)
+
+ +

You can also delete by primary key, unique key, or perform batch deletes (see Delete Requests):

+
try Player.deleteOne(db, id: 1)
+try Player.deleteOne(db, key: ["email": "arthur@example.com"])
+try Country.deleteAll(db, ids: ["FR", "US"])
+try Player
+    .filter(Column("email") == nil)
+    .deleteAll(db)
+
+ +

:point_right: delete methods are available for subclasses of the Record class, and types that adopt the PersistableRecord protocol. Batch deletes are available on the TableRecord protocol.

+

Counting Records

+ +

To count records, call the fetchCount method:

+
let playerCount: Int = try Player.fetchCount(db)
+
+let playerWithEmailCount: Int = try Player
+    .filter(Column("email") == nil)
+    .fetchCount(db)
+
+ +

:point_right: fetchCount is available for subclasses of the Record class, and types that adopt the TableRecord protocol.

+ +

Details follow:

+ + +

Record Protocols Overview

+ +

GRDB ships with three record protocols. Your own types will adopt one or several of them, according to the abilities you want to extend your types with.

+ +
    +
  • FetchableRecord is able to decode database rows.

    +
    struct Place: FetchableRecord { ... }
    +let places = try dbQueue.read { db in
    +    try Place.fetchAll(db, sql: "SELECT * FROM place")
    +}
    +
    + +
    +

    :bulb: Tip: FetchableRecord can derive its implementation from the standard Decodable protocol. See Codable Records for more information.

    +
    + +

    FetchableRecord can decode database rows, but it is not able to build SQL requests for you. For that, you also need TableRecord:

  • +
  • TableRecord is able to generate SQL queries:

    +
    struct Place: TableRecord { ... }
    +let placeCount = try dbQueue.read { db in
    +    // Generates and runs `SELECT COUNT(*) FROM place`
    +    try Place.fetchCount(db)
    +}
    +
    + +

    When a type adopts both TableRecord and FetchableRecord, it can load from those requests:

    +
    struct Place: TableRecord, FetchableRecord { ... }
    +try dbQueue.read { db in
    +    let places = try Place.order(Column("title")).fetchAll(db)
    +    let paris = try Place.fetchOne(id: 1)
    +}
    +
  • +
  • PersistableRecord is able to write: it can create, update, and delete rows in the database:

    +
    struct Place : PersistableRecord { ... }
    +try dbQueue.write { db in
    +    try Place.delete(db, id: 1)
    +    try Place(...).insert(db)
    +}
    +
    + +

    A persistable record can also compare itself against other records, and avoid useless database updates.

    + +
    +

    :bulb: Tip: PersistableRecord can derive its implementation from the standard Encodable protocol. See Codable Records for more information.

    +
  • +
+

FetchableRecord Protocol

+ +

The FetchableRecord protocol grants fetching methods to any type that can be built from a database row:

+
protocol FetchableRecord {
+    /// Row initializer
+    init(row: Row)
+}
+
+ +

To use FetchableRecord, subclass the Record class, or adopt it explicitly. For example:

+
struct Place {
+    var id: Int64?
+    var title: String
+    var coordinate: CLLocationCoordinate2D
+}
+
+extension Place : FetchableRecord {
+    init(row: Row) {
+        id = row["id"]
+        title = row["title"]
+        coordinate = CLLocationCoordinate2D(
+            latitude: row["latitude"],
+            longitude: row["longitude"])
+    }
+}
+
+ +

Rows also accept column enums:

+
extension Place : FetchableRecord {
+    enum Columns: String, ColumnExpression {
+        case id, title, latitude, longitude
+    }
+
+    init(row: Row) {
+        id = row[Columns.id]
+        title = row[Columns.title]
+        coordinate = CLLocationCoordinate2D(
+            latitude: row[Columns.latitude],
+            longitude: row[Columns.longitude])
+    }
+}
+
+ +

See column values for more information about the row[] subscript.

+ +

When your record type adopts the standard Decodable protocol, you don’t have to provide the implementation for init(row:). See Codable Records for more information:

+
// That's all
+struct Player: Decodable, FetchableRecord {
+    var id: Int64
+    var name: String
+    var score: Int
+}
+
+ +

FetchableRecord allows adopting types to be fetched from SQL queries:

+
try Place.fetchCursor(db, sql: "SELECT ...", arguments:...) // A Cursor of Place
+try Place.fetchAll(db, sql: "SELECT ...", arguments:...)    // [Place]
+try Place.fetchSet(db, sql: "SELECT ...", arguments:...)    // Set<Place>
+try Place.fetchOne(db, sql: "SELECT ...", arguments:...)    // Place?
+
+ +

See fetching methods for information about the fetchCursor, fetchAll, fetchSet and fetchOne methods. See StatementArguments for more information about the query arguments.

+ +
+

:point_up: Note: for performance reasons, the same row argument to init(row:) is reused during the iteration of a fetch query. If you want to keep the row for later use, make sure to store a copy: self.row = row.copy().

+ +

:point_up: Note: The FetchableRecord.init(row:) initializer fits the needs of most applications. But some application are more demanding than others. When FetchableRecord does not exactly provide the support you need, have a look at the Beyond FetchableRecord chapter.

+
+

TableRecord Protocol

+ +

The TableRecord protocol generates SQL for you. To use TableRecord, subclass the Record class, or adopt it explicitly:

+
protocol TableRecord {
+    static var databaseTableName: String { get }
+    static var databaseSelection: [SQLSelectable] { get }
+}
+
+ +

The databaseSelection type property is optional, and documented in the Columns Selected by a Request chapter.

+ +

The databaseTableName type property is the name of a database table. By default, it is derived from the type name:

+
struct Place: TableRecord { }
+print(Place.databaseTableName) // prints "place"
+
+ +

For example:

+ +
    +
  • Place: place
  • +
  • Country: country
  • +
  • PostalAddress: postalAddress
  • +
  • HTTPRequest: httpRequest
  • +
  • TOEFL: toefl
  • +
+ +

You can still provide a custom table name:

+
struct Place: TableRecord {
+    static let databaseTableName = "location"
+}
+print(Place.databaseTableName) // prints "location"
+
+ +

Subclasses of the Record class must always override their superclass’s databaseTableName property:

+
class Place: Record {
+    override class var databaseTableName: String { "place" }
+}
+print(Place.databaseTableName) // prints "place"
+
+ +

When a type adopts both TableRecord and FetchableRecord, it can be fetched using the query interface:

+
// SELECT * FROM place WHERE name = 'Paris'
+let paris = try Place.filter(nameColumn == "Paris").fetchOne(db)
+
+ +

TableRecord can also fetch deal with primary and unique keys: see Fetching by Key and Testing for Record Existence.

+

PersistableRecord Protocol

+ +

GRDB record types can create, update, and delete rows in the database.

+ +

Those abilities are granted by three protocols:

+
// Defines how a record encodes itself into the database
+protocol EncodableRecord {
+    /// Defines the values persisted in the database
+    func encode(to container: inout PersistenceContainer)
+}
+
+// Adds persistence methods
+protocol MutablePersistableRecord: TableRecord, EncodableRecord {
+    /// Optional method that lets your adopting type store its rowID upon
+    /// successful insertion. Don't call it directly: it is called for you.
+    mutating func didInsert(with rowID: Int64, for column: String?)
+}
+
+// Adds immutability
+protocol PersistableRecord: MutablePersistableRecord {
+    /// Non-mutating version of the optional didInsert(with:for:)
+    func didInsert(with rowID: Int64, for column: String?)
+}
+
+ +

Yes, three protocols instead of one. Here is how you pick one or the other:

+ +
    +
  • If your type is a class, choose PersistableRecord. On top of that, implement didInsert(with:for:) if the database table has an auto-incremented primary key.

  • +
  • If your type is a struct, and the database table has an auto-incremented primary key, choose MutablePersistableRecord, and implement didInsert(with:for:).

  • +
  • Otherwise, choose PersistableRecord, and ignore didInsert(with:for:).

  • +
+ +

The encode(to:) method defines which values (Bool, Int, String, Date, Swift enums, etc.) are assigned to database columns.

+ +

The optional didInsert method lets the adopting type store its rowID after successful insertion, and is only useful for tables that have an auto-incremented primary key. It is called from a protected dispatch queue, and serialized with all database updates.

+ +

To use the persistable protocols, subclass the Record class, or adopt one of them explicitly. For example:

+
extension Place : MutablePersistableRecord {
+    /// The values persisted in the database
+    func encode(to container: inout PersistenceContainer) {
+        container["id"] = id
+        container["title"] = title
+        container["latitude"] = coordinate.latitude
+        container["longitude"] = coordinate.longitude
+    }
+
+    // Update auto-incremented id upon successful insertion
+    mutating func didInsert(with rowID: Int64, for column: String?) {
+        id = rowID
+    }
+}
+
+var paris = Place(
+    id: nil,
+    title: "Paris",
+    coordinate: CLLocationCoordinate2D(latitude: 48.8534100, longitude: 2.3488000))
+
+try paris.insert(db)
+paris.id   // some value
+
+ +

Persistence containers also accept column enums:

+
extension Place : MutablePersistableRecord {
+    enum Columns: String, ColumnExpression {
+        case id, title, latitude, longitude
+    }
+
+    func encode(to container: inout PersistenceContainer) {
+        container[Columns.id] = id
+        container[Columns.title] = title
+        container[Columns.latitude] = coordinate.latitude
+        container[Columns.longitude] = coordinate.longitude
+    }
+}
+
+ +

When your record type adopts the standard Encodable protocol, you don’t have to provide the implementation for encode(to:). See Codable Records for more information:

+
// That's all
+struct Player: Encodable, MutablePersistableRecord {
+    var id: Int64?
+    var name: String
+    var score: Int
+
+    // Update auto-incremented id upon successful insertion
+    mutating func didInsert(with rowID: Int64, for column: String?) {
+        id = rowID
+    }
+}
+
+

Persistence Methods

+ +

Record subclasses and types that adopt PersistableRecord are given default implementations for methods that insert, update, and delete:

+
// INSERT
+try place.insert(db)
+let insertedPlace = try place.inserted(db) // non-mutating
+
+// UPDATE
+try place.update(db)
+try place.update(db, columns: ["title"])
+
+// Maybe UPDATE
+try place.updateChanges(db, from: otherPlace)
+try place.updateChanges(db) { $0.isFavorite = true }
+try place.updateChanges(db) // Record class only
+
+// INSERT or UPDATE
+try place.save(db)
+let savedPlace = place.saved(db) // non-mutating
+
+// DELETE
+try place.delete(db)
+
+// EXISTENCE CHECK
+let exists = try place.exists(db)
+
+ +

The TableRecord protocol comes with batch operations:

+
// UPDATE
+try Place.updateAll(db, ...)
+
+// DELETE
+try Place.deleteAll(db)
+try Place.deleteAll(db, ids:...)
+try Place.deleteAll(db, keys:...)
+try Place.deleteOne(db, id:...)
+try Place.deleteOne(db, key:...)
+
+ +
    +
  • All those methods can throw a DatabaseError.

  • +
  • update and updateChanges throw PersistenceError if the database does not contain any row for the primary key of the record.

  • +
  • save makes sure your values are stored in the database. It performs an UPDATE if the record has a non-null primary key, and then, if no row was modified, an INSERT. It directly performs an INSERT if the record has no primary key, or a null primary key.

  • +
  • delete and deleteOne returns whether a database row was deleted or not. deleteAll returns the number of deleted rows. updateAll returns the number of updated rows. updateChanges returns whether a database row was updated or not.

  • +
+ +

All primary keys are supported, including composite primary keys that span several columns, and the implicit rowid primary key.

+

Customizing the Persistence Methods

+ +

Your custom type may want to perform extra work when the persistence methods are invoked.

+ +

For example, it may want to have its UUID automatically set before inserting. Or it may want to validate its values before saving.

+ +

When you subclass Record, you simply have to override the customized method, and call super:

+
class Player : Record {
+    var uuid: UUID?
+
+    override func insert(_ db: Database) throws {
+        if uuid == nil {
+            uuid = UUID()
+        }
+        try super.insert(db)
+    }
+}
+
+ +

If you use the raw PersistableRecord protocol, use one of the special methods performInsert, performUpdate, performSave, performDelete, or performExists:

+
struct Link : PersistableRecord {
+    var url: URL
+
+    func insert(_ db: Database) throws {
+        try validate()
+        try performInsert(db)
+    }
+
+    func update(_ db: Database, columns: Set<String>) throws {
+        try validate()
+        try performUpdate(db, columns: columns)
+    }
+
+    func validate() throws {
+        if url.host == nil {
+            throw ValidationError("url must be absolute.")
+        }
+    }
+}
+
+ +
+

:point_up: Note: the special methods performInsert, performUpdate, etc. are reserved for your custom implementations. Do not use them elsewhere. Do not provide another implementation for those methods.

+ +

:point_up: Note: it is recommended that you do not implement your own version of the save method. Its default implementation forwards the job to update or insert: these are the methods that may need customization, not save.

+
+

Identifiable Records

+ +

When a record type maps a table with a single-column primary key, it is recommended to have it adopt the standard Identifiable protocol.

+
struct Player: Identifiable, FetchableRecord, PersistableRecord {
+    var id: Int64 // fulfills the Identifiable requirement
+    var name: String
+    var score: Int
+}
+
+ +

When id has a database-compatible type (Int64, Int, String, UUID, …), the Identifiable conformance unlocks type-safe record and request methods:

+
let player = try Player.fetchOne(db, id: 1)
+let players = try Player.fetchAll(db, ids: [1, 2, 3])
+let players = try Player.fetchSet(db, ids: [1, 2, 3])
+
+let request = Player.filter(id: 1)
+let request = Player.filter(ids: [1, 2, 3])
+
+let ids = try Player.selectID().fetchAll(db)
+let ids = try Player.filter(...).selectID().fetchSet(db)
+
+try Player.deleteOne(db, id: 1)
+try Player.deleteAll(db, ids: [1, 2, 3])
+
+ +
+

:point_up: Note: Identifiable is not available on all application targets, and not all tables have a single-column primary key. GRDB provides other methods that deal with primary and unique keys, but they won’t check the type of their arguments:

+
// Those methods are not type-checked
+try Player.fetchOne(db, key: 1)
+try Player.fetchOne(db, key: ["email": "arthur@example.com"])
+try Country.fetchAll(db, keys: ["FR", "US"])
+try Citizenship.fetchOne(db, key: ["citizenId": 1, "countryCode": "FR"])
+
+let request = Player.filter(key: 1)
+let request = Player.filter(keys: [1, 2, 3])
+
+try Player.deleteOne(db, key: 1)
+try Player.deleteAll(db, keys: [1, 2, 3])
+
+
+ +

Some database tables have a single-column primary key which is not called “id”:

+
try db.create(table: "country") { t in
+    t.column("isoCode", .text).notNull().primaryKey()
+    t.column("name", .text).notNull()
+    t.column("population", .integer).notNull()
+}
+
+ +

In this case, Identifiable conformance can be achieved, for example, by returning the primary key column from the id property:

+
struct Country: Identifiable, FetchableRecord, PersistableRecord {
+    var isoCode: String
+    var name: String
+    var population: Int
+
+    // Fulfill the Identifiable requirement
+    var id: String { isoCode }
+}
+
+let france = try dbQueue.read { db in
+    try Country.fetchOne(db, id: "FR")
+}
+
+

Codable Records

+ +

Record types that adopt an archival protocol (Codable, Encodable or Decodable) get free database support just by declaring conformance to the desired record protocols:

+
// Declare a record...
+struct Player: Codable, FetchableRecord, PersistableRecord {
+    var name: String
+    var score: Int
+}
+
+// ...and there you go:
+try dbQueue.write { db in
+    try Player(name: "Arthur", score: 100).insert(db)
+    let players = try Player.fetchAll(db)
+}
+
+ +

Codable records encode and decode their properties according to their own implementation of the Encodable and Decodable protocols. Yet databases have specific requirements:

+ +
    +
  • Properties are always coded according to their preferred database representation, when they have one (all values that adopt the DatabaseValueConvertible protocol).
  • +
  • You can customize the encoding and decoding of dates and uuids.
  • +
  • Complex properties (arrays, dictionaries, nested structs, etc.) are stored as JSON.
  • +
+ +

For more information about Codable records, see:

+ + + +
+

:bulb: Tip: see the Demo Applications for sample code that uses Codable records.

+
+

JSON Columns

+ +

When a Codable record contains a property that is not a simple value (Bool, Int, String, Date, Swift enums, etc.), that value is encoded and decoded as a JSON string. For example:

+
enum AchievementColor: String, Codable {
+    case bronze, silver, gold
+}
+
+struct Achievement: Codable {
+    var name: String
+    var color: AchievementColor
+}
+
+struct Player: Codable, FetchableRecord, PersistableRecord {
+    var name: String
+    var score: Int
+    var achievements: [Achievement] // stored in a JSON column
+}
+
+try! dbQueue.write { db in
+    // INSERT INTO player (name, score, achievements)
+    // VALUES (
+    //   'Arthur',
+    //   100,
+    //   '[{"color":"gold","name":"Use Codable Records"}]')
+    let achievement = Achievement(name: "Use Codable Records", color: .gold)
+    let player = Player(name: "Arthur", score: 100, achievements: [achievement])
+    try player.insert(db)
+}
+
+ +

GRDB uses the standard JSONDecoder and JSONEncoder from Foundation. By default, Data values are handled with the .base64 strategy, Date with the .millisecondsSince1970 strategy, and non conforming floats with the .throw strategy.

+ +

You can customize the JSON format by implementing those methods:

+
protocol FetchableRecord {
+    static func databaseJSONDecoder(for column: String) -> JSONDecoder
+}
+
+protocol EncodableRecord {
+    static func databaseJSONEncoder(for column: String) -> JSONEncoder
+}
+
+ +
+

:bulb: Tip: Make sure you set the JSONEncoder sortedKeys option, available from iOS 11.0+, macOS 10.13+, tvOS 9.0+ and watchOS 4.0+. This option makes sure that the JSON output is stable. This stability is required for Record Comparison to work as expected, and database observation tools such as ValueObservation to accurately recognize changed records.

+
+

Column Names Coding Strategies

+ +

By default, Codable Records store their values into database columns that match their coding keys: the teamID property is stored into the teamID column.

+ +

This behavior can be overridden, so that you can, for example, store the teamID property into the team_id column:

+
protocol FetchableRecord {
+    static var databaseColumnDecodingStrategy: DatabaseColumnDecodingStrategy { get }
+}
+
+protocol EncodableRecord {
+    static var databaseColumnEncodingStrategy: DatabaseColumnEncodingStrategy { get }
+}
+
+ +

See DatabaseColumnDecodingStrategy and DatabaseColumnEncodingStrategy to learn about all available strategies.

+

Date and UUID Coding Strategies

+ +

By default, Codable Records encode and decode their Date and UUID properties as described in the general Date and DateComponents and UUID chapters.

+ +

To sum up: dates encode themselves in the “YYYY-MM-DD HH:MM:SS.SSS” format, in the UTC time zone, and decode a variety of date formats and timestamps. UUIDs encode themselves as 16-bytes data blobs, and decode both 16-bytes data blobs and strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”.

+ +

Those behaviors can be overridden:

+
protocol FetchableRecord {
+    static var databaseDateDecodingStrategy: DatabaseDateDecodingStrategy { get }
+}
+
+protocol EncodableRecord {
+    static var databaseDateEncodingStrategy: DatabaseDateEncodingStrategy { get }
+    static var databaseUUIDEncodingStrategy: DatabaseUUIDEncodingStrategy { get }
+}
+
+ +

See DatabaseDateDecodingStrategy, DatabaseDateEncodingStrategy, and DatabaseUUIDEncodingStrategy to learn about all available strategies.

+ +

There is no customization of uuid decoding, because UUID can already decode all its encoded variants (16-bytes blobs and uuid strings, both uppercase and lowercase).

+ +

Customized date and uuid handling apply:

+ +
    +
  • When encoding and decoding database rows to and from records (fetching and persistence methods).
  • +
  • In requests by single-column primary key: fetchOne(_:id:), filter(id:), deleteAll(_:keys:), etc.
  • +
+ +

They do not apply in other requests based on date or uuid values.

+ +

So make sure that dates and uuids are properly encoded in your requests. For example:

+
struct Player: Codable, FetchableRecord, PersistableRecord, Identifiable {
+    // UUIDs are stored as strings
+    static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
+    var id: UUID
+    ...
+}
+
+try dbQueue.write { db in
+    let uuid = UUID()
+    let player = Player(id: uuid, ...)
+
+    // OK: inserts a player in the database, with a string uuid
+    try player.insert(db)
+
+    // OK: performs a string-based query, finds the inserted player
+    _ = try Player.filter(id: uuid).fetchOne(db)
+
+    // NOT OK: performs a blob-based query, fails to find the inserted player
+    _ = try Player.filter(Column("id") == uuid).fetchOne(db)
+
+    // OK: performs a string-based query, finds the inserted player
+    _ = try Player.filter(Column("id") == uuid.uuidString).fetchOne(db)
+}
+
+

The userInfo Dictionary

+ +

Your Codable Records can be stored in the database, but they may also have other purposes. In this case, you may need to customize their implementations of Decodable.init(from:) and Encodable.encode(to:), depending on the context.

+ +

The standard way to provide such context is the userInfo dictionary. Implement those properties:

+
protocol FetchableRecord {
+    static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] { get }
+}
+
+protocol EncodableRecord {
+    static var databaseEncodingUserInfo: [CodingUserInfoKey: Any] { get }
+}
+
+ +

For example, here is a Player type that customizes its decoding:

+
// A key that holds a decoder's name
+let decoderName = CodingUserInfoKey(rawValue: "decoderName")!
+
+struct Player: FetchableRecord, Decodable {
+    init(from decoder: Decoder) throws {
+        // Print the decoder name
+        let decoderName = decoder.userInfo[decoderName] as? String
+        print("Decoded from \(decoderName ?? "unknown decoder")")
+        ...
+    }
+}
+
+ +

You can have a specific decoding from JSON…

+
// prints "Decoded from JSON"
+let decoder = JSONDecoder()
+decoder.userInfo = [decoderName: "JSON"]
+let player = try decoder.decode(Player.self, from: jsonData)
+
+ +

… and another one from database rows:

+
extension Player: FetchableRecord {
+    static let databaseDecodingUserInfo: [CodingUserInfoKey: Any] = [decoderName: "database row"]
+}
+
+// prints "Decoded from database row"
+let player = try Player.fetchOne(db, ...)
+
+ +
+

:point_up: Note: make sure the databaseDecodingUserInfo and databaseEncodingUserInfo properties are explicitly declared as [CodingUserInfoKey: Any]. If they are not, the Swift compiler may silently miss the protocol requirement, resulting in sticky empty userInfo.

+
+

Tip: Derive Columns from Coding Keys

+ +

Codable types are granted with a CodingKeys enum. You can use them to safely define database columns:

+
struct Player: Codable {
+    var id: Int64
+    var name: String
+    var score: Int
+}
+
+extension Player: FetchableRecord, PersistableRecord {
+    enum Columns {
+        static let id = Column(CodingKeys.id)
+        static let name = Column(CodingKeys.name)
+        static let score = Column(CodingKeys.score)
+    }
+}
+
+ +

See the query interface and Good Practices for Designing Record Types for further information.

+

Record Class

+ +

Record is a class that is designed to be subclassed. It inherits its features from the FetchableRecord, TableRecord, and PersistableRecord protocols. On top of that, Record instances can compare against previous versions of themselves in order to avoid useless updates.

+ +

Record subclasses define their custom database relationship by overriding database methods. For example:

+
class Place: Record {
+    var id: Int64?
+    var title: String
+    var isFavorite: Bool
+    var coordinate: CLLocationCoordinate2D
+
+    init(id: Int64?, title: String, isFavorite: Bool, coordinate: CLLocationCoordinate2D) {
+        self.id = id
+        self.title = title
+        self.isFavorite = isFavorite
+        self.coordinate = coordinate
+        super.init()
+    }
+
+    /// The table name
+    override class var databaseTableName: String { "place" }
+
+    /// The table columns
+    enum Columns: String, ColumnExpression {
+        case id, title, favorite, latitude, longitude
+    }
+
+    /// Creates a record from a database row
+    required init(row: Row) {
+        id = row[Columns.id]
+        title = row[Columns.title]
+        isFavorite = row[Columns.favorite]
+        coordinate = CLLocationCoordinate2D(
+            latitude: row[Columns.latitude],
+            longitude: row[Columns.longitude])
+        super.init(row: row)
+    }
+
+    /// The values persisted in the database
+    override func encode(to container: inout PersistenceContainer) {
+        container[Columns.id] = id
+        container[Columns.title] = title
+        container[Columns.favorite] = isFavorite
+        container[Columns.latitude] = coordinate.latitude
+        container[Columns.longitude] = coordinate.longitude
+    }
+
+    /// Update record ID after a successful insertion
+    override func didInsert(with rowID: Int64, for column: String?) {
+        id = rowID
+    }
+}
+
+

Record Comparison

+ +

Records that adopt the EncodableRecord protocol can compare against other records, or against previous versions of themselves.

+ +

This helps avoiding costly UPDATE statements when a record has not been edited.

+ + +

The updateChanges Methods

+ +

The updateChanges methods perform a database update of the changed columns only (and does nothing if record has no change).

+ +
    +
  • updateChanges(_:from:)

    + +

    This method lets you compare two records:

    +
    if let oldPlayer = try Player.fetchOne(db, id: 42) {
    +    var newPlayer = oldPlayer
    +    newPlayer.score = 100
    +    if try newPlayer.updateChanges(db, from: oldPlayer) {
    +        print("player was modified, and updated in the database")
    +    } else {
    +        print("player was not modified, and database was not hit")
    +    }
    +}
    +
  • +
  • updateChanges(_:with:)

    + +

    This method lets you update a record in place:

    +
    if var player = try Player.fetchOne(db, id: 42) {
    +    let modified = try player.updateChanges(db) {
    +        $0.score = 100
    +    }
    +    if modified {
    +        print("player was modified, and updated in the database")
    +    } else {
    +        print("player was not modified, and database was not hit")
    +    }
    +}
    +
  • +
  • updateChanges(_:) (Record class only)

    + +

    Instances of the Record class are able to compare against themselves, and know if they have changes that have not been saved since the last fetch or saving:

    +
    // Record class only
    +if let player = try Player.fetchOne(db, id: 42) {
    +    player.score = 100
    +    if try player.updateChanges(db) {
    +        print("player was modified, and updated in the database")
    +    } else {
    +        print("player was not modified, and database was not hit")
    +    }
    +}
    +
  • +
+

The databaseEquals Method

+ +

This method returns whether two records have the same database representation:

+
let oldPlayer: Player = ...
+var newPlayer: Player = ...
+if newPlayer.databaseEquals(oldPlayer) == false {
+    try newPlayer.save(db)
+}
+
+ +
+

:point_up: Note: The comparison is performed on the database representation of records. As long as your record type adopts the EncodableRecord protocol, you don’t need to care about Equatable.

+
+

The databaseChanges and hasDatabaseChanges Methods

+ +

databaseChanges(from:) returns a dictionary of differences between two records:

+
let oldPlayer = Player(id: 1, name: "Arthur", score: 100)
+let newPlayer = Player(id: 1, name: "Arthur", score: 1000)
+for (column, oldValue) in newPlayer.databaseChanges(from: oldPlayer) {
+    print("\(column) was \(oldValue)")
+}
+// prints "score was 100"
+
+ +

The Record class is able to compare against itself:

+
// Record class only
+let player = Player(id: 1, name: "Arthur", score: 100)
+try player.insert(db)
+player.score = 1000
+for (column, oldValue) in player.databaseChanges {
+    print("\(column) was \(oldValue)")
+}
+// prints "score was 100"
+
+ +

Record instances also have a hasDatabaseChanges property:

+
// Record class only
+player.score = 1000
+if player.hasDatabaseChanges {
+    try player.save(db)
+}
+
+ +

Record.hasDatabaseChanges is false after a Record instance has been fetched or saved into the database. Subsequent modifications may set it, or not: hasDatabaseChanges is based on value comparison. Setting a property to the same value does not set the changed flag:

+
let player = Player(name: "Barbara", score: 750)
+player.hasDatabaseChanges // true
+
+try player.insert(db)
+player.hasDatabaseChanges // false
+
+player.name = "Barbara"
+player.hasDatabaseChanges // false
+
+player.score = 1000
+player.hasDatabaseChanges // true
+player.databaseChanges    // ["score": 750]
+
+ +

For an efficient algorithm which synchronizes the content of a database table with a JSON payload, check groue/SortedDifference.

+

Record Customization Options

+ +

GRDB records come with many default behaviors, that are designed to fit most situations. Many of those defaults can be customized for your specific needs:

+ + + +

Codable Records have a few extra options:

+ + +

Conflict Resolution

+ +

Insertions and updates can create conflicts: for example, a query may attempt to insert a duplicate row that violates a unique index.

+ +

Those conflicts normally end with an error. Yet SQLite let you alter the default behavior, and handle conflicts with specific policies. For example, the INSERT OR REPLACE statement handles conflicts with the “replace” policy which replaces the conflicting row instead of throwing an error.

+ +

The five different policies are: abort (the default), replace, rollback, fail, and ignore.

+ +

SQLite let you specify conflict policies at two different places:

+ +
    +
  • In the definition of the database table:

    +
    // CREATE TABLE player (
    +//     id INTEGER PRIMARY KEY AUTOINCREMENT,
    +//     email TEXT UNIQUE ON CONFLICT REPLACE
    +// )
    +try db.create(table: "player") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("email", .text).unique(onConflict: .replace) // <--
    +}
    +
    +// Despite the unique index on email, both inserts succeed.
    +// The second insert replaces the first row:
    +try db.execute(sql: "INSERT INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +try db.execute(sql: "INSERT INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +
  • +
  • In each modification query:

    +
    // CREATE TABLE player (
    +//     id INTEGER PRIMARY KEY AUTOINCREMENT,
    +//     email TEXT UNIQUE
    +// )
    +try db.create(table: "player") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("email", .text).unique()
    +}
    +
    +// Again, despite the unique index on email, both inserts succeed.
    +try db.execute(sql: "INSERT OR REPLACE INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +try db.execute(sql: "INSERT OR REPLACE INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +
  • +
+ +

When you want to handle conflicts at the query level, specify a custom persistenceConflictPolicy in your type that adopts the PersistableRecord protocol. It will alter the INSERT and UPDATE queries run by the insert, update and save persistence methods:

+
protocol MutablePersistableRecord {
+    /// The policy that handles SQLite conflicts when records are
+    /// inserted or updated.
+    ///
+    /// This property is optional: its default value uses the ABORT
+    /// policy for both insertions and updates, so that GRDB generate
+    /// regular INSERT and UPDATE queries.
+    static var persistenceConflictPolicy: PersistenceConflictPolicy { get }
+}
+
+struct Player : MutablePersistableRecord {
+    static let persistenceConflictPolicy = PersistenceConflictPolicy(
+        insert: .replace,
+        update: .replace)
+}
+
+// INSERT OR REPLACE INTO player (...) VALUES (...)
+try player.insert(db)
+
+ +
+

:point_up: Note: the ignore policy does not play well at all with the didInsert method which notifies the rowID of inserted records. Choose your poison:

+ +
    +
  • if you specify the ignore policy in the database table definition, don’t implement the didInsert method: it will be called with some random id in case of failed insert.
  • +
  • if you specify the ignore policy at the query level, the didInsert method is never called.
  • +
+ +

:point_up: Note: The replace policy may have to delete rows so that inserts and updates can succeed. Those deletions are not reported to transaction observers (this might change in a future release of SQLite).

+
+

The Implicit RowID Primary Key

+ +

All SQLite tables have a primary key. Even when the primary key is not explicit:

+
// No explicit primary key
+try db.create(table: "event") { t in
+    t.column("message", .text)
+    t.column("date", .datetime)
+}
+
+// No way to define an explicit primary key
+try db.create(virtualTable: "book", using: FTS4()) { t in
+    t.column("title")
+    t.column("author")
+    t.column("body")
+}
+
+ +

The implicit primary key is stored in the hidden column rowid. Hidden means that SELECT * does not select it, and yet it can be selected and queried: SELECT *, rowid ... WHERE rowid = 1.

+ +

Some GRDB methods will automatically use this hidden column when a table has no explicit primary key:

+
// SELECT * FROM event WHERE rowid = 1
+let event = try Event.fetchOne(db, id: 1)
+
+// DELETE FROM book WHERE rowid = 1
+try Book.deleteOne(db, id: 1)
+
+

Exposing the RowID Column

+ +

By default, a record type that wraps a table without any explicit primary key doesn’t know about the hidden rowid column.

+ +

Without primary key, records don’t have any identity, and the persistence method can behave in undesired fashion: update() throws errors, save() always performs insertions and may break constraints, exists() is always false.

+ +

When SQLite won’t let you provide an explicit primary key (as in full-text tables, for example), you may want to make your record type fully aware of the hidden rowid column:

+ +
    +
  1. Have the databaseSelection static property (from the TableRecord protocol) return the hidden rowid column:

    +
    struct Event : TableRecord {
    +    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
    +}
    +
    +// When you subclass Record, you need an override:
    +class Book : Record {
    +    override class var databaseSelection: [SQLSelectable] {
    +        [AllColums(), Column.rowID]
    +    }
    +}
    +
    + +

    GRDB will then select the rowid column by default:

    +
    // SELECT *, rowid FROM event
    +let events = try Event.fetchAll(db)
    +
  2. +
  3. Have init(row:) from the FetchableRecord protocol consume the “rowid” column:

    +
    struct Event : FetchableRecord {
    +    var id: Int64?
    +
    +    init(row: Row) {
    +        id = row[Column.rowID] // or `row[.rowID]` with Swift 5.5+
    +    }
    +}
    +
    + +

    Your fetched records will then know their ids:

    +
    let event = try Event.fetchOne(db)!
    +event.id // some value
    +
  4. +
  5. Encode the rowid in encode(to:), and keep it in the didInsert(with:for:) method (both from the PersistableRecord and MutablePersistableRecord protocols):

    +
    struct Event : MutablePersistableRecord {
    +    var id: Int64?
    +
    +    func encode(to container: inout PersistenceContainer) {
    +        container[Column.rowID] = id // or `container[.rowID]` with Swift 5.5+
    +        container["message"] = message
    +        container["date"] = date
    +    }
    +
    +    // Update auto-incremented id upon successful insertion
    +    mutating func didInsert(with rowID: Int64, for column: String?) {
    +        id = rowID
    +    }
    +}
    +
    + +

    You will then be able to track your record ids, update them, or check for their existence:

    +
    let event = Event(message: "foo", date: Date())
    +
    +// Insertion sets the record id:
    +try event.insert(db)
    +event.id // some value
    +
    +// Record can be updated:
    +event.message = "bar"
    +try event.update(db)
    +
    +// Record knows if it exists:
    +event.exists(db) // true
    +
  6. +
+

Beyond FetchableRecord

+ +

Some GRDB users eventually discover that the FetchableRecord protocol does not fit all situations. Use cases that are not well handled by FetchableRecord include:

+ +
    +
  • Your application needs polymorphic row decoding: it decodes some type or another, depending on the values contained in a database row.

  • +
  • Your application needs to decode rows with a context: each decoded value should be initialized with some extra value that does not come from the database.

  • +
  • Your application needs a record type that supports untrusted databases, and may fail at decoding database rows (throw an error when a row contains invalid values).

  • +
+ +

Since those use cases are not well handled by FetchableRecord, don’t try to implement them on top of this protocol: you’ll just fight the framework.

+ +

Instead, please have a look at the CustomizedDecodingOfDatabaseRows playground. You’ll run some sample code, and learn how to escape FetchableRecord when you need. And remember that leaving FetchableRecord will not deprive you of query interface requests and generally all SQL generation features of the TableRecord and PersistableRecord protocols.

+

Examples of Record Definitions

+ +

We will show below how to declare a record type for the following database table:

+
try dbQueue.write { db in
+    try db.create(table: "place") { t in
+        t.autoIncrementedPrimaryKey("id")
+        t.column("title", .text).notNull()
+        t.column("isFavorite", .boolean).notNull().defaults(to: false)
+        t.column("longitude", .double).notNull()
+        t.column("latitude", .double).notNull()
+    }
+}
+
+ +

Each one of the three examples below is correct. You will pick one or the other depending on your personal preferences and the requirements of your application:

+ +
+ Define a Codable struct, and adopt the record protocols you need + +This is the shortest way to define a record type. + +See the [Record Protocols Overview](#record-protocols-overview), and [Codable Records] for more information. + +“`swift +struct Place: Codable { + var id: Int64? + var title: String + var isFavorite: Bool + private var latitude: CLLocationDegrees + private var longitude: CLLocationDegrees + + var coordinate: CLLocationCoordinate2D { + get { + CLLocationCoordinate2D( + latitude: latitude, + longitude: longitude) + } + set { + latitude = newValue.latitude + longitude = newValue.longitude + } + } +} + +// SQL generation +extension Place: TableRecord { + /// The table columns + enum Columns { + static let id = Column(CodingKeys.id) + static let title = Column(CodingKeys.title) + static let isFavorite = Column(CodingKeys.isFavorite) + static let latitude = Column(CodingKeys.latitude) + static let longitude = Column(CodingKeys.longitude) + } +} + +// Fetching methods +extension Place: FetchableRecord { } + +// Persistence methods +extension Place: MutablePersistableRecord { + // Update auto-incremented id upon successful insertion + mutating func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +”` + +
+ +
+ Define a plain struct, and adopt the record protocols you need + +See the [Record Protocols Overview](#record-protocols-overview) for more information. + +“`swift +struct Place { + var id: Int64? + var title: String + var isFavorite: Bool + var coordinate: CLLocationCoordinate2D +} + +// SQL generation +extension Place: TableRecord { + /// The table columns + enum Columns: String, ColumnExpression { + case id, title, isFavorite, latitude, longitude + } +} + +// Fetching methods +extension Place: FetchableRecord { + /// Creates a record from a database row + init(row: Row) { + id = row[Columns.id] + title = row[Columns.title] + isFavorite = row[Columns.isFavorite] + coordinate = CLLocationCoordinate2D( + latitude: row[Columns.latitude], + longitude: row[Columns.longitude]) + } +} + +// Persistence methods +extension Place: MutablePersistableRecord { + /// The values persisted in the database + func encode(to container: inout PersistenceContainer) { + container[Columns.id] = id + container[Columns.title] = title + container[Columns.isFavorite] = isFavorite + container[Columns.latitude] = coordinate.latitude + container[Columns.longitude] = coordinate.longitude + } + + // Update auto-incremented id upon successful insertion + mutating func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +”` + +
+ +
+ Define a plain struct optimized for fetching performance + +This struct derives its persistence methods from the standard Encodable protocol (see [Codable Records]), but performs optimized row decoding by accessing database columns with numeric indexes. + +See the [Record Protocols Overview](#record-protocols-overview) for more information. + +“`swift +struct Place: Encodable { + var id: Int64? + var title: String + var isFavorite: Bool + private var latitude: CLLocationDegrees + private var longitude: CLLocationDegrees + + var coordinate: CLLocationCoordinate2D { + get { + CLLocationCoordinate2D( + latitude: latitude, + longitude: longitude) + } + set { + latitude = newValue.latitude + longitude = newValue.longitude + } + } +} + +// SQL generation +extension Place: TableRecord { + /// The table columns + enum Columns { + static let id = Column(CodingKeys.id) + static let title = Column(CodingKeys.title) + static let isFavorite = Column(CodingKeys.isFavorite) + static let latitude = Column(CodingKeys.latitude) + static let longitude = Column(CodingKeys.longitude) + } + + /// Arrange the selected columns and lock their order + static let databaseSelection: [SQLSelectable] = [ + Columns.id, + Columns.title, + Columns.favorite, + Columns.latitude, + Columns.longitude] +} + +// Fetching methods +extension Place: FetchableRecord { + /// Creates a record from a database row + init(row: Row) { + // For high performance, use numeric indexes that match the + // order of Place.databaseSelection + id = row[0] + title = row[1] + isFavorite = row[2] + coordinate = CLLocationCoordinate2D( + latitude: row[3], + longitude: row[4]) + } +} + +// Persistence methods +extension Place: MutablePersistableRecord { + // Update auto-incremented id upon successful insertion + mutating func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +”` + +
+ +
+ Subclass the Record class + +See the [Record class](#record-class) for more information. + +“`swift +class Place: Record { + var id: Int64? + var title: String + var isFavorite: Bool + var coordinate: CLLocationCoordinate2D + + init(id: Int64?, title: String, isFavorite: Bool, coordinate: CLLocationCoordinate2D) { + self.id = id + self.title = title + self.isFavorite = isFavorite + self.coordinate = coordinate + super.init() + } + + /// The table name + override class var databaseTableName: String { "place” } + + /// The table columns + enum Columns: String, ColumnExpression { + case id, title, isFavorite, latitude, longitude + } + + /// Creates a record from a database row + required init(row: Row) { + id = row[Columns.id] + title = row[Columns.title] + isFavorite = row[Columns.isFavorite] + coordinate = CLLocationCoordinate2D( + latitude: row[Columns.latitude], + longitude: row[Columns.longitude]) + super.init(row: row) + } + + /// The values persisted in the database + override func encode(to container: inout PersistenceContainer) { + container[Columns.id] = id + container[Columns.title] = title + container[Columns.isFavorite] = isFavorite + container[Columns.latitude] = coordinate.latitude + container[Columns.longitude] = coordinate.longitude + } + + // Update auto-incremented id upon successful insertion + override func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +“` + +
+

List of Record Methods

+ +

This is the list of record methods, along with their required protocols. The Record class adopts all these protocols, and adds a few extra methods.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodProtocolsNotes
Core Methods
init(row:)FetchableRecord
Type.databaseTableNameTableRecord
Type.databaseSelectionTableRecord*
Type.persistenceConflictPolicyPersistableRecord*
record.encode(to:)EncodableRecord
record.didInsert(with:for:)PersistableRecord
Insert and Update Records
record.insert(db)PersistableRecord
record.inserted(db)PersistableRecord
record.save(db)PersistableRecord
record.saved(db)PersistableRecord
record.update(db)PersistableRecord
record.update(db, columns:...)PersistableRecord
record.updateChanges(db, from:...)PersistableRecord*
record.updateChanges(db) { ... }PersistableRecord*
record.updateChanges(db)Record*
Type.updateAll(db, ...)TableRecord
Type.filter(...).updateAll(db, ...)TableRecord²
Delete Records
record.delete(db)PersistableRecord
Type.deleteOne(db, key:...)TableRecord¹
Type.deleteOne(db, id:...)TableRecord & Identifiable¹
Type.deleteAll(db)TableRecord
Type.deleteAll(db, keys:...)TableRecord¹
Type.deleteAll(db, ids:...)TableRecord & Identifiable¹
Type.filter(...).deleteAll(db)TableRecord²
Check Record Existence
record.exists(db)PersistableRecord
Type.exists(db, key: ...)TableRecord¹
Type.exists(db, id: ...)TableRecord & Identifiable¹
Type.filter(...).isEmpty(db)TableRecord²
Convert Record to Dictionary
record.databaseDictionaryEncodableRecord
Count Records
Type.fetchCount(db)TableRecord
Type.filter(...).fetchCount(db)TableRecord²
Fetch Record Cursors
Type.fetchCursor(db)FetchableRecord & TableRecord
Type.fetchCursor(db, keys:...)FetchableRecord & TableRecord¹
Type.fetchCursor(db, ids:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchCursor(db, sql: sql)FetchableRecord³
Type.fetchCursor(statement)FetchableRecord⁴
Type.filter(...).fetchCursor(db)FetchableRecord & TableRecord²
Fetch Record Arrays
Type.fetchAll(db)FetchableRecord & TableRecord
Type.fetchAll(db, keys:...)FetchableRecord & TableRecord¹
Type.fetchAll(db, ids:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchAll(db, sql: sql)FetchableRecord³
Type.fetchAll(statement)FetchableRecord⁴
Type.filter(...).fetchAll(db)FetchableRecord & TableRecord²
Fetch Record Sets
Type.fetchSet(db)FetchableRecord & TableRecord
Type.fetchSet(db, keys:...)FetchableRecord & TableRecord¹
Type.fetchSet(db, ids:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchSet(db, sql: sql)FetchableRecord³
Type.fetchSet(statement)FetchableRecord⁴
Type.filter(...).fetchSet(db)FetchableRecord & TableRecord²
Fetch Individual Records
Type.fetchOne(db)FetchableRecord & TableRecord
Type.fetchOne(db, key:...)FetchableRecord & TableRecord¹
Type.fetchOne(db, id:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchOne(db, sql: sql)FetchableRecord³
Type.fetchOne(statement)FetchableRecord⁴
Type.filter(...).fetchOne(db)FetchableRecord & TableRecord²
Codable Records
Type.databaseDecodingUserInfoFetchableRecord*
Type.databaseJSONDecoder(for:)FetchableRecord*
Type.databaseDateDecodingStrategyFetchableRecord*
Type.databaseEncodingUserInfoEncodableRecord*
Type.databaseJSONEncoder(for:)EncodableRecord*
Type.databaseDateEncodingStrategyEncodableRecord*
Type.databaseUUIDEncodingStrategyEncodableRecord*
Define Associations
Type.belongsTo(...)TableRecord*
Type.hasMany(...)TableRecord*
Type.hasOne(...)TableRecord*
Type.hasManyThrough(...)TableRecord*
Type.hasOneThrough(...)TableRecord*
Building Query Interface Requests
record.request(for:...)TableRecord & EncodableRecord*
Type.all()TableRecord²
Type.none()TableRecord²
Type.select(...)TableRecord²
Type.select(..., as:...)TableRecord²
Type.selectID()TableRecord & Identifiable*
Type.annotated(with:...)TableRecord²
Type.filter(...)TableRecord²
Type.filter(id:)TableRecord & Identifiable*
Type.filter(ids:)TableRecord & Identifiable*
Type.matching(...)TableRecord²
Type.including(all:)TableRecord²
Type.including(optional:)TableRecord²
Type.including(required:)TableRecord²
Type.joining(optional:)TableRecord²
Type.joining(required:)TableRecord²
Type.group(...)TableRecord²
Type.groupByPrimaryKey()TableRecord²
Type.having(...)TableRecord²
Type.order(...)TableRecord²
Type.orderByPrimaryKey()TableRecord²
Type.limit(...)TableRecord²
Type.with(...)TableRecord²
Record Comparison
record.databaseEquals(...)EncodableRecord
record.databaseChanges(from:...)EncodableRecord
record.updateChanges(db, from:...)PersistableRecord
record.updateChanges(db) { ... }PersistableRecord
record.hasDatabaseChangesRecord
record.databaseChangesRecord
record.updateChanges(db)Record
+ +

¹ All unique keys are supported: primary keys (single-column, composite, implicit RowID) and unique indexes:

+
try Player.fetchOne(db, id: 1)                                // Player?
+try Player.fetchOne(db, key: ["email": "arthur@example.com"]) // Player?
+try Country.fetchAll(db, keys: ["FR", "US"])                  // [Country]
+
+ +

² See Fetch Requests:

+
let request = Player.filter(emailColumn != nil).order(nameColumn)
+let players = try request.fetchAll(db)  // [Player]
+let count = try request.fetchCount(db)  // Int
+
+ +

³ See SQL queries:

+
let player = try Player.fetchOne(db, sql: "SELECT * FROM player WHERE id = ?", arguments: [1]) // Player?
+
+ +

⁴ See Prepared Statements:

+
let statement = try db.makeStatement(sql: "SELECT * FROM player WHERE id = ?")
+let player = try Player.fetchOne(statement, arguments: [1])  // Player?
+
+

The Query Interface

+ +

The query interface lets you write pure Swift instead of SQL:

+
try dbQueue.write { db in
+    // Update database schema
+    try db.create(table: "wine") { t in ... }
+
+    // Fetch records
+    let wines = try Wine
+        .filter(originColumn == "Burgundy")
+        .order(priceColumn)
+        .fetchAll(db)
+
+    // Count
+    let count = try Wine
+        .filter(colorColumn == Color.red)
+        .fetchCount(db)
+
+    // Update
+    try Wine
+        .filter(originColumn == "Burgundy")
+        .updateAll(db, priceColumn *= 0.75)
+
+    // Delete
+    try Wine
+        .filter(corkedColumn == true)
+        .deleteAll(db)
+}
+
+ +

You need to open a database connection before you can query the database.

+ +

Please bear in mind that the query interface can not generate all possible SQL queries. You may also prefer writing SQL, and this is just OK. From little snippets to full queries, your SQL skills are welcome:

+
try dbQueue.write { db in
+    // Update database schema (with SQL)
+    try db.execute(sql: "CREATE TABLE wine (...)")
+
+    // Fetch records (with SQL)
+    let wines = try Wine.fetchAll(db,
+        sql: "SELECT * FROM wine WHERE origin = ? ORDER BY price",
+        arguments: ["Burgundy"])
+
+    // Count (with an SQL snippet)
+    let count = try Wine
+        .filter(sql: "color = ?", arguments: [Color.red])
+        .fetchCount(db)
+
+    // Update (with SQL)
+    try db.execute(sql: "UPDATE wine SET price = price * 0.75 WHERE origin = 'Burgundy'")
+
+    // Delete (with SQL)
+    try db.execute(sql: "DELETE FROM wine WHERE corked")
+}
+
+ +

So don’t miss the SQL API.

+ +
+

:point_up: Note: the generated SQL may change between GRDB releases, without notice: don’t have your application rely on any specific SQL output.

+
+ + +

Database Schema

+ +

Once granted with a database connection, you can setup your database schema without writing SQL:

+ + +

Create Tables

+
// CREATE TABLE place (
+//   id INTEGER PRIMARY KEY AUTOINCREMENT,
+//   title TEXT,
+//   favorite BOOLEAN NOT NULL DEFAULT 0,
+//   latitude DOUBLE NOT NULL,
+//   longitude DOUBLE NOT NULL
+// )
+try db.create(table: "place") { t in
+    t.autoIncrementedPrimaryKey("id")
+    t.column("title", .text)
+    t.column("favorite", .boolean).notNull().defaults(to: false)
+    t.column("longitude", .double).notNull()
+    t.column("latitude", .double).notNull()
+}
+
+ +

The create(table:) method covers nearly all SQLite table creation features. For virtual tables, see Full-Text Search, or use raw SQL.

+ +

SQLite itself has many reference documents about table creation: CREATE TABLE, Datatypes In SQLite Version 3, SQLite Foreign Key Support, ON CONFLICT, The WITHOUT ROWID Optimization.

+ +

Configure table creation:

+
// CREATE TABLE example ( ... )
+try db.create(table: "example") { t in ... }
+
+// CREATE TEMPORARY TABLE example IF NOT EXISTS (
+try db.create(table: "example", temporary: true, ifNotExists: true) { t in ... }
+
+ +
+

:bulb: Tip: database table names should be singular, and camel-cased. Make them look like Swift identifiers: place, country, postalAddress, ‘httpRequest’.

+ +

This will help you using Associations when you need them. Database table names that follow another naming convention are totally OK, but you will need to perform extra configuration.

+ +

:point_up: Note: WITHOUT ROWID tables can not be tracked with Database Observation tools.

+
+ +

Add regular columns with their name and eventual type (text, integer, double, numeric, boolean, blob, date and datetime) - see SQLite data types:

+
// CREATE TABLE example (
+//   a,
+//   name TEXT,
+//   creationDate DATETIME,
+try db.create(table: "example") { t in
+    t.column("a")
+    t.column("name", .text)
+    t.column("creationDate", .datetime)
+
+ +

Define not null columns, and set default values:

+
    // email TEXT NOT NULL,
+    t.column("email", .text).notNull()
+
+    // name TEXT NOT NULL DEFAULT 'Anonymous',
+    t.column("name", .text).notNull().defaults(to: "Anonymous")
+
+ +

Use an individual column as primary, unique, or foreign key. When defining a foreign key, the referenced column is the primary key of the referenced table (unless you specify otherwise):

+
    // id INTEGER PRIMARY KEY AUTOINCREMENT,
+    t.autoIncrementedPrimaryKey("id")
+
+    // uuid TEXT PRIMARY KEY,
+    t.column("uuid", .text).primaryKey()
+
+    // email TEXT UNIQUE,
+    t.column("email", .text).unique()
+
+    // countryCode TEXT REFERENCES country(code) ON DELETE CASCADE,
+    t.column("countryCode", .text).references("country", onDelete: .cascade)
+
+ +
+

:bulb: Tip: when you need an integer primary key that automatically generates unique values, it is highly recommended that you use the autoIncrementedPrimaryKey method:

+
try db.create(table: "example") { t in
+    t.autoIncrementedPrimaryKey("id")
+    ...
+}
+
+ +

The reason for this recommendation is that auto-incremented primary keys prevent the reuse of ids. This prevents your app or database observation tools to think that a row was updated, when it was actually deleted, then replaced. Depending on your application needs, this may be acceptable. But usually it is not.

+
+ +

Create an index on the column:

+
    t.column("score", .integer).indexed()
+
+ +

For extra index options, see Create Indexes below.

+ +

Perform integrity checks on individual columns, and SQLite will only let conforming rows in. In the example below, the $0 closure variable is a column which lets you build any SQL expression.

+
    // name TEXT CHECK (LENGTH(name) > 0)
+    // score INTEGER CHECK (score > 0)
+    t.column("name", .text).check { length($0) > 0 }
+    t.column("score", .integer).check(sql: "score > 0")
+
+ +

Columns can also be defined with a raw sql String, or an SQL literal in which you can safely embed raw values without any risk of syntax errors or SQL injection:

+
    t.column(sql: "name TEXT")
+
+    let defaultName: String = ...
+    t.column(literal: "name TEXT DEFAULT \(defaultName)")
+
+ +

Other table constraints can involve several columns:

+
    // PRIMARY KEY (a, b),
+    t.primaryKey(["a", "b"])
+
+    // UNIQUE (a, b) ON CONFLICT REPLACE,
+    t.uniqueKey(["a", "b"], onConflict: .replace)
+
+    // FOREIGN KEY (a, b) REFERENCES parents(c, d),
+    t.foreignKey(["a", "b"], references: "parents")
+
+    // CHECK (a + b < 10),
+    t.check(Column("a") + Column("b") < 10)
+
+    // CHECK (a + b < 10)
+    t.check(sql: "a + b < 10")
+
+    // Raw SQL constraints
+    t.constraint(sql: "CHECK (a + b < 10)")
+    t.constraint(literal: "CHECK (a + b < \(10))")
+
+ +

Generated columns are available with a custom SQLite build:

+
    t.column("totalScore", .integer).generatedAs(sql: "score + bonus")
+    t.column("totalScore", .integer).generatedAs(Column("score") + Column("bonus"))
+}
+
+

Modify Tables

+ +

SQLite lets you modify existing tables:

+
// ALTER TABLE referer RENAME TO referrer
+try db.rename(table: "referer", to: "referrer")
+
+// ALTER TABLE player ADD COLUMN hasBonus BOOLEAN
+// ALTER TABLE player RENAME COLUMN url TO homeURL
+try db.alter(table: "player") { t in
+    t.add(column: "hasBonus", .boolean)
+    t.rename(column: "url", to: "homeURL") // SQLite 3.25+
+}
+
+ +
+

:point_up: Note: SQLite restricts the possible table alterations, and may require you to recreate dependent triggers or views. See the documentation of the ALTER TABLE for details. See Advanced Database Schema Changes for a way to lift restrictions.

+
+

Drop Tables

+ +

Drop tables with the drop(table:) method:

+
try db.drop(table: "obsolete")
+
+

Create Indexes

+ +

Create indexes with the create(index:) method:

+
// CREATE UNIQUE INDEX byEmail ON users(email)
+try db.create(index: "byEmail", on: "users", columns: ["email"], unique: true)
+
+ +

Relevant SQLite documentation:

+ + +

Requests

+ +

The query interface requests let you fetch values from the database:

+
let request = Player.filter(emailColumn != nil).order(nameColumn)
+let players = try request.fetchAll(db)  // [Player]
+let count = try request.fetchCount(db)  // Int
+
+ +

Query interface requests usually start from a type that adopts the TableRecord protocol, such as a Record subclass (see Records):

+
class Player: Record { ... }
+
+// The request for all players:
+let request = Player.all()
+let players = try request.fetchAll(db) // [Player]
+
+ +

When you can not use a record type, use Table:

+
// The request for all rows from the player table:
+let table = Table("player")
+let request = table.all()
+let rows = try request.fetchAll(db)    // [Row]
+
+// The request for all players from the player table:
+let table = Table<Player>("player")
+let request = table.all()
+let players = try request.fetchAll(db) // [Player]
+
+ +
+

:point_up: Note: all examples in the documentation below use a record type, but you can always substitute a Table instead.

+
+ +

Next, declare the table columns that you want to use for filtering, or sorting:

+
let idColumn = Column("id")
+let nameColumn = Column("name")
+
+ +

You can also declare column enums, if you prefer:

+
// Columns.id and Columns.name can be used just as
+// idColumn and nameColumn declared above.
+enum Columns: String, ColumnExpression {
+    case id
+    case name
+}
+
+ +

You can now build requests with the following methods: all, none, select, distinct, filter, matching, group, having, order, reversed, limit, joining, including, with. All those methods return another request, which you can further refine by applying another method: Player.select(...).filter(...).order(...).

+ +
    +
  • all(), none(): the requests for all rows, or no row.

    +
    // SELECT * FROM player
    +Player.all()
    +
    + +

    By default, all columns are selected. See Columns Selected by a Request.

  • +
  • select(...) and select(..., as:) define the selected columns. See Columns Selected by a Request.

    +
    // SELECT name FROM player
    +Player.select(nameColumn, as: String.self)
    +
  • +
  • selectID() is available on Identifiable Records. It supports all tables that have a single-column primary key:

    +
    // SELECT id FROM player
    +Player.selectID()
    +
    +// SELECT id FROM player WHERE name IS NOT NULL
    +Player.filter(nameColumn != nil).selectID()
    +
  • +
  • annotated(with: expression...) extends the selection.

    +
    // SELECT *, (score + bonus) AS total FROM player
    +Player.annotated(with: (scoreColumn + bonusColumn).forKey("total"))
    +
    + +

    Such annotations can help using Associations:

    +
    // SELECT player.*, team.name
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let teamAlias = TableAlias()
    +let request = Player
    +    .annotated(with: teamAlias[nameColumn])
    +    .joining(required: Player.team.aliased(teamAlias))
    +
  • +
  • annotated(with: aggregate) extends the selection with association aggregates.

    +
    // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount
    +// FROM team
    +// LEFT JOIN player ON player.teamId = team.id
    +// GROUP BY team.id
    +Team.annotated(with: Team.players.count)
    +
  • +
  • distinct() performs uniquing.

    +
    // SELECT DISTINCT name FROM player
    +Player.select(nameColumn, as: String.self).distinct()
    +
  • +
  • filter(expression) applies conditions.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +Player.filter([1,2,3].contains(idColumn))
    +
    +// SELECT * FROM player WHERE (name IS NOT NULL) AND (height > 1.75)
    +Player.filter(nameColumn != nil && heightColumn > 1.75)
    +
  • +
  • filter(id:) and filter(ids:) are type-safe methods available on Identifiable Records:

    +
    // SELECT * FROM player WHERE id = 1
    +Player.filter(id: 1)
    +
    +// SELECT * FROM country WHERE isoCode IN ('FR', 'US')
    +Country.filter(ids: ["FR", "US"])
    +
  • +
  • filter(key:) and filter(keys:) apply conditions on primary and unique keys:

    +
    // SELECT * FROM player WHERE id = 1
    +Player.filter(key: 1)
    +
    +// SELECT * FROM country WHERE isoCode IN ('FR', 'US')
    +Country.filter(keys: ["FR", "US"])
    +
    +// SELECT * FROM citizenship WHERE citizenId = 1 AND countryCode = 'FR'
    +Citizenship.filter(key: ["citizenId": 1, "countryCode": "FR"])
    +
    +// SELECT * FROM player WHERE email = 'arthur@example.com'
    +Player.filter(key: ["email": "arthur@example.com"])
    +
  • +
  • matching(pattern) performs full-text search.

    +
    // SELECT * FROM document WHERE document MATCH 'sqlite database'
    +let pattern = FTS3Pattern(matchingAllTokensIn: "SQLite database")
    +Document.matching(pattern)
    +
    + +

    When the pattern is nil, no row will match.

  • +
  • group(expression, ...) groups rows.

    +
    // SELECT name, MAX(score) FROM player GROUP BY name
    +Player
    +    .select(nameColumn, max(scoreColumn))
    +    .group(nameColumn)
    +
  • +
  • having(expression) applies conditions on grouped rows.

    +
    // SELECT team, MAX(score) FROM player GROUP BY team HAVING MIN(score) >= 1000
    +Player
    +    .select(teamColumn, max(scoreColumn))
    +    .group(teamColumn)
    +    .having(min(scoreColumn) >= 1000)
    +
  • +
  • having(aggregate) applies conditions on grouped rows, according to an association aggregate.

    +
    // SELECT team.*
    +// FROM team
    +// LEFT JOIN player ON player.teamId = team.id
    +// GROUP BY team.id
    +// HAVING COUNT(DISTINCT player.id) >= 5
    +Team.having(Team.players.count >= 5)
    +
  • +
  • order(ordering, ...) sorts.

    +
    // SELECT * FROM player ORDER BY name
    +Player.order(nameColumn)
    +
    +// SELECT * FROM player ORDER BY score DESC, name
    +Player.order(scoreColumn.desc, nameColumn)
    +
    + +

    SQLite considers NULL values to be smaller than any other values for sorting purposes. Hence, NULLs naturally appear at the beginning of an ascending ordering and at the end of a descending ordering. With a custom SQLite build, this can be changed using .ascNullsLast and .descNullsFirst:

    +
    // SELECT * FROM player ORDER BY score ASC NULLS LAST
    +Player.order(nameColumn.ascNullsLast)
    +
    + +

    Each order call clears any previous ordering:

    +
    // SELECT * FROM player ORDER BY name
    +Player.order(scoreColumn).order(nameColumn)
    +
  • +
  • reversed() reverses the eventual orderings.

    +
    // SELECT * FROM player ORDER BY score ASC, name DESC
    +Player.order(scoreColumn.desc, nameColumn).reversed()
    +
    + +

    If no ordering was already specified, this method has no effect:

    +
    // SELECT * FROM player
    +Player.all().reversed()
    +
  • +
  • limit(limit, offset: offset) limits and pages results.

    +
    // SELECT * FROM player LIMIT 5
    +Player.limit(5)
    +
    +// SELECT * FROM player LIMIT 5 OFFSET 10
    +Player.limit(5, offset: 10)
    +
  • +
  • joining(...) and including(...) fetch and join records through Associations.

    +
    // SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +Player.including(required: Player.team)
    +
  • +
  • with(cte) embeds a common table expression:

    +
    // WITH ... SELECT * FROM player
    +let cte = CommonTableExpression(...)
    +Player.with(cte)
    +
  • +
  • Other requests that involve the primary key:

    + +
      +
    • orderByPrimaryKey() sorts by primary key.

      +
      // SELECT * FROM player ORDER BY id
      +Player.orderByPrimaryKey()
      +
      +// SELECT * FROM country ORDER BY code
      +Country.orderByPrimaryKey()
      +
      +// SELECT * FROM citizenship ORDER BY citizenId, countryCode
      +Citizenship.orderByPrimaryKey()
      +
    • +
    • groupByPrimaryKey() groups rows by primary key.

    • +
  • +
+ +

You can refine requests by chaining those methods:

+
// SELECT * FROM player WHERE (email IS NOT NULL) ORDER BY name
+Player.order(nameColumn).filter(emailColumn != nil)
+
+ +

The select, order, group, and limit methods ignore and replace previously applied selection, orderings, grouping, and limits. On the opposite, filter, matching, and having methods extend the query:

+
Player                          // SELECT * FROM player
+    .filter(nameColumn != nil)  // WHERE (name IS NOT NULL)
+    .filter(emailColumn != nil) //        AND (email IS NOT NULL)
+    .order(nameColumn)          // - ignored -
+    .reversed()                 // - ignored -
+    .order(scoreColumn)         // ORDER BY score
+    .limit(20, offset: 40)      // - ignored -
+    .limit(10)                  // LIMIT 10
+
+ +

Raw SQL snippets are also accepted, with eventual arguments:

+
// SELECT DATE(creationDate), COUNT(*) FROM player WHERE name = 'Arthur' GROUP BY date(creationDate)
+Player
+    .select(sql: "DATE(creationDate), COUNT(*)")
+    .filter(sql: "name = ?", arguments: ["Arthur"])
+    .group(sql: "DATE(creationDate)")
+
+

Columns Selected by a Request

+ +

By default, query interface requests select all columns:

+
// SELECT * FROM player
+struct Player: TableRecord { ... }
+let request = Player.all()
+
+// SELECT * FROM player
+let table = Table("player")
+let request = table.all()
+
+ +

The selection can be changed for each individual requests, or in the case of record-based requests, for all requests built from this record type.

+ +

The select(...) and select(..., as:) methods change the selection of a single request (see Fetching from Requests for detailed information):

+
let request = Player.select(max(Column("score")))
+let maxScore = try Int.fetchOne(db, request) // Int?
+
+let request = Player.select(max(Column("score")), as: Int.self)
+let maxScore = try request.fetchOne(db)      // Int?
+
+ +

The default selection for a record type is controlled by the databaseSelection property:

+
struct RestrictedPlayer : TableRecord {
+    static let databaseTableName = "player"
+    static let databaseSelection: [SQLSelectable] = [Column("id"), Column("name")]
+}
+
+struct ExtendedPlayer : TableRecord {
+    static let databaseTableName = "player"
+    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
+}
+
+// SELECT id, name FROM player
+let request = RestrictedPlayer.all()
+
+// SELECT *, rowid FROM player
+let request = ExtendedPlayer.all()
+
+ +
+

:point_up: Note: make sure the databaseSelection property is explicitly declared as [SQLSelectable]. If it is not, the Swift compiler may silently miss the protocol requirement, resulting in sticky SELECT * requests. To verify your setup, see the How do I print a request as SQL? FAQ.

+
+

Expressions

+ +

Feed requests with SQL expressions built from your Swift code:

+

SQL Operators

+ +

GRDB comes with a Swift version of many SQLite built-in operators, listed below. But not all: see Adding support for missing SQL functions or operators.

+ +
    +
  • =, <>, <, <=, >, >=, IS, IS NOT

    + +

    Comparison operators are based on the Swift operators ==, !=, ===, !==, <, <=, >, >=:

    +
    // SELECT * FROM player WHERE (name = 'Arthur')
    +Player.filter(nameColumn == "Arthur")
    +
    +// SELECT * FROM player WHERE (name IS NULL)
    +Player.filter(nameColumn == nil)
    +
    +// SELECT * FROM player WHERE (score IS 1000)
    +Player.filter(scoreColumn === 1000)
    +
    +// SELECT * FROM rectangle WHERE width < height
    +Rectangle.filter(widthColumn < heightColumn)
    +
    + +

    Subqueries are supported:

    +
    // SELECT * FROM player WHERE score = (SELECT max(score) FROM player)
    +let maximumScore = Player.select(max(scoreColumn))
    +Player.filter(scoreColumn == maximumScore)
    +
    +// SELECT * FROM player WHERE score = (SELECT max(score) FROM player)
    +let maximumScore = SQLRequest("SELECT max(score) FROM player")
    +Player.filter(scoreColumn == maximumScore)
    +
    + +
    +

    :point_up: Note: SQLite string comparison, by default, is case-sensitive and not Unicode-aware. See string comparison if you need more control.

    +
  • +
  • *, /, +, -

    + +

    SQLite arithmetic operators are derived from their Swift equivalent:

    +
    // SELECT ((temperature * 1.8) + 32) AS fahrenheit FROM planet
    +Planet.select((temperatureColumn * 1.8 + 32).forKey("fahrenheit"))
    +
    + +
    +

    :point_up: Note: an expression like nameColumn + "rrr" will be interpreted by SQLite as a numerical addition (with funny results), not as a string concatenation. See the concat operator below.

    +
    + +

    When you want to join a sequence of expressions with the + or * operator, use joined(operator:):

    +
    // SELECT score + bonus + 1000 FROM player
    +let values = [
    +    scoreColumn,
    +    bonusColumn,
    +    1000.databaseValue]
    +Player.select(values.joined(operator: .add))
    +
    + +

    Note in the example above how you concatenate raw values: 1000.databaseValue. A plain 1000 would not compile.

    + +

    When the sequence is empty, joined(operator: .add) returns 0, and joined(operator: .multiply) returns 1.

  • +
  • ||

    + +

    Concatenate several strings:

    +
    // SELECT firstName || ' ' || lastName FROM player
    +Player.select([firstNameColumn, " ".databaseValue, lastNameColumn].joined(operator: .concat))
    +
    + +

    Note in the example above how you concatenate raw strings: " ".databaseValue. A plain " " would not compile.

    + +

    When the sequence is empty, joined(operator: .concat) returns the empty string.

  • +
  • AND, OR, NOT

    + +

    The SQL logical operators are derived from the Swift &&, || and !:

    +
    // SELECT * FROM player WHERE ((NOT verified) OR (score < 1000))
    +Player.filter(!verifiedColumn || scoreColumn < 1000)
    +
    + +

    When you want to join a sequence of expressions with the AND or OR operator, use joined(operator:):

    +
    // SELECT * FROM player WHERE (verified AND (score >= 1000) AND (name IS NOT NULL))
    +let conditions = [
    +    verifiedColumn,
    +    scoreColumn >= 1000,
    +    nameColumn != nil]
    +Player.filter(conditions.joined(operator: .and))
    +
    + +

    When the sequence is empty, joined(operator: .and) returns true, and joined(operator: .or) returns false:

    +
    // SELECT * FROM player WHERE 1
    +Player.filter([].joined(operator: .and))
    +
    +// SELECT * FROM player WHERE 0
    +Player.filter([].joined(operator: .or))
    +
  • +
  • BETWEEN, IN, NOT IN

    + +

    To check inclusion in a Swift sequence (array, set, range…), call the contains method:

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +Player.filter([1, 2, 3].contains(idColumn))
    +
    +// SELECT * FROM player WHERE id NOT IN (1, 2, 3)
    +Player.filter(![1, 2, 3].contains(idColumn))
    +
    +// SELECT * FROM player WHERE score BETWEEN 0 AND 1000
    +Player.filter((0...1000).contains(scoreColumn))
    +
    +// SELECT * FROM player WHERE (score >= 0) AND (score < 1000)
    +Player.filter((0..<1000).contains(scoreColumn))
    +
    +// SELECT * FROM player WHERE initial BETWEEN 'A' AND 'N'
    +Player.filter(("A"..."N").contains(initialColumn))
    +
    +// SELECT * FROM player WHERE (initial >= 'A') AND (initial < 'N')
    +Player.filter(("A"..<"N").contains(initialColumn))
    +
    + +

    To check inclusion inside a subquery, call the contains method as well:

    +
    // SELECT * FROM player WHERE id IN (SELECT playerId FROM playerSelection)
    +let selectedPlayerIds = PlayerSelection.select(playerIdColumn)
    +Player.filter(selectedPlayerIds.contains(idColumn))
    +
    +// SELECT * FROM player WHERE id IN (SELECT playerId FROM playerSelection)
    +let selectedPlayerIds = SQLRequest("SELECT playerId FROM playerSelection")
    +Player.filter(selectedPlayerIds.contains(idColumn))
    +
    + +

    To check inclusion inside a common table expression, call the contains method as well:

    +
    // WITH selectedName AS (...)
    +// SELECT * FROM player WHERE name IN selectedName
    +let cte = CommonTableExpression(named: "selectedName", ...)
    +Player
    +    .with(cte)
    +    .filter(cte.contains(nameColumn))
    +
    + +
    +

    :point_up: Note: SQLite string comparison, by default, is case-sensitive and not Unicode-aware. See string comparison if you need more control.

    +
  • +
  • EXISTS, NOT EXISTS

    + +

    To check if a subquery would return rows, call the exists method:

    +
    // Teams that have at least one other player
    +//
    +//  SELECT * FROM team
    +//  WHERE EXISTS (SELECT * FROM player WHERE teamID = team.id)
    +let teamAlias = TableAlias()
    +let player = Player.filter(Column("teamID") == teamAlias[Column("id")])
    +let teams = Team.aliased(teamAlias).filter(player.exists())
    +
    +// Teams that have no player
    +//
    +//  SELECT * FROM team
    +//  WHERE NOT EXISTS (SELECT * FROM player WHERE teamID = team.id)
    +let teams = Team.aliased(teamAlias).filter(!player.exists())
    +
    + +

    In the above example, you use a TableAlias in order to let a subquery refer to a column from another table.

    + +

    In the next example, which involves the same table twice, the table alias requires an explicit disambiguation with TableAlias(name:):

    +
    // Players who coach at least one other player
    +//
    +//  SELECT coach.* FROM player coach
    +//  WHERE EXISTS (SELECT * FROM player WHERE coachId = coach.id)
    +let coachAlias = TableAlias(name: "coach")
    +let coachedPlayer = Player.filter(Column("coachId") == coachAlias[Column("id")])
    +let coaches = Player.aliased(coachAlias).filter(coachedPlayer.exists())
    +
    + +

    Finally, subqueries can also be expressed as SQL, with SQL Interpolation:

    +
    // SELECT coach.* FROM player coach
    +// WHERE EXISTS (SELECT * FROM player WHERE coachId = coach.id)
    +let coachedPlayer = SQLRequest("SELECT * FROM player WHERE coachId = \(coachAlias[Column("id")])")
    +let coaches = Player.aliased(coachAlias).filter(coachedPlayer.exists())
    +
  • +
  • LIKE

    + +

    The SQLite LIKE operator is available as the like method:

    +
    // SELECT * FROM player WHERE (email LIKE '%@example.com')
    +Player.filter(emailColumn.like("%@example.com"))
    +
    +// SELECT * FROM book WHERE (title LIKE '%10\%%' ESCAPE '\')
    +Player.filter(emailColumn.like("%10\\%%", escape: "\\"))
    +
    + +
    +

    :point_up: Note: the SQLite LIKE operator is case-insensitive but not Unicode-aware. For example, the expression 'a' LIKE 'A' is true but 'æ' LIKE 'Æ' is false.

    +
  • +
  • MATCH

    + +

    The full-text MATCH operator is available through FTS3Pattern (for FTS3 and FTS4 tables) and FTS5Pattern (for FTS5):

    + +

    FTS3 and FTS4:

    +
    let pattern = FTS3Pattern(matchingAllTokensIn: "SQLite database")
    +
    +// SELECT * FROM document WHERE document MATCH 'sqlite database'
    +Document.matching(pattern)
    +
    +// SELECT * FROM document WHERE content MATCH 'sqlite database'
    +Document.filter(contentColumn.match(pattern))
    +
    + +

    FTS5:

    +
    let pattern = FTS5Pattern(matchingAllTokensIn: "SQLite database")
    +
    +// SELECT * FROM document WHERE document MATCH 'sqlite database'
    +Document.matching(pattern)
    +
  • +
+

SQL Functions

+ +

GRDB comes with a Swift version of many SQLite built-in functions, listed below. But not all: see Adding support for missing SQL functions or operators.

+ +
    +
  • ABS, AVG, COUNT, DATETIME, JULIANDAY, LENGTH, MAX, MIN, SUM:

    + +

    Those are based on the abs, average, count, dateTime, julianDay, length, max, min and sum Swift functions:

    +
    // SELECT MIN(score), MAX(score) FROM player
    +Player.select(min(scoreColumn), max(scoreColumn))
    +
    +// SELECT COUNT(name) FROM player
    +Player.select(count(nameColumn))
    +
    +// SELECT COUNT(DISTINCT name) FROM player
    +Player.select(count(distinct: nameColumn))
    +
    +// SELECT JULIANDAY(date, 'start of year') FROM game
    +Game.select(julianDay(dateColumn, .startOfYear))
    +
    + +

    For more information about the functions dateTime and julianDay, see Date And Time Functions.

  • +
  • IFNULL

    + +

    Use the Swift ?? operator:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +Player.select(nameColumn ?? "Anonymous")
    +
    +// SELECT IFNULL(name, email) FROM player
    +Player.select(nameColumn ?? emailColumn)
    +
  • +
  • LOWER, UPPER

    + +

    The query interface does not give access to those SQLite functions. Nothing against them, but they are not unicode aware.

    + +

    Instead, GRDB extends SQLite with SQL functions that call the Swift built-in string functions capitalized, lowercased, uppercased, localizedCapitalized, localizedLowercased and localizedUppercased:

    +
    Player.select(nameColumn.uppercased())
    +
    + +
    +

    :point_up: Note: When comparing strings, you’d rather use a collation:

    +
    let name: String = ...
    +
    +// Not recommended
    +nameColumn.uppercased() == name.uppercased()
    +
    +// Better
    +nameColumn.collating(.caseInsensitiveCompare) == name
    +
    +
  • +
  • Custom SQL functions and aggregates

    + +

    You can apply your own custom SQL functions and aggregates:

    +
    let f = DatabaseFunction("f", ...)
    +
    +// SELECT f(name) FROM player
    +Player.select(f.apply(nameColumn))
    +
  • +
+

Adding support for missing SQL functions or operators

+ +

When you spot an SQL function or operator that misses its Swift version, you can define it right into your application code.

+ +

For example, you can add support for the DATE function, thanks to SQL Interpolation:

+
func date(_ value: SQLSpecificExpressible) -> SQLExpression {
+    SQL("DATE(\(value))").sqlExpression
+}
+
+// SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
+let request = Player.filter(date(Column("createdAt")) == "2020-01-23")
+
+ +

See the Query Interface Organization for more information about SQLSpecificExpressible and SQLExpression.

+

Fetching from Requests

+ +

Once you have a request, you can fetch the records at the origin of the request:

+
// Some request based on `Player`
+let request = Player.filter(...)... // QueryInterfaceRequest<Player>
+
+// Fetch players:
+try request.fetchCursor(db) // A Cursor of Player
+try request.fetchAll(db)    // [Player]
+try request.fetchSet(db)    // Set<Player>
+try request.fetchOne(db)    // Player?
+
+ +

For example:

+
let allPlayers = try Player.fetchAll(db)                            // [Player]
+let arthur = try Player.filter(nameColumn == "Arthur").fetchOne(db) // Player?
+
+ +

See fetching methods for information about the fetchCursor, fetchAll, fetchSet and fetchOne methods.

+ +

You sometimes want to fetch other values.

+ +

The simplest way is to use the request as an argument to a fetching method of the desired type:

+
// Fetch an Int
+let request = Player.select(max(scoreColumn))
+let maxScore = try Int.fetchOne(db, request) // Int?
+
+// Fetch a Row
+let request = Player.select(min(scoreColumn), max(scoreColumn))
+let row = try Row.fetchOne(db, request)!     // Row
+let minScore = row[0] as Int?
+let maxScore = row[1] as Int?
+
+ +

You can also change the request so that it knows the type it has to fetch:

+ +
    +
  • With asRequest(of:), useful when you use Associations:

    +
    struct BookInfo: FetchableRecord, Decodable {
    +    var book: Book
    +    var author: Author
    +}
    +
    +// A request of BookInfo
    +let request = Book
    +    .including(required: Book.author)
    +    .asRequest(of: BookInfo.self)
    +
    +let bookInfos = try dbQueue.read { db in
    +    try request.fetchAll(db) // [BookInfo]
    +}
    +
  • +
  • With select(..., as:), which is handy when you change the selection:

    +
    // A request of Int
    +let request = Player.select(max(scoreColumn), as: Int.self)
    +
    +let maxScore = try dbQueue.read { db in
    +    try request.fetchOne(db) // Int?
    +}
    +
  • +
+

Fetching by Key

+ +

Fetching records according to their primary key is a common task.

+ +

Identifiable Records can use the type-safe methods fetchOne(_:id:), fetchAll(_:ids:) and fetchSet(_:ids:):

+
try Player.fetchOne(db, id: 1)               // Player?
+try Country.fetchAll(db, ids: ["FR", "US"])  // [Countries]
+
+ +

All record types can use fetchOne(_:key:), fetchAll(_:keys:) and fetchSet(_:keys:) that apply conditions on primary and unique keys:

+
try Player.fetchOne(db, key: 1)              // Player?
+try Country.fetchAll(db, keys: ["FR", "US"]) // [Country]
+try Player.fetchOne(db, key: ["email": "arthur@example.com"])            // Player?
+try Citizenship.fetchOne(db, key: ["citizenId": 1, "countryCode": "FR"]) // Citizenship?
+
+ +

When the table has no explicit primary key, GRDB uses the hidden "rowid” column:

+
// SELECT * FROM document WHERE rowid = 1
+try Document.fetchOne(db, key: 1)            // Document?
+
+ +

When you want to build a request and plan to fetch from it later, use a filter method:

+
let request = Player.filter(id: 1)
+let request = Country.filter(ids: ["FR", "US"])
+let request = Player.filter(key: ["email": "arthur@example.com"])
+let request = Citizenship.filter(key: ["citizenId": 1, "countryCode": "FR"])
+
+

Testing for Record Existence

+ +

You can check if a request has matching rows in the database.

+
// Some request based on `Player`
+let request = Player.filter(...)...
+
+// Check for player existence:
+let noSuchPlayer = try request.isEmpty(db) // Bool
+
+ +

You should check for emptiness instead of counting:

+
// Correct
+let noSuchPlayer = try request.fetchCount(db) == 0
+// Even better
+let noSuchPlayer = try request.isEmpty(db)
+
+ +

You can also check if a given primary or unique key exists in the database.

+ +

Identifiable Records can use the type-safe method exists(_:id:):

+
try Player.exists(db, id: 1)
+try Country.exists(db, id: "FR")
+
+ +

All record types can use exists(_:key:) that can check primary and unique keys:

+
try Player.exists(db, key: 1)
+try Country.exists(db, key: "FR")
+try Player.exists(db, key: ["email": "arthur@example.com"])
+try Citizenship.exists(db, key: ["citizenId": 1, "countryCode": "FR"])
+
+ +

You should check for key existence instead of fetching a record and checking for nil:

+
// Correct
+let playerExists = try Player.fetchOne(db, id: 1) != nil
+// Even better
+let playerExists = try Player.exists(db, id: 1)
+
+

Fetching Aggregated Values

+ +

Requests can count. The fetchCount() method returns the number of rows that would be returned by a fetch request:

+
// SELECT COUNT(*) FROM player
+let count = try Player.fetchCount(db) // Int
+
+// SELECT COUNT(*) FROM player WHERE email IS NOT NULL
+let count = try Player.filter(emailColumn != nil).fetchCount(db)
+
+// SELECT COUNT(DISTINCT name) FROM player
+let count = try Player.select(nameColumn).distinct().fetchCount(db)
+
+// SELECT COUNT(*) FROM (SELECT DISTINCT name, score FROM player)
+let count = try Player.select(nameColumn, scoreColumn).distinct().fetchCount(db)
+
+ +

Other aggregated values can also be selected and fetched (see SQL Functions):

+
let request = Player.select(max(scoreColumn))
+let maxScore = try Int.fetchOne(db, request) // Int?
+
+let request = Player.select(min(scoreColumn), max(scoreColumn))
+let row = try Row.fetchOne(db, request)!     // Row
+let minScore = row[0] as Int?
+let maxScore = row[1] as Int?
+
+

Delete Requests

+ +

Requests can delete records, with the deleteAll() method:

+
// DELETE FROM player
+try Player.deleteAll(db)
+
+// DELETE FROM player WHERE team = 'red'
+try Player
+    .filter(teamColumn == "red")
+    .deleteAll(db)
+
+// DELETE FROM player ORDER BY score LIMIT 10
+try Player
+    .order(scoreColumn)
+    .limit(10)
+    .deleteAll(db)
+
+ +
+

:point_up: Note Deletion methods are available on types that adopt the TableRecord protocol, and Table:

+
struct Player: TableRecord { ... }
+try Player.deleteAll(db)          // Fine
+try Table("player").deleteAll(db) // Just as fine
+
+
+ +

Deleting records according to their primary key is a common task.

+ +

Identifiable Records can use the type-safe methods deleteOne(_:id:) and deleteAll(_:ids:):

+
try Player.deleteOne(db, id: 1)
+try Country.deleteAll(db, ids: ["FR", "US"])
+
+ +

All record types can use deleteOne(_:key:) and deleteAll(_:keys:) that apply conditions on primary and unique keys:

+
try Player.deleteOne(db, key: 1)
+try Country.deleteAll(db, keys: ["FR", "US"])
+try Player.deleteOne(db, key: ["email": "arthur@example.com"])
+try Citizenship.deleteOne(db, key: ["citizenId": 1, "countryCode": "FR"])
+
+ +

When the table has no explicit primary key, GRDB uses the hidden “rowid” column:

+
// DELETE FROM document WHERE rowid = 1
+try Document.deleteOne(db, id: 1)             // Document?
+
+

Update Requests

+ +

Requests can batch update records. The updateAll() method accepts column assignments defined with the set(to:) method:

+
// UPDATE player SET score = 0, isHealthy = 1, bonus = NULL
+try Player.updateAll(db, 
+    Column("score").set(to: 0), 
+    Column("isHealthy").set(to: true), 
+    Column("bonus").set(to: nil))
+
+// UPDATE player SET score = 0 WHERE team = 'red'
+try Player
+    .filter(Column("team") == "red")
+    .updateAll(db, Column("score").set(to: 0))
+
+// UPDATE player SET top = 1 ORDER BY score DESC LIMIT 10
+try Player
+    .order(Column("score").desc)
+    .limit(10)
+    .updateAll(db, Column("top").set(to: true))
+
+// UPDATE country SET population = 67848156 WHERE id = 'FR'
+try Country
+    .filter(id: "FR")
+    .updateAll(db, Column("population").set(to: 67_848_156))
+
+ +

Column assignments accept any expression:

+
// UPDATE player SET score = score + (bonus * 2)
+try Player.updateAll(db, Column("score").set(to: Column("score") + Column("bonus") * 2))
+
+ +

As a convenience, you can also use the +=, -=, *=, or /= operators:

+
// UPDATE player SET score = score + (bonus * 2)
+try Player.updateAll(db, Column("score") += Column("bonus") * 2)
+
+ +

Default Conflict Resolution rules apply, and you may also provide a specific one:

+
// UPDATE OR IGNORE player SET ...
+try Player.updateAll(db, onConflict: .ignore, /* assignments... */)
+
+ +
+

:point_up: Note The updateAll method is available on types that adopt the TableRecord protocol, and Table:

+
struct Player: TableRecord { ... }
+try Player.updateAll(db, ...)          // Fine
+try Table("player").updateAll(db, ...) // Just as fine
+
+
+

Custom Requests

+ +

Until now, we have seen requests created from any type that adopts the TableRecord protocol:

+
let request = Player.all()  // QueryInterfaceRequest<Player>
+
+ +

Those requests of type QueryInterfaceRequest can fetch and count:

+
try request.fetchCursor(db) // A Cursor of Player
+try request.fetchAll(db)    // [Player]
+try request.fetchSet(db)    // Set<Player>
+try request.fetchOne(db)    // Player?
+try request.fetchCount(db)  // Int
+
+ +

When the query interface can not generate the SQL you need, you can still fallback to raw SQL:

+
// Custom SQL is always welcome
+try Player.fetchAll(db, sql: "SELECT ...")   // [Player]
+
+ +

But you may prefer to bring some elegance back in, and build custom requests:

+
// No custom SQL in sight
+try Player.customRequest().fetchAll(db) // [Player]
+
+ +

To build custom requests, you can use one of the built-in requests or derive requests from other requests.

+ +
    +
  • SQLRequest is a fetch request built from raw SQL. For example:

    +
    extension Player {
    +    static func filter(color: Color) -> SQLRequest<Player> {
    +        SQLRequest<Player>(
    +            sql: "SELECT * FROM player WHERE color = ?"
    +            arguments: [color])
    +    }
    +}
    +
    +// [Player]
    +try Player.filter(color: .red).fetchAll(db)
    +
    + +

    SQLRequest supports SQL Interpolation:

    +
    extension Player {
    +    static func filter(color: Color) -> SQLRequest<Player> {
    +        "SELECT * FROM player WHERE color = \(color)"
    +    }
    +}
    +
  • +
  • The asRequest(of:) method changes the type fetched by the request. It is useful, for example, when you use Associations:

    +
    struct BookInfo: FetchableRecord, Decodable {
    +    var book: Book
    +    var author: Author
    +}
    +
    +let request = Book
    +    .including(required: Book.author)
    +    .asRequest(of: BookInfo.self)
    +
    +// [BookInfo]
    +try request.fetchAll(db)
    +
  • +
  • The adapted(_:) method eases the consumption of complex rows with row adapters. See Joined Queries Support for some sample code that uses this method.

  • +
  • AnyFetchRequest: a type-erased request.

  • +
+

Joined Queries Support

+ +

GRDB helps consuming joined queries with complex selection.

+ +

In this chapter, we will focus on the extraction of information from complex rows, such as the ones fetched by the query below:

+
-- How to consume the left, middle, and right parts of those rows?
+SELECT player.*, team.*, MAX(round.score) AS maxScore
+FROM player
+LEFT JOIN team ON ...
+LEFT JOIN round ON ...
+GROUP BY ...
+
+ +

We will not talk about the generation of joined queries, which is covered in Associations.

+ +

So what are we talking about?

+ +

It is difficult to consume rows fetched from complex joined queries, because they often contain several columns with the same name: id from table player, id from table team, etc.

+ +

When such ambiguity happens, GRDB row accessors always favor the leftmost matching column. This means that row["id"] would give a player id, without any obvious way to access the team id.

+ +

A classical technique to avoid this ambiguity is to give each column a unique name. For example:

+
-- A classical technique
+SELECT player.id AS player_id, player.name AS player_name, team.id AS team_id, team.name AS team_name, team.color AS team_color, MAX(round.score) AS maxScore
+FROM player
+LEFT JOIN team ON ...
+LEFT JOIN round ON ...
+GROUP BY ...
+
+ +

This technique works pretty well, but it has three drawbacks:

+ +
    +
  1. The selection becomes hard to read and understand.
  2. +
  3. Such queries are difficult to write by hand.
  4. +
  5. The mangled names are a very bad fit for FetchableRecord types that expect specific column names. After all, if the Team record type can read SELECT * FROM team ..., it should be able to read SELECT ..., team.*, ... as well.
  6. +
+ +

We thus need another technique. Below we’ll see how to split rows into slices, and preserve column names.

+ +

SELECT player.*, team.*, MAX(round.score) AS maxScore FROM ... will be split into three slices: one that contains player’s columns, one that contains team’s columns, and a remaining slice that contains remaining column(s). The Player record type will be able to read the first slice, which contains the columns expected by the Player.init(row:) initializer. In the same way, the Team record type could read the second slice.

+ +

Unlike the name-mangling technique, splitting rows keeps SQL legible, accepts your hand-crafted SQL queries, and plays as nicely as possible with your existing record types.

+ + +

Splitting Rows, an Introduction

+ +

Let’s first write some introductory code, hoping that this chapter will make you understand how pieces fall together. We’ll see later how records will help us streamline the initial approach, how to track changes in joined requests, and how we can use the standard Decodable protocol.

+ +

To split rows, we will use row adapters. Row adapters adapt rows so that row consumers see exactly the columns they want. Among other things, row adapters can define several row scopes that give access to as many row slices. Sounds like a perfect match.

+ +

At the very beginning, there is an SQL query:

+
try dbQueue.read { db in
+    let sql = """
+        SELECT player.*, team.*, MAX(round.score) AS maxScore
+        FROM player
+        LEFT JOIN team ON ...
+        LEFT JOIN round ON ...
+        GROUP BY ...
+        """
+
+ +

We need an adapter that extracts player columns, in a slice that has as many columns as there are columns in the player table. That’s RangeRowAdapter:

+
    // SELECT player.*, team.*, ...
+    //        <------>
+    let playerWidth = try db.columns(in: "player").count
+    let playerAdapter = RangeRowAdapter(0 ..< playerWidth)
+
+ +

We also need an adapter that extracts team columns:

+
    // SELECT player.*, team.*, ...
+    //                  <---->
+    let teamWidth = try db.columns(in: "team").count
+    let teamAdapter = RangeRowAdapter(playerWidth ..< (playerWidth + teamWidth))
+
+ +

We merge those two adapters in a single ScopeAdapter that will allow us to access both sliced rows:

+
    let playerScope = "player"
+    let teamScope = "team"
+    let adapter = ScopeAdapter([
+        playerScope: playerAdapter,
+        teamScope: teamAdapter])
+
+ +

And now we can fetch, and start consuming our rows. You already know row cursors:

+
    let rows = try Row.fetchCursor(db, sql: sql, adapter: adapter)
+    while let row = try rows.next() {
+
+ +

From a fetched row, we can build a player:

+
        let player: Player = row[playerScope]
+
+ +

In the SQL query, the team is joined with the LEFT JOIN operator. This means that the team may be missing: its slice may contain team values, or it may only contain NULLs. When this happens, we don’t want to build a Team record, and we thus load an optional Team:

+
        let team: Team? = row[teamScope]
+
+ +

And finally, we can load the maximum score, assuming that the “maxScore” column is not ambiguous:

+
        let maxScore: Int = row["maxScore"]
+
+        print("player: \(player)")
+        print("team: \(team)")
+        print("maxScore: \(maxScore)")
+    }
+}
+
+ +
+

:bulb: In this chapter, we have learned:

+ +
    +
  • how to use RangeRowAdapter to extract a specific table’s columns into a row slice.
  • +
  • how to use ScopeAdapter to gives access to several row slices through named scopes.
  • +
  • how to use Row subscripting to extract records from rows, or optional records in order to deal with left joins.
  • +
+
+

Splitting Rows, the Record Way

+ +

Our introduction above has introduced important techniques. It uses row adapters in order to split rows. It uses Row subscripting in order to extract records from row slices.

+ +

But we may want to make it more usable and robust:

+ +
    +
  1. It’s generally easier to consume records than raw rows.
  2. +
  3. Joined records not always need all columns from a table (see TableRecord.databaseSelection in Columns Selected by a Request).
  4. +
  5. Building row adapters is long and error prone.
  6. +
+ +

To address the first bullet, let’s define a record that holds our player, optional team, and maximum score. Since it can decode database rows, it adopts the FetchableRecord protocol:

+
struct PlayerInfo {
+    var player: Player
+    var team: Team?
+    var maxScore: Int
+}
+
+/// PlayerInfo can decode rows:
+extension PlayerInfo: FetchableRecord {
+    private enum Scopes {
+        static let player = "player"
+        static let team = "team"
+    }
+
+    init(row: Row) {
+        player = row[Scopes.player]
+        team = row[Scopes.team]
+        maxScore = row["maxScore"]
+    }
+}
+
+ +

Now we write a method that returns a custom request, and then build the fetching method on top of that request:

+
extension PlayerInfo {
+    /// The request for all player infos
+    static func all() -> AdaptedFetchRequest<SQLRequest<PlayerInfo>> {
+
+ +

To acknowledge that both Player and Team records may customize their selection of the “player” and “team” columns, we’ll write our SQL in a slightly different way:

+
        // Let Player and Team customize their selection:
+        let request: SQLRequest<PlayerInfo> = """
+            SELECT
+                \(columnsOf: Player.self), -- instead of player.*
+                \(columnsOf: Team.self),   -- instead of team.*
+                MAX(round.score) AS maxScore
+            FROM player
+            LEFT JOIN team ON ...
+            LEFT JOIN round ON ...
+            GROUP BY ...
+            """
+
+ +

Our SQL is no longer a regular String, but an SQLRequest<PlayerInfo> which profits from SQL Interpolation. Inside this request, \(columnsOf: Player.self) outputs player.*, unless Player defines a customized selection.

+ +

Now we need to build adapters.

+ +

We use the splittingRowAdapters global function, whose job is precisely to build row adapters of desired widths:

+ +

And since counting table columns require a database connection, we use the adapted(_:) request method. It allows requests to adapt themselves right before execution, when a database connection is available.

+
        return request.adapted { db in
+            let adapters = try splittingRowAdapters(columnCounts: [
+                Player.numberOfSelectedColumns(db),
+                Team.numberOfSelectedColumns(db)])
+            return ScopeAdapter([
+                Scopes.player: adapters[0],
+                Scopes.team: adapters[1]])
+        }
+    }
+
+ +
+

:point_up: Note: splittingRowAdapters returns as many adapters as necessary to fully split a row. In the example above, it returns three adapters: one for player, one for team, and one for the remaining columns.

+
+ +

And finally, we can define the fetching method:

+
    /// Fetches all player infos
+    static func fetchAll(_ db: Database) throws -> [PlayerInfo] {
+        try all().fetchAll(db)
+    }
+}
+
+ +

And when your app needs to fetch player infos, it now reads:

+
// Fetch player infos
+let playerInfos = try dbQueue.read { db in
+    try PlayerInfo.fetchAll(db)
+}
+
+ +
+

:bulb: In this chapter, we have learned:

+ +
    +
  • how to define a FetchableRecord record that consumes rows fetched from a joined query.
  • +
  • how to use SQL Interpolation and numberOfSelectedColumns in order to deal with nested record types that define custom selection.
  • +
  • how to use splittingRowAdapters in order to streamline the definition of row slices.
  • +
  • how to gather all relevant methods and constants in a record type, fully responsible of its relationship with the database.
  • +
+
+

Splitting Rows, the Codable Way

+ +

Codable Records build on top of the standard Decodable protocol in order to decode database rows.

+ +

You can consume complex joined queries with Codable records as well. As a demonstration, we’ll rewrite the above sample code:

+
struct Player: Decodable, FetchableRecord, TableRecord {
+    var id: Int64
+    var name: String
+}
+struct Team: Decodable, FetchableRecord, TableRecord {
+    var id: Int64
+    var name: String
+    var color: Color
+}
+struct PlayerInfo: Decodable, FetchableRecord {
+    var player: Player
+    var team: Team?
+    var maxScore: Int
+}
+
+extension PlayerInfo {
+    /// The request for all player infos
+    static func all() -> AdaptedFetchRequest<SQLRequest<PlayerInfo>> {
+        let request: SQLRequest<PlayerInfo> = """
+            SELECT
+                \(columnsOf: Player.self),
+                \(columnsOf: Team.self),
+                MAX(round.score) AS maxScore
+            FROM player
+            LEFT JOIN team ON ...
+            LEFT JOIN round ON ...
+            GROUP BY ...
+            """
+        return request.adapted { db in
+            let adapters = try splittingRowAdapters(columnCounts: [
+                Player.numberOfSelectedColumns(db),
+                Team.numberOfSelectedColumns(db)])
+            return ScopeAdapter([
+                CodingKeys.player.stringValue: adapters[0],
+                CodingKeys.team.stringValue: adapters[1]])
+        }
+    }
+
+    /// Fetches all player infos
+    static func fetchAll(_ db: Database) throws -> [PlayerInfo] {
+        try all().fetchAll(db)
+    }
+}
+
+// Fetch player infos
+let playerInfos = try dbQueue.read { db in
+    try PlayerInfo.fetchAll(db)
+}
+
+ +
+

:bulb: In this chapter, we have learned how to use the Decodable protocol and its associated CodingKeys enum in order to dry up our code.

+
+

Database Changes Observation

+ +

SQLite notifies its host application of changes performed to the database, as well of transaction commits and rollbacks.

+ +

GRDB puts this SQLite feature to some good use, and lets you observe the database in various ways:

+ + + +

Database observation requires that a single database queue or pool is kept open for all the duration of the database usage.

+

After Commit Hook

+ +

When your application needs to make sure a specific database transaction has been successfully committed before it executes some work, use the Database.afterNextTransactionCommit(_:) method.

+ +

Its closure argument is called right after database changes have been successfully written to disk:

+
try dbQueue.write { db in
+    db.afterNextTransactionCommit { db in
+        print("success")
+    }
+    ...
+} // prints "success"
+
+ +

The closure runs in a protected dispatch queue, serialized with all database updates.

+ +

This “after commit hook” helps synchronizing the database with other resources, such as files, or system sensors.

+ +

In the example below, a location manager starts monitoring a CLRegion if and only if it has successfully been stored in the database:

+
/// Inserts a region in the database, and start monitoring upon
+/// successful insertion.
+func startMonitoring(_ db: Database, region: CLRegion) throws {
+    // Make sure database is inside a transaction
+    try db.inSavepoint {
+
+        // Save the region in the database
+        try insert(...)
+
+        // Start monitoring if and only if the insertion is
+        // eventually committed
+        db.afterNextTransactionCommit { _ in
+            // locationManager prefers the main queue:
+            DispatchQueue.main.async {
+                locationManager.startMonitoring(for: region)
+            }
+        }
+
+        return .commit
+    }
+}
+
+ +

The method above won’t trigger the location manager if the transaction is eventually rollbacked (explicitly, or because of an error), as in the sample code below:

+
try dbQueue.write { db in
+    // success
+    try startMonitoring(db, region)
+
+    // On error, the transaction is rollbacked, the region is not inserted, and
+    // the location manager is not invoked.
+    try failableMethod(db)
+}
+
+

ValueObservation

+ +

ValueObservation tracks changes in database values. It automatically notifies your application with fresh values whenever changes are committed in the database.

+ +

Tracked changes are insertions, updates, and deletions that impact the tracked value, performed with the query interface, or raw SQL. This includes indirect changes triggered by foreign keys actions or SQL triggers.

+ +
+

:point_up: Note: Some changes are not notified: changes to internal system tables (such as sqlite\_master), and changes to WITHOUT ROWID tables.

+
+ +

ValueObservation is the preferred GRDB tool for keeping your user interface synchronized with the database. See the Demo Applications for sample code.

+ + +

ValueObservation Usage

+ +
    +
  1. Make sure that a unique database connection is kept open during the whole duration of the observation.

    + +

    ValueObservation does not notify changes performed by external connections.

  2. +
  3. Define a ValueObservation by providing a function that fetches the observed value.

    +
    let observation = ValueObservation.tracking { db in
    +    /* fetch and return the observed value */
    +}
    +
    +// For example, an observation of [Player], which tracks all players:
    +let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +// The same observation, using shorthand notation:
    +let observation = ValueObservation.tracking(Player.fetchAll)
    +
    + +

    The observation can perform multiple requests, from multiple database tables, and even use raw SQL.

    + +
    + Example of a more complex ValueObservation + +“`swift +struct HallOfFame { + var totalPlayerCount: Int + var bestPlayers: [Player] +} + +// An observation of HallOfFame +let observation = ValueObservation.tracking { db -> HallOfFame in + let totalPlayerCount = try Player.fetchCount(db) + + let bestPlayers = try Player + .order(Column("score”).desc) + .limit(10) + .fetchAll(db) + + return HallOfFame( + totalPlayerCount: totalPlayerCount, + bestPlayers: bestPlayers) +} +“` + +
    + +
    + Example of a SQL ValueObservation + +”`swift +// An observation of the maximum score +let observation = ValueObservation.tracking { db in + try Int.fetchOne(db, sql: “SELECT MAX(score) FROM player”) +} +“` + +
  4. +
  5. Start the observation in order to be notified of changes:

    +
    // Start observing the database
    +let cancellable: DatabaseCancellable = observation.start(
    +    in: dbQueue, // or dbPool
    +    onError: { error in print("players could not be fetched") },
    +    onChange: { (players: [Player]) in print("fresh players", players) })
    +
  6. +
  7. Stop the observation by calling the cancel() method on the object returned by the start method. Cancellation is automatic when the cancellable is deinitialized:

    +
    cancellable.cancel()
    +
  8. +
+ +

As a convenience, ValueObservation can be turned into a Combine publisher, or a RxSwift Observable (see Combine Support and the companion library RxGRDB):

+ +
+ Combine example + +”`swift +import Combine +import GRDB + +let observation = ValueObservation.tracking(Player.fetchAll) + +let cancellable = observation.publisher(in: dbQueue).sink( + receiveCompletion: { completion in … }, + receiveValue: { (players: [Player]) in + print(“fresh players”, players) + }) +“` + +See [Combine Support] for more information. + +
+ +
+ RxSwift example + +”`swift +import GRDB +import RxGRDB +import RxSwift + +let observation = ValueObservation.tracking(Player.fetchAll) + +let disposable = observation.rx.observe(in: dbQueue).subscribe( + onNext: { (players: [Player]) in + print(“fresh players”, players) + }, + onError: { error in … }) +“` + +See the companion library [RxGRDB] for more information. + +
+ +

Generally speaking:

+ +
    +
  • ValueObservation notifies an initial value before the eventual changes.
  • +
  • ValueObservation only notifies changes committed to disk.
  • +
  • By default, ValueObservation notifies a fresh value whenever any of its component is modified (any fetched column, row, etc.). This can be configured.
  • +
  • By default, ValueObservation notifies the initial value, as well as eventual changes and errors, on the main thread, asynchronously. This can be configured.
  • +
  • ValueObservation may coalesce subsequent changes into a single notification.
  • +
  • ValueObservation may notify consecutive identical values. You can filter out the undesired duplicates with the removeDuplicates() method.
  • +
  • The database observation stops when any of those conditions is met: + +
      +
    • The cancellable returned by the start method is cancelled or deinitialized.
    • +
    • An error occurs.
    • +
    • The database connection is closed.
    • +
  • +
+ +

Take care that there are use cases that ValueObservation is unfit for. For example, your application may need to process absolutely all changes, and avoid any coalescing. It may also need to process changes before any further modifications are performed in the database file. In those cases, you need to track individual transactions, not values. See DatabaseRegionObservation. If you need to process uncommitted changes, see TransactionObserver.

+

ValueObservation Scheduling

+ +

By default, ValueObservation notifies the initial value, as well as eventual changes and errors, on the main thread, asynchronously:

+
// The default scheduling
+let cancellable = observation.start(
+    in: dbQueue,
+    onError: { error in ... },                   // called asynchronously on the main thread
+    onChange: { value in print("fresh value") }) // called asynchronously on the main thread
+
+ +

You can change this behavior by adding a scheduling argument to the start() method.

+ +

For example, scheduling: .immediate makes sure the initial value is notified immediately when the observation starts. It helps your application update the user interface without having to wait for any asynchronous notifications:

+
class PlayersViewController: UIViewController {
+    private var cancellable: DatabaseCancellable?
+
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+
+        // Start observing the database
+        let observation = ValueObservation.tracking(Player.fetchAll)
+        cancellable = observation.start(
+            in: dbQueue,
+            scheduling: .immediate, // <- immediate scheduler
+            onError: { error in ... },
+            onChange: { [weak self] (players: [Player]) in
+                guard let self = self else { return }
+                self.updateView(players)
+            })
+        // <- Here the view has already been updated.
+    }
+
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+
+        // Stop observing the database
+        cancellable?.cancel()
+    }
+
+    private func updateView(_ players: [Player]) { ... }
+}
+
+ +

Note that the .immediate scheduling requires that the observation starts from the main thread. A fatal error is raised otherwise.

+ +

The other built-in scheduler .async(onQueue:) asynchronously schedules values and errors on the dispatch queue of your choice:

+
let queue: DispatchQueue = ...
+let cancellable = observation.start(
+    in: dbQueue,
+    scheduling: .async(onQueue: queue)
+    onError: { error in ... },                   // called asynchronously on queue
+    onChange: { value in print("fresh value") }) // called asynchronously on queue
+
+

ValueObservation Operators

+ +

Operators are methods that transform and configure value observations so that they better fit the needs of your application.

+ + + +

Debugging Operators

+ + +

ValueObservation.map

+ +

The map operator transforms the values notified by a ValueObservation.

+ +

For example:

+
// Turn an observation of Player? into an observation of UIImage?
+let observation = ValueObservation
+    .tracking { db in try Player.fetchOne(db, id: 42) }
+    .map { player in player?.image }
+
+ +

The transformation function does not block any database access. This makes the map operator a tool which helps reducing database contention.

+

ValueObservation.removeDuplicates

+ +

The removeDuplicates operator filters out consecutive equal values. The observed values must adopt the standard Equatable protocol.

+ +

For example:

+
// An observation of distinct Player?
+let observation = ValueObservation
+    .tracking { db in try Player.fetchOne(db, id: 42) }
+    .removeDuplicates()
+
+ +

:bulb: Tip: When the observed value does not adopt Equatable, you can observe distinct raw database values such as Row or DatabaseValue, before converting them to the desired type. For example, the previous observation can be rewritten as below:

+
// An observation of distinct Player?
+let request = Player.filter(id: 42)
+let observation = ValueObservation
+    .tracking { db in try Row.fetchOne(db, request) }
+    .removeDuplicates() // Row adopts Equatable
+    .map { row in row.map(Player.init(row:) }
+
+ +

This technique is also available for requests that involve Associations:

+
struct TeamInfo: Decodable, FetchableRecord {
+    var team: Team
+    var players: [Player]
+}
+
+// An observation of distinct [TeamInfo]
+let request = Team.including(all: Team.players)
+let observation = ValueObservation
+    .tracking { db in try Row.fetchAll(db, request) }
+    .removeDuplicates() // Row adopts Equatable
+    .map { rows in rows.map(TeamInfo.init(row:) }
+
+

ValueObservation.requiresWriteAccess

+ +

The requiresWriteAccess property is false by default. When true, a ValueObservation has a write access to the database, and its fetches are automatically wrapped in a savepoint:

+
var observation = ValueObservation.tracking { db in
+    // write access allowed
+    ...
+}
+observation.requiresWriteAccess = true
+
+ +

When you use a database pool, this flag has a performance hit.

+

ValueObservation.handleEvents

+ +

The handleEvents operator lets your application observe the lifetime of a ValueObservation:

+
let observation = ValueObservation
+    .tracking { db in ... }
+    .handleEvents(
+        willStart: {
+            // The observation starts.
+        },
+        willFetch: {
+            // The observation will perform a database fetch.
+        },
+        willTrackRegion: { databaseRegion in
+            // The observation starts tracking a database region.
+        },
+        databaseDidChange: {
+            // The observation was impacted by a database change.
+        },
+        didReceiveValue: { value in
+            // A fresh value was observed.
+            // NOTE: This closure runs on an unspecified DispatchQueue.
+        },
+        didFail: { error in
+            // The observation completes with an error.
+        },
+        didCancel: {
+            // The observation was cancelled.
+        })
+
+ +

See also ValueObservation.print.

+

ValueObservation.print

+ +

The print operator logs messages for all ValueObservation events.

+
let observation = ValueObservation
+    .tracking { db in ... }
+    .print()
+
+ +

See also ValueObservation.handleEvents.

+

ValueObservation Sharing

+ +

:fire: EXPERIMENTAL

+ +

Sharing a ValueObservation allows several components of your app to be notified of database changes, in an efficient way.

+ +

A shared observation spares database resources. For example, when a database change happens, a fresh value is fetched only once, and then notified to all subscriptions.

+ +

Usage:

+
// SharedValueObservation<[Player]>
+let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue)
+//  ~~~~~~~~~~~~~~~~~~~~
+
+let cancellable = try sharedObservation.start(
+    onError: { error in ... },
+    onChange: { players: [Player] in
+        print("fresh players: \(players)")
+    })
+
+ +

The sharing only applies if you start observing the database from the same SharedValueObservation instance:

+
// NOT shared
+let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+
+// Shared
+let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
+let cancellable1 = sharedObservation.start(...)
+let cancellable2 = sharedObservation.start(...)
+
+ +

By default, fresh values are dispatched asynchronously on the main queue. You can change this behavior (see ValueObservation Scheduling for more information):

+
let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue, scheduling: .immediate)
+//                       ~~~~~~~~~~~~~~~~~~~~~~
+
+ +

A shared observation starts observing the database as soon as it is subscribed. You can choose if database observation should stop, or not, when its number of subscriptions drops down to zero, with the extent parameter:

+
// The default: stops observing the database when the number of subscriptions 
+// drops down to zero, and restart database observation on the next subscription.
+//
+// Database errors can be recovered by resubscribing to the shared observation.
+let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue, extent: .whileObserved)
+//                       ~~~~~~~~~~~~~~~~~~~~~~
+
+// Only stops observing the database when the shared observation is deinitialized,
+// and all subscriptions are cancelled.
+//
+// This extent prevents the shared observation from recovering from database
+// errors. To recover from database errors, create a new shared
+// SharedValueObservation instance.
+let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue, extent: .observationLifetime)
+//                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ +
+

:point_up: Note: ValueObservation and SharedValueObservation are nearly identical, but there are a few differences you should be aware of:

+ +
    +
  • SharedValueObservation has no operator such as map. As a replacement, you may use Combine apis:

    +
    let sharedObservation = ValueObservation.tracking { ... }.shared(in: dbQueue)
    +let cancellable = try sharedObservation
    +    .publisher() // Turn shared observation into a Combine Publisher
    +    .map { ... } // The map operator from Combine
    +    .sink(...)
    +
  • +
  • Unlike ValueObservation, SharedValueObservation retains the database connection. As long as there exists a SharedValueObservation instance, or an active suscription to a shared observation, the database connection won’t be deinitialized.

  • +
+
+

Specifying the Region Tracked by ValueObservation

+ +

While the standard ValueObservation.tracking { db in ... } method lets you track changes to a fetched value and receive any changes to it, sometimes your use case might require more granular control.

+ +

Consider a scenario where you’d like to get a specific Player’s row, but only when their score column changes. You can use tracking(region:fetch:) to do just that:

+
let observation = ValueObservation.tracking(
+    // Define what database region constitutes a "change"
+    region: Player.select(Column("score")).filter(id: 1),
+    // Define what to fetch upon such change
+    fetch: { db in try Player.fetchOne(db, id: 1) }
+)
+
+ +

This overload of ValueObservation lets you entirely separate the observed region from the fetched value itself, providing utmost flexibility. See DatabaseRegionConvertible for more information.

+

ValueObservation Performance

+ +

This chapter further describes runtime aspects of ValueObservation, and provides some optimization tips for demanding applications.

+ +

ValueObservation is triggered by database transactions that may modify the tracked value.

+ +

For example, if you track the maximum score of players, all transactions that impact the score column of the player database table (any update, insertion, or deletion) trigger the observation, even if the maximum score itself is not changed.

+ +

You can filter out undesired duplicate notifications with the removeDuplicates() method.

+ +

ValueObservation can create database contention. In other words, active observations take a toll on the constrained database resources. When triggered by impactful transactions, observations fetch fresh values, and can delay read and write database accesses of other application components.

+ +

When needed, you can help GRDB optimize observations and reduce database contention:

+ +
    +
  1. :bulb: Tip: Stop observations when possible.

    + +

    For example, if a UIViewController needs to display database values, it can start the observation in viewWillAppear, and stop it in viewWillDisappear. Check the sample code above.

  2. +
  3. :bulb: Tip: Share observations when possible.

    + +

    Each call to ValueObservation.start method triggers independent values refreshes. When several components of your app are interested in the same value, consider sharing the observation.

  4. +
  5. :bulb: Tip: Use a database pool, because it can perform multi-threaded database accesses.

  6. +
  7. :bulb: Tip: When the observation processes some raw fetched values, use the map operator:

    +
    // Plain observation
    +let observation = ValueObservation.tracking { db -> MyValue in
    +    let players = try Player.fetchAll(db)
    +    return computeMyValue(players)
    +}
    +
    +// Optimized observation
    +let observation = ValueObservation
    +    .tracking { db try Player.fetchAll(db) }
    +    .map { players in computeMyValue(players) }
    +
    + +

    The map operator helps reducing database contention because it performs its job without blocking concurrent database reads.

  8. +
  9. :bulb: Tip: When the observation tracks a constant database region, create an optimized observation with the ValueObservation.trackingConstantRegion(_:) method.

    + +

    The optimization only kicks in when the observation is started from a database pool: fresh values are fetched concurrently, and do not block database writes.

    + +

    The ValueObservation.trackingConstantRegion(_:) has a precondition: the observed requests must fetch from a single and constant database region. The tracked region is made of tables, columns, and, when possible, rowids of individual rows. All changes that happen outside of this region do not impact the observation.

    + +

    For example:

    +
    // Tracks the full 'player' table (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> [Player] in
    +    try Player.fetchAll(db)
    +}
    +
    +// Tracks the row with id 42 in the 'player' table (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> Player? in
    +    try Player.fetchOne(db, id: 42)
    +}
    +
    +// Tracks the 'score' column in the 'player' table (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> Int? in
    +    try Player.select(max(Column("score"))).fetchOne(db)
    +}
    +
    +// Tracks both the 'player' and 'team' tables (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> ([Team], [Player]) in
    +    let teams = try Team.fetchAll(db)
    +    let players = try Player.fetchAll(db)
    +    return (teams, players)
    +}
    +
    + +

    When you want to observe a varying database region, make sure you use the plain ValueObservation.tracking(_:) method instead, or else some changes will not be notified.

    + +

    For example, consider those three observations below that depend on some user preference. They all track a varying region, and must use ValueObservation.tracking(_:):

    +
    // Does not always track the same row in the player table.
    +let observation = ValueObservation.tracking { db -> Player? in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    return try Player.fetchOne(db, id: pref.favoritePlayerId)
    +}
    +
    +// Only tracks the 'user' table if there are some blocked emails.
    +let observation = ValueObservation.tracking { db -> [User] in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    let blockedEmails = pref.blockedEmails
    +    return try User.filter(blockedEmails.contains(Column("email"))).fetchAll(db)
    +}
    +
    +// Sometimes tracks the 'food' table, and sometimes the 'beverage' table.
    +let observation = ValueObservation.tracking { db -> Int in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    switch pref.selection {
    +    case .food: return try Food.fetchCount(db)
    +    case .beverage: return try Beverage.fetchCount(db)
    +    }
    +}
    +
    + +

    When you are in doubt, add the print() method to your observation before starting it, and look in your application logs for lines that start with tracked region. Make sure the printed database region covers the changes you expect to be tracked.

    + +

    + Examples of tracked regions

  10. +
+
- `empty`: The empty region, which tracks nothing and never triggers the observation.
+- `player(*)`: The full `player` table
+- `player(id,name)`: The `id` and `name` columns of the `player` table
+- `player(id,name)[1]`: The `id` and `name` columns of the row with id 1 in the `player` table
+- `player(*),preference(*)`: Both the full `player` and `preference` tables
+
+</details>
+
+

DatabaseRegionObservation

+ +

DatabaseRegionObservation tracks changes in database requests, and notifies each impactful transaction.

+ +

Tracked changes are insertions, updates, and deletions that impact the tracked requests, performed with the query interface, or raw SQL. This includes indirect changes triggered by foreign keys actions or SQL triggers.

+ +
+

:point_up: Note: Some changes are not notified: changes to internal system tables (such as sqlite_master), and changes to WITHOUT ROWID tables.

+
+ +

DatabaseRegionObservation calls your application right after changes have been committed in the database, and before any other thread had any opportunity to perform further changes. This is a pretty strong guarantee, that most applications do not really need. Instead, most applications prefer to be notified with fresh values: make sure you check ValueObservation before using DatabaseRegionObservation.

+

DatabaseRegionObservation Usage

+ +

Define an observation by providing one or several requests to track:

+
// Track all players
+let observation = DatabaseRegionObservation(tracking: Player.all())
+
+ +

Then start the observation from a database queue or pool:

+
let observer = try observation.start(in: dbQueue) { (db: Database) in
+    print("Players were changed")
+}
+
+ +

And enjoy the changes notifications:

+
try dbQueue.write { db in
+    try Player(name: "Arthur").insert(db)
+}
+// Prints "Players were changed"
+
+ +

By default, the observation lasts until the observer returned by the start method is deinitialized. See DatabaseRegionObservation.extent for more details.

+ +

You can also feed DatabaseRegionObservation with DatabaseRegion, or any type which conforms to the DatabaseRegionConvertible protocol. For example:

+
// Observe the full database
+let observation = DatabaseRegionObservation(tracking: DatabaseRegion.fullDatabase)
+let observer = try observation.start(in: dbQueue) { (db: Database) in
+    print("Database was changed")
+}
+
+

DatabaseRegionObservation.extent

+ +

The extent property lets you specify the duration of the observation. See Observation Extent for more details:

+
// This observation lasts until the database connection is closed
+var observation = DatabaseRegionObservation...
+observation.extent = .databaseLifetime
+_ = try observation.start(in: dbQueue) { db in ... }
+
+ +

The default extent is .observerLifetime: the observation stops when the observer returned by start is deinitialized.

+ +

Regardless of the extent of an observation, you can always stop observation with the remove(transactionObserver:) method:

+
// Start
+let observer = try observation.start(in: dbQueue) { db in ... }
+
+// Stop
+dbQueue.remove(transactionObserver: observer)
+
+

TransactionObserver Protocol

+ +

The TransactionObserver protocol lets you observe individual database changes and transactions:

+
protocol TransactionObserver : class {
+    /// Notifies a database change:
+    /// - event.kind (insert, update, or delete)
+    /// - event.tableName
+    /// - event.rowID
+    ///
+    /// For performance reasons, the event is only valid for the duration of
+    /// this method call. If you need to keep it longer, store a copy:
+    /// event.copy().
+    func databaseDidChange(with event: DatabaseEvent)
+
+    /// Filters the database changes that should be notified to the
+    /// `databaseDidChange(with:)` method.
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool
+
+    /// An opportunity to rollback pending changes by throwing an error.
+    func databaseWillCommit() throws
+
+    /// Database changes have been committed.
+    func databaseDidCommit(_ db: Database)
+
+    /// Database changes have been rollbacked.
+    func databaseDidRollback(_ db: Database)
+}
+
+ + +

Activate a Transaction Observer

+ +

To activate a transaction observer, add it to the database queue or pool:

+
let observer = MyObserver()
+dbQueue.add(transactionObserver: observer)
+
+ +

By default, database holds weak references to its transaction observers: they are not retained, and stop getting notifications after they are deinitialized. See Observation Extent for more options.

+

Database Changes And Transactions

+ +

A transaction observer is notified of all database changes: inserts, updates and deletes. This includes indirect changes triggered by ON DELETE and ON UPDATE actions associated to foreign keys, and SQL triggers.

+ +
+

:point_up: Note: Some changes are not notified: changes to internal system tables (such as sqlite_master), changes to WITHOUT ROWID tables, and the deletion of duplicate rows triggered by ON CONFLICT REPLACE clauses (this last exception might change in a future release of SQLite).

+
+ +

Notified changes are not actually written to disk until the transaction commits, and the databaseDidCommit callback is called. On the other side, databaseDidRollback confirms their invalidation:

+
try dbQueue.write { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange
+    try db.execute(sql: "UPDATE ...") // 2. didChange
+}                                     // 3. willCommit, 4. didCommit
+
+try dbQueue.inTransaction { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange
+    try db.execute(sql: "UPDATE ...") // 2. didChange
+    return .rollback                  // 3. didRollback
+}
+
+try dbQueue.write { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange
+    throw SomeError()
+}                                     // 2. didRollback
+
+ +

Database statements that are executed outside of any transaction do not drop off the radar:

+
try dbQueue.inDatabase { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange, 2. willCommit, 3. didCommit
+    try db.execute(sql: "UPDATE ...") // 4. didChange, 5. willCommit, 6. didCommit
+}
+
+ +

Changes that are on hold because of a savepoint are only notified after the savepoint has been released. This makes sure that notified events are only events that have an opportunity to be committed:

+
try dbQueue.inTransaction { db in
+    try db.execute(sql: "INSERT ...")            // 1. didChange
+
+    try db.execute(sql: "SAVEPOINT foo")
+    try db.execute(sql: "UPDATE ...")            // delayed
+    try db.execute(sql: "UPDATE ...")            // delayed
+    try db.execute(sql: "RELEASE SAVEPOINT foo") // 2. didChange, 3. didChange
+
+    try db.execute(sql: "SAVEPOINT foo")
+    try db.execute(sql: "UPDATE ...")            // not notified
+    try db.execute(sql: "ROLLBACK TO SAVEPOINT foo")
+
+    return .commit                               // 4. willCommit, 5. didCommit
+}
+
+ +

Eventual errors thrown from databaseWillCommit are exposed to the application code:

+
do {
+    try dbQueue.inTransaction { db in
+        ...
+        return .commit           // 1. willCommit (throws), 2. didRollback
+    }
+} catch {
+    // 3. The error thrown by the transaction observer.
+}
+
+ +
+

:point_up: Note: all callbacks are called in a protected dispatch queue, and serialized with all database updates.

+ +

:point_up: Note: the databaseDidChange(with:) and databaseWillCommit() callbacks must not touch the SQLite database. This limitation does not apply to databaseDidCommit and databaseDidRollback which can use their database argument.

+
+ +

DatabaseRegionObservation and ValueObservation are based on the TransactionObserver protocol.

+ +

See also TableChangeObserver.swift, which shows a transaction observer that notifies of modified database tables with NSNotificationCenter.

+

Filtering Database Events

+ +

Transaction observers can avoid being notified of database changes they are not interested in.

+ +

The filtering happens in the observes(eventsOfKind:) method, which tells whether the observer wants notification of specific kinds of changes, or not. For example, here is how an observer can focus on the changes that happen on the "player” database table:

+
class PlayerObserver: TransactionObserver {
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        // Only observe changes to the "player" table.
+        return eventKind.tableName == "player"
+    }
+
+    func databaseDidChange(with event: DatabaseEvent) {
+        // This method is only called for changes that happen to
+        // the "player" table.
+    }
+}
+
+ +

Generally speaking, the observes(eventsOfKind:) method can distinguish insertions from deletions and updates, and is also able to inspect the columns that are about to be changed:

+
class PlayerScoreObserver: TransactionObserver {
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        // Only observe changes to the "score" column of the "player" table.
+        switch eventKind {
+        case .insert(let tableName):
+            return tableName == "player"
+        case .delete(let tableName):
+            return tableName == "player"
+        case .update(let tableName, let columnNames):
+            return tableName == "player" && columnNames.contains("score")
+        }
+    }
+}
+
+ +

When the observes(eventsOfKind:) method returns false for all event kinds, the observer is still notified of commits and rollbacks:

+
class PureTransactionObserver: TransactionObserver {
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        // Ignore all individual changes
+        return false
+    }
+
+    func databaseDidChange(with event: DatabaseEvent) { /* Never called */ }
+    func databaseWillCommit() throws { /* Called before commit */ }
+    func databaseDidRollback(_ db: Database) { /* Called on rollback */ }
+    func databaseDidCommit(_ db: Database) { /* Called on commit */ }
+}
+
+ +

For more information about event filtering, see DatabaseRegion.

+

Observation Extent

+ +

You can specify how long an observer is notified of database changes and transactions.

+ +

The remove(transactionObserver:) method explicitly stops notifications, at any time:

+
// From a database queue or pool:
+dbQueue.remove(transactionObserver: observer)
+
+// From a database connection:
+dbQueue.inDatabase { db in
+    db.remove(transactionObserver: observer)
+}
+
+ +

Alternatively, use the extent parameter of the add(transactionObserver:extent:) method:

+
let observer = MyObserver()
+
+// On a database queue or pool:
+dbQueue.add(transactionObserver: observer) // default extent
+dbQueue.add(transactionObserver: observer, extent: .observerLifetime)
+dbQueue.add(transactionObserver: observer, extent: .nextTransaction)
+dbQueue.add(transactionObserver: observer, extent: .databaseLifetime)
+
+// On a database connection:
+dbQueue.inDatabase { db in
+    db.add(transactionObserver: ...)
+}
+
+ +
    +
  • The default extent is .observerLifetime: the database holds a weak reference to the observer, and the observation automatically ends when the observer is deinitialized. Meanwhile, observer is notified of all changes and transactions.

  • +
  • .nextTransaction activates the observer until the current or next transaction completes. The database keeps a strong reference to the observer until its databaseDidCommit or databaseDidRollback method is eventually called. Hereafter the observer won’t get any further notification.

  • +
  • .databaseLifetime has the database retain and notify the observer until the database connection is closed.

  • +
+ +

Finally, an observer may ignore all database changes until the end of the current transaction:

+
class PlayerObserver: TransactionObserver {
+    var playerTableWasModified = false
+
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        eventKind.tableName == "player"
+    }
+
+    func databaseDidChange(with event: DatabaseEvent) {
+        playerTableWasModified = true
+
+        // It is pointless to keep on tracking further changes:
+        stopObservingDatabaseChangesUntilNextTransaction()
+    }
+}
+
+ +

After stopObservingDatabaseChangesUntilNextTransaction(), the databaseDidChange(with:) method will not be notified of any change for the remaining duration of the current transaction. This helps GRDB optimize database observation.

+

DatabaseRegion

+ +

A DatabaseRegion is a reunion of database tables, and combination of columns and rows (identified by their rowid):

+
|Table1 |   |Table2 |   |Table3 |   |Table4 |   |Table5 |
+|-------|   |-------|   |-------|   |-------|   |-------|
+|x|x|x|x|   |x| | | |   |x|x|x|x|   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | |x| | |
+|x|x|x|x|   |x| | | |   | | | | |   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | | | | |
+
+ +

DatabaseRegion helps ValueObservation and DatabaseRegionObservation track changes in the database through the TransactionObserver protocol.

+ +

Note that observing a database region spots potential changes, not actual changes in the results of a request. A change is notified if and only if a statement has actually modified the tracked tables and columns by inserting, updating, or deleting a row.

+ +

For example, if you observe the region of Player.select(max(Column("score"))), then you’ll get be notified of all changes performed on the score column of the player table (updates, insertions and deletions), even if they do not modify the value of the maximum score. However, you will not get any notification for changes performed on other database tables, or updates to other columns of the player table.

+ +

For more details, see the reference.

+

The DatabaseRegionConvertible Protocol

+ +

DatabaseRegionConvertible is a protocol for all types that can turn into a DatabaseRegion:

+
protocol DatabaseRegionConvertible {
+    func databaseRegion(_ db: Database) throws -> DatabaseRegion
+}
+
+ +

All requests adopt this protocol, and this allows them to be observed with DatabaseRegionObservation and ValueObservation.

+ +

For example:

+
// 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"))
+
+ +

Note that specifying a region as a request does not run the request. In the above example, Player.filter(id: 1) and SELECT score FROM player are never executed. They are only compiled by SQLite, so that GRDB understands the tables, rows, and columns that constitute the database region.

+

Support for SQLite Pre-Update Hooks

+ +

When SQLite is built with the SQLITE_ENABLE_PREUPDATE_HOOK option, TransactionObserverType gets an extra callback which lets you observe individual column values in the rows modified by a transaction:

+
protocol TransactionObserverType : class {
+    #if SQLITE_ENABLE_PREUPDATE_HOOK
+    /// Notifies before a database change (insert, update, or delete)
+    /// with change information (initial / final values for the row's
+    /// columns).
+    ///
+    /// The event is only valid for the duration of this method call. If you
+    /// need to keep it longer, store a copy: event.copy().
+    func databaseWillChange(with event: DatabasePreUpdateEvent)
+    #endif
+}
+
+ +

This extra API can be activated in two ways:

+ +
    +
  1. Use the GRDB.swift CocoaPod with a custom compilation option, as below. It uses the system SQLite, which is compiled with SQLITE_ENABLE_PREUPDATE_HOOK support, but only on iOS 11.0+ (we don’t know the minimum version of macOS, tvOS, watchOS):

    +
    pod 'GRDB.swift'
    +platform :ios, '11.0' # or above
    +
    +post_install do |installer|
    +  installer.pods_project.targets.select { |target| target.name == "GRDB.swift" }.each do |target|
    +    target.build_configurations.each do |config|
    +      # Enable extra GRDB APIs
    +      config.build_settings['OTHER_SWIFT_FLAGS'] = "$(inherited) -D SQLITE_ENABLE_PREUPDATE_HOOK"
    +      # Enable extra SQLite APIs
    +      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = "$(inherited) GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1"
    +    end
    +  end
    +end
    +
    + +
    +

    :warning: Warning: make sure you use the right platform version! You will get runtime errors on devices with a lower version.

    + +

    :point_up: Note: the GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1 option in GCC_PREPROCESSOR_DEFINITIONS defines some C function prototypes that are lacking from the system <sqlite3.h> header. When Xcode eventually ships with an SDK that includes a complete header, you may get a compiler error about duplicate function definitions. When this happens, just remove this GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1 option.

    +
  2. +
  3. Use a custom SQLite build and activate the SQLITE_ENABLE_PREUPDATE_HOOK compilation option.

  4. +
+

Encryption

+ +

GRDB can encrypt your database with SQLCipher v3.4+.

+ +

Use CocoaPods, and specify in your Podfile:

+
# GRDB with SQLCipher 4
+pod 'GRDB.swift/SQLCipher'
+pod 'SQLCipher', '~> 4.0'
+
+# GRDB with SQLCipher 3
+pod 'GRDB.swift/SQLCipher'
+pod 'SQLCipher', '~> 3.4'
+
+ + +

Creating or Opening an Encrypted Database

+ +

You create and open an encrypted database by providing a passphrase to your database connection:

+
var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

It is also in prepareDatabase that you perform other SQLCipher configuration steps that must happen early in the lifetime of a SQLCipher connection. For example:

+
var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+    try db.execute(sql: "PRAGMA cipher_page_size = ...")
+    try db.execute(sql: "PRAGMA kdf_iter = ...")
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

When you want to open an existing SQLCipher 3 database with SQLCipher 4, you may want to run the cipher_compatibility pragma:

+
// Open an SQLCipher 3 database with SQLCipher 4
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+    try db.execute(sql: "PRAGMA cipher_compatibility = 3")
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

See SQLCipher 4.0.0 Release and Upgrading to SQLCipher 4 for more information.

+

Changing the Passphrase of an Encrypted Database

+ +

You can change the passphrase of an already encrypted database.

+ +

When you use a database queue, open the database with the old passphrase, and then apply the new passphrase:

+
try dbQueue.write { db in
+    try db.changePassphrase("newSecret")
+}
+
+ +

When you use a database pool, make sure that no concurrent read can happen by changing the passphrase within the barrierWriteWithoutTransaction block. You must also ensure all future reads open a new database connection by calling the invalidateReadOnlyConnections method:

+
try dbPool.barrierWriteWithoutTransaction { db in
+    try db.changePassphrase("newSecret")
+    dbPool.invalidateReadOnlyConnections()
+}
+
+ +
+

:point_up: Note: When an application wants to keep on using a database queue or pool after the passphrase has changed, it is responsible for providing the correct passphrase to the usePassphrase method called in the database preparation function. Consider:

+
// WRONG: this won't work across a passphrase change
+let passphrase = try getPassphrase()
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase(passphrase)
+}
+
+// CORRECT: get the latest passphrase when it is needed
+var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try getPassphrase()
+    try db.usePassphrase(passphrase)
+}
+
+ +

:point_up: Note: The DatabasePool.barrierWriteWithoutTransaction method does not prevent database snapshots from accessing the database during the passphrase change, or after the new passphrase has been applied to the database. Those database accesses may throw errors. Applications should provide their own mechanism for invalidating open snapshots before the passphrase is changed.

+ +

:point_up: Note: Instead of changing the passphrase “in place” as described here, you can also export the database in a new encrypted database that uses the new passphrase. See Exporting a Database to an Encrypted Database.

+
+

Exporting a Database to an Encrypted Database

+ +

Providing a passphrase won’t encrypt a clear-text database that already exists, though. SQLCipher can’t do that, and you will get an error instead: SQLite error 26: file is encrypted or is not a database.

+ +

Instead, create a new encrypted database, at a distinct location, and export the content of the existing database. This can both encrypt a clear-text database, or change the passphrase of an encrypted database.

+ +

The technique to do that is documented by SQLCipher.

+ +

With GRDB, it gives:

+
// The existing database
+let existingDBQueue = try DatabaseQueue(path: "/path/to/existing.db")
+
+// The new encrypted database, at some distinct location:
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+}
+let newDBQueue = try DatabaseQueue(path: "/path/to/new.db", configuration: config)
+
+try existingDBQueue.inDatabase { db in
+    try db.execute(
+        sql: """
+            ATTACH DATABASE ? AS encrypted KEY ?;
+            SELECT sqlcipher_export('encrypted');
+            DETACH DATABASE encrypted;
+            """,
+        arguments: [newDBQueue.path, "secret"])
+}
+
+// Now the export is completed, and the existing database can be deleted.
+
+

Security Considerations

+

Managing the lifetime of the passphrase string

+ +

It is recommended to avoid keeping the passphrase in memory longer than necessary. To do this, make sure you load the passphrase from the prepareDatabase method:

+
// NOT RECOMMENDED: this keeps the passphrase in memory longer than necessary
+let passphrase = try getPassphrase()
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase(passphrase)
+}
+
+// RECOMMENDED: only load the passphrase when it is needed
+var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try getPassphrase()
+    try db.usePassphrase(passphrase)
+}
+
+ +

This technique helps manages the lifetime of the passphrase, although keep in mind that the content of a String may remain intact in memory long after the object has been released.

+ +

For even better control over the lifetime of the passphrase in memory, use a Data object which natively provides the resetBytes function.

+
// RECOMMENDED: only load the passphrase when it is needed and reset its content immediately after use
+var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try getPassphraseData() // Data
+    defer {
+        passphrase.resetBytes(in: 0..<data.count)
+    }
+    try db.usePassphrase(passphrase)
+}
+
+ +

Some demanding users will want to go further, and manage the lifetime of the raw passphrase bytes. See below.

+

Managing the lifetime of the passphrase bytes

+ +

GRDB offers convenience methods for providing the database passphrases as Swift strings: usePassphrase(_:) and changePassphrase(_:). Those methods don’t keep the passphrase String in memory longer than necessary. But they are as secure as the standard String type: the lifetime of actual passphrase bytes in memory is not under control.

+ +

When you want to precisely manage the passphrase bytes, talk directly to SQLCipher, using its raw C functions.

+ +

For example:

+
var config = Configuration()
+config.prepareDatabase { db in
+    ... // Carefully load passphrase bytes
+    let code = sqlite3_key(db.sqliteConnection, /* passphrase bytes */)
+    ... // Carefully dispose passphrase bytes
+    guard code == SQLITE_OK else {
+        throw DatabaseError(
+            resultCode: ResultCode(rawValue: code), 
+            message: db.lastErrorMessage)
+    }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+

Passphrase availability vs. Database availability

+ +

When the passphrase is securely stored in the system keychain, your application can protect it using the kSecAttrAccessible attribute.

+ +

Such protection prevents GRDB from creating SQLite connections when the passphrase is not available:

+
var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try loadPassphraseFromSystemKeychain()
+    try db.usePassphrase(passphrase)
+}
+
+// Success if and only if the passphrase is available
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

For the same reason, database pools, which open SQLite connections on demand, may fail at any time as soon as the passphrase becomes unavailable:

+
// Success if and only if the passphrase is available
+let dbPool = try DatabasePool(path: dbPath, configuration: config)
+
+// May fail if passphrase has turned unavailable
+try dbPool.read { ... }
+
+// May trigger value observation failure if passphrase has turned unavailable
+try dbPool.write { ... }
+
+ +

Because DatabasePool maintains a pool of long-lived SQLite connections, some database accesses will use an existing connection, and succeed. And some other database accesses will fail, as soon as the pool wants to open a new connection. It is impossible to predict which accesses will succeed or fail.

+ +

For the same reason, a database queue, which also maintains a long-lived SQLite connection, will remain available even after the passphrase has turned unavailable.

+ +

Applications are thus responsible for protecting database accesses when the passphrase is unavailable. To this end, they can use Data Protection. They can also destroy their instances of database queue or pool when the passphrase becomes unavailable.

+

Backup

+ +

You can backup (copy) a database into another.

+ +

Backups can for example help you copying an in-memory database to and from a database file when you implement NSDocument subclasses.

+
let source: DatabaseQueue = ...      // or DatabasePool
+let destination: DatabaseQueue = ... // or DatabasePool
+try source.backup(to: destination)
+
+ +

The backup method blocks the current thread until the destination database contains the same contents as the source database.

+ +

When the source is a database pool, concurrent writes can happen during the backup. Those writes may, or may not, be reflected in the backup, but they won’t trigger any error.

+

Interrupt a Database

+ +

The interrupt() method causes any pending database operation to abort and return at its earliest opportunity.

+ +

It can be called from any thread.

+
dbQueue.interrupt()
+dbPool.interrupt()
+
+ +

A call to interrupt() that occurs when there are no running SQL statements is a no-op and has no effect on SQL statements that are started after interrupt() returns.

+ +

A database operation that is interrupted will throw a DatabaseError with code SQLITE_INTERRUPT. If the interrupted SQL operation is an INSERT, UPDATE, or DELETE that is inside an explicit transaction, then the entire transaction will be rolled back automatically. If the rolled back transaction was started by a transaction-wrapping method such as DatabaseWriter.write or Database.inTransaction, then all database accesses will throw a DatabaseError with code SQLITE_ABORT until the wrapping method returns.

+ +

For example:

+
try dbQueue.write { db in
+    try Player(...).insert(db)     // throws SQLITE_INTERRUPT
+    try Player(...).insert(db)     // not executed
+}                                  // throws SQLITE_INTERRUPT
+
+try dbQueue.write { db in
+    do {
+        try Player(...).insert(db) // throws SQLITE_INTERRUPT
+    } catch { }
+}                                  // throws SQLITE_ABORT
+
+try dbQueue.write { db in
+    do {
+        try Player(...).insert(db) // throws SQLITE_INTERRUPT
+    } catch { }
+    try Player(...).insert(db)     // throws SQLITE_ABORT
+}                                  // throws SQLITE_ABORT
+
+ +

You can catch both SQLITE_INTERRUPT and SQLITE_ABORT errors:

+
do {
+    try dbPool.write { db in ... }
+} catch DatabaseError.SQLITE_INTERRUPT, DatabaseError.SQLITE_ABORT {
+    // Oops, the database was interrupted.
+}
+
+ +

For more information, see Interrupt A Long-Running Query.

+

Avoiding SQL Injection

+ +

SQL injection is a technique that lets an attacker nuke your database.

+ +
+

XKCD: Exploits of a Mom

+ +

https://xkcd.com/327/

+
+ +

Here is an example of code that is vulnerable to SQL injection:

+
// BAD BAD BAD
+let id = 1
+let name = textField.text
+try dbQueue.write { db in
+    try db.execute(sql: "UPDATE students SET name = '\(name)' WHERE id = \(id)")
+}
+
+ +

If the user enters a funny string like Robert'; DROP TABLE students; --, SQLite will see the following SQL, and drop your database table instead of updating a name as intended:

+
UPDATE students SET name = 'Robert';
+DROP TABLE students;
+--' WHERE id = 1
+
+ +

To avoid those problems, never embed raw values in your SQL queries. The only correct technique is to provide arguments to your raw SQL queries:

+
let name = textField.text
+try dbQueue.write { db in
+    // Good
+    try db.execute(
+        sql: "UPDATE students SET name = ? WHERE id = ?",
+        arguments: [name, id])
+
+    // Just as good
+    try db.execute(
+        sql: "UPDATE students SET name = :name WHERE id = :id",
+        arguments: ["name": name, "id": id])
+}
+
+ +

When you use records and the query interface, GRDB always prevents SQL injection for you:

+
let id = 1
+let name = textField.text
+try dbQueue.write { db in
+    if var student = try Student.fetchOne(db, id: id) {
+        student.name = name
+        try student.update(db)
+    }
+}
+
+

Error Handling

+ +

GRDB can throw DatabaseError, PersistenceError, or crash your program with a fatal error.

+ +

Considering that a local database is not some JSON loaded from a remote server, GRDB focuses on trusted databases. Dealing with untrusted databases requires extra care.

+ + +

DatabaseError

+ +

DatabaseError are thrown on SQLite errors:

+
do {
+    try Pet(masterId: 1, name: "Bobby").insert(db)
+} catch let error as DatabaseError {
+    // The SQLite error code: 19 (SQLITE_CONSTRAINT)
+    error.resultCode
+
+    // The extended error code: 787 (SQLITE_CONSTRAINT_FOREIGNKEY)
+    error.extendedResultCode
+
+    // The eventual SQLite message: FOREIGN KEY constraint failed
+    error.message
+
+    // The eventual erroneous SQL query
+    // "INSERT INTO pet (masterId, name) VALUES (?, ?)"
+    error.sql
+
+    // The eventual SQL arguments
+    // [1, "Bobby"]
+    error.arguments
+
+    // Full error description:
+    // "SQLite error 19 with statement `INSERT INTO pet (masterId, name)
+    //  VALUES (?, ?)` arguments [1, "Bobby"]: FOREIGN KEY constraint failed""
+    error.description
+}
+
+ +

SQLite uses results codes to distinguish between various errors.

+ +

You can catch a DatabaseError and match on result codes:

+
do {
+    try ...
+} catch let error as DatabaseError {
+    switch error {
+    case DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY:
+        // foreign key constraint error
+    case DatabaseError.SQLITE_CONSTRAINT:
+        // any other constraint error
+    default:
+        // any other database error
+    }
+}
+
+ +

You can also directly match errors on result codes:

+
do {
+    try ...
+} catch DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY {
+    // foreign key constraint error
+} catch DatabaseError.SQLITE_CONSTRAINT {
+    // any other constraint error
+} catch {
+    // any other database error
+}
+
+ +

Each DatabaseError has two codes: an extendedResultCode (see extended result code), and a less precise resultCode (see primary result code). Extended result codes are refinements of primary result codes, as SQLITE_CONSTRAINT_FOREIGNKEY is to SQLITE_CONSTRAINT, for example.

+ +
+

:warning: Warning: SQLite has progressively introduced extended result codes across its versions. The SQLite release notes are unfortunately not quite clear about that: write your handling of extended result codes with care.

+
+

PersistenceError

+ +

PersistenceError is thrown by the PersistableRecord protocol, in a single case: when the update method could not find any row to update:

+
do {
+    try player.update(db)
+} catch let PersistenceError.recordNotFound(databaseTableName: table, key: key) {
+    print("Key \(key) was not found in table \(table).")
+}
+
+

Fatal Errors

+ +

Fatal errors notify that the program, or the database, has to be changed.

+ +

They uncover programmer errors, false assumptions, and prevent misuses. Here are a few examples:

+ +
    +
  • The code asks for a non-optional value, when the database contains NULL:

    +
    // fatal error: could not convert NULL to String.
    +let name: String = row["name"]
    +
    + +

    Solution: fix the contents of the database, use NOT NULL constraints, or load an optional:

    +
    let name: String? = row["name"]
    +
  • +
  • Conversion from database value to Swift type fails:

    +
    // fatal error: could not convert "Mom’s birthday" to Date.
    +let date: Date = row["date"]
    +
    +// fatal error: could not convert "" to URL.
    +let url: URL = row["url"]
    +
    + +

    Solution: fix the contents of the database, or use DatabaseValue to handle all possible cases:

    +
    let dbValue: DatabaseValue = row["date"]
    +if dbValue.isNull {
    +    // Handle NULL
    +} else if let date = Date.fromDatabaseValue(dbValue) {
    +    // Handle valid date
    +} else {
    +    // Handle invalid date
    +}
    +
  • +
  • The database can’t guarantee that the code does what it says:

    +
    // fatal error: table player has no unique index on column email
    +try Player.deleteOne(db, key: ["email": "arthur@example.com"])
    +
    + +

    Solution: add a unique index to the player.email column, or use the deleteAll method to make it clear that you may delete more than one row:

    +
    try Player.filter(Column("email") == "arthur@example.com").deleteAll(db)
    +
  • +
  • Database connections are not reentrant:

    +
    // fatal error: Database methods are not reentrant.
    +dbQueue.write { db in
    +    dbQueue.write { db in
    +        ...
    +    }
    +}
    +
    + +

    Solution: avoid reentrancy, and instead pass a database connection along.

  • +
+

How to Deal with Untrusted Inputs

+ +

Let’s consider the code below:

+
let sql = "SELECT ..."
+
+// Some untrusted arguments for the query
+let arguments: [String: Any] = ...
+let rows = try Row.fetchCursor(db, sql: sql, arguments: StatementArguments(arguments))
+
+while let row = try rows.next() {
+    // Some untrusted database value:
+    let date: Date? = row[0]
+}
+
+ +

It has two opportunities to throw fatal errors:

+ +
    +
  • Untrusted arguments: The dictionary may contain values that do not conform to the DatabaseValueConvertible protocol, or may miss keys required by the statement.
  • +
  • Untrusted database content: The row may contain a non-null value that can’t be turned into a date.
  • +
+ +

In such a situation, you can still avoid fatal errors by exposing and handling each failure point, one level down in the GRDB API:

+
// Untrusted arguments
+if let arguments = StatementArguments(arguments) {
+    let statement = try db.makeStatement(sql: sql)
+    try statement.setArguments(arguments)
+
+    var cursor = try Row.fetchCursor(statement)
+    while let row = try iterator.next() {
+        // Untrusted database content
+        let dbValue: DatabaseValue = row[0]
+        if dbValue.isNull {
+            // Handle NULL
+        if let date = Date.fromDatabaseValue(dbValue) {
+            // Handle valid date
+        } else {
+            // Handle invalid date
+        }
+    }
+}
+
+ +

See prepared statements and DatabaseValue for more information.

+

Error Log

+ +

SQLite can be configured to invoke a callback function containing an error code and a terse error message whenever anomalies occur.

+ +

This global error callback must be configured early in the lifetime of your application:

+
Database.logError = { (resultCode, message) in
+    NSLog("%@", "SQLite error \(resultCode): \(message)")
+}
+
+ +
+

:warning: Warning: Database.logError must be set before any database connection is opened. This includes the connections that your application opens with GRDB, but also connections opened by other tools, such as third-party libraries. Setting it after a connection has been opened is an SQLite misuse, and has no effect.

+
+ +

See The Error And Warning Log for more information.

+

Unicode

+ +

SQLite lets you store unicode strings in the database.

+ +

However, SQLite does not provide any unicode-aware string transformations or comparisons.

+

Unicode functions

+ +

The UPPER and LOWER built-in SQLite functions are not unicode-aware:

+
// "JéRôME"
+try String.fetchOne(db, sql: "SELECT UPPER('Jérôme')")
+
+ +

GRDB extends SQLite with SQL functions that call the Swift built-in string functions capitalized, lowercased, uppercased, localizedCapitalized, localizedLowercased and localizedUppercased:

+
// "JÉRÔME"
+let uppercased = DatabaseFunction.uppercase
+try String.fetchOne(db, sql: "SELECT \(uppercased.name)('Jérôme')")
+
+ +

Those unicode-aware string functions are also readily available in the query interface:

+
Player.select(nameColumn.uppercased)
+
+

String Comparison

+ +

SQLite compares strings in many occasions: when you sort rows according to a string column, or when you use a comparison operator such as = and <=.

+ +

The comparison result comes from a collating function, or collation. SQLite comes with three built-in collations that do not support Unicode: binary, nocase, and rtrim.

+ +

GRDB comes with five extra collations that leverage unicode-aware comparisons based on the standard Swift String comparison functions and operators:

+ +
    +
  • unicodeCompare (uses the built-in <= and == Swift operators)
  • +
  • caseInsensitiveCompare
  • +
  • localizedCaseInsensitiveCompare
  • +
  • localizedCompare
  • +
  • localizedStandardCompare
  • +
+ +

A collation can be applied to a table column. All comparisons involving this column will then automatically trigger the comparison function:

+
try db.create(table: "player") { t in
+    // Guarantees case-insensitive email unicity
+    t.column("email", .text).unique().collate(.nocase)
+
+    // Sort names in a localized case insensitive way
+    t.column("name", .text).collate(.localizedCaseInsensitiveCompare)
+}
+
+// Players are sorted in a localized case insensitive way:
+let players = try Player.order(nameColumn).fetchAll(db)
+
+ +
+

:warning: Warning: SQLite requires host applications to provide the definition of any collation other than binary, nocase and rtrim. When a database file has to be shared or migrated to another SQLite library of platform (such as the Android version of your application), make sure you provide a compatible collation.

+
+ +

If you can’t or don’t want to define the comparison behavior of a column (see warning above), you can still use an explicit collation in SQL requests and in the query interface:

+
let collation = DatabaseCollation.localizedCaseInsensitiveCompare
+let players = try Player.fetchAll(db,
+    sql: "SELECT * FROM player ORDER BY name COLLATE \(collation.name))")
+let players = try Player.order(nameColumn.collating(collation)).fetchAll(db)
+
+ +

You can also define your own collations:

+
let collation = DatabaseCollation("customCollation") { (lhs, rhs) -> NSComparisonResult in
+    // return the comparison of lhs and rhs strings.
+}
+
+// Make the collation available to a database connection
+var config = Configuration()
+config.prepareDatabase { db in
+    db.add(collation: collation)
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+

Memory Management

+ +

Both SQLite and GRDB use non-essential memory that help them perform better.

+ +

You can reclaim this memory with the releaseMemory method:

+
// Release as much memory as possible.
+dbQueue.releaseMemory()
+dbPool.releaseMemory()
+
+ +

This method blocks the current thread until all current database accesses are completed, and the memory collected.

+

Memory Management on iOS

+ +

The iOS operating system likes applications that do not consume much memory.

+ +

Database queues and pools automatically call the releaseMemory method when the application receives a memory warning, and when the application enters background.

+

Data Protection

+ +

Data Protection lets you protect files so that they are encrypted and unavailable until the device is unlocked.

+ +

Data protection can be enabled globally for all files created by an application.

+ +

You can also explicitly protect a database, by configuring its enclosing directory. This will not only protect the database file, but also all temporary files created by SQLite (including the persistent .shm and .wal files created by database pools).

+ +

For example, to explicitly use complete protection:

+
// Paths
+let fileManager = FileManager.default
+let directoryURL = try fileManager
+    .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+    .appendingPathComponent("database", isDirectory: true)
+let databaseURL = directoryURL.appendingPathComponent("db.sqlite")
+
+// Create directory if needed
+var isDirectory: ObjCBool = false
+if !fileManager.fileExists(atPath: directoryURL.path, isDirectory: &isDirectory) {
+    try fileManager.createDirectory(atPath: directoryURL.path, withIntermediateDirectories: false)
+} else if !isDirectory.boolValue {
+    throw NSError(domain: NSCocoaErrorDomain, code: NSFileWriteFileExistsError, userInfo: nil)
+}
+
+// Enable data protection
+try fileManager.setAttributes([.protectionKey : FileProtectionType.complete], ofItemAtPath: directoryURL.path)
+
+// Open database
+let dbQueue = try DatabaseQueue(path: databaseURL.path)
+
+ +

When a database is protected, an application that runs in the background on a locked device won’t be able to read or write from it. Instead, it will get DatabaseError with code SQLITE_IOERR (10) “disk I/O error”, or SQLITE_AUTH (23) “not authorized”.

+ +

You can catch those errors and wait for UIApplicationDelegate.applicationProtectedDataDidBecomeAvailable(_:) or UIApplicationProtectedDataDidBecomeAvailable notification in order to retry the failed database operation.

+

FAQ

+ +

FAQ: Opening Connections

+ + + +

FAQ: SQL

+ + + +

FAQ: General

+ + + +

FAQ: Associations

+ + + +

FAQ: ValueObservation

+ + + +

FAQ: Errors

+ + +

FAQ: Opening Connections

+ + +

How do I create a database in my application?

+ +

This question assumes that your application has to create a new database from scratch. If your app has to open an existing database that is embedded inside your application as a resource, see How do I open a database stored as a resource of my application? instead.

+ +

The database has to be stored in a valid place where it can be created and modified. For example, in the Application Support directory:

+
let databaseURL = try FileManager.default
+    .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+    .appendingPathComponent("db.sqlite")
+let dbQueue = try DatabaseQueue(path: databaseURL.path)
+
+

How do I open a database stored as a resource of my application?

+ +

If your application does not need to modify the database, open a read-only connection to your resource:

+
var config = Configuration()
+config.readonly = true
+let dbPath = Bundle.main.path(forResource: "db", ofType: "sqlite")!
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

If the application should modify the database, you need to copy it to a place where it can be modified. For example, in the Application Support directory. Only then, open a connection:

+
let fileManager = FileManager.default
+let dbPath = try fileManager
+    .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+    .appendingPathComponent("db.sqlite")
+    .path
+if !fileManager.fileExists(atPath: dbPath) {
+    let dbResourcePath = Bundle.main.path(forResource: "db", ofType: "sqlite")!
+    try fileManager.copyItem(atPath: dbResourcePath, toPath: dbPath)
+}
+let dbQueue = try DatabaseQueue(path: dbPath)
+
+

How do I close a database connection?

+ +

Database connections are automatically closed when they are deinitialized.

+ +

When the correct execution of your program depends on precise database closing, use the close() method:

+
try dbQueue.close()
+
+ +

This explicit close() may fail with an error. See the inline documentation of this method for more information. Generally speaking, you should not call this method: rely on automatic closing instead.

+

FAQ: SQL

+ + +

How do I print a request as SQL?

+ +

When you want to debug a request that does not deliver the expected results, you may want to print the SQL that is actually executed.

+ +

You can compile the request into a prepared statement:

+
try dbQueue.read { db in
+    let request = Player.filter(Column("name") == "O'Brien")
+    let statement = try request.makePreparedRequest(db).statement
+    print(statement) // SQL: SELECT * FROM player WHERE name = ?, Arguments: ["O'Brien"]
+}
+
+ +

Another option is to setup a tracing function that prints out the executed SQL requests. For example, provide a tracing function when you connect to the database:

+
// Prints all SQL statements
+var config = Configuration()
+config.prepareDatabase { db in
+    db.trace { print($0) }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    let players = try Player.filter(Column("name") == "O'Brien").fetchAll(db)
+    // Prints SELECT * FROM player WHERE name = 'O''Brien'
+}
+
+ +

If you want to hide values such as 'O''Brien' from the logged statements, adapt the tracing function as below:

+
db.trace { event in
+    if case let .statement(statement) = event {
+        // Prints SELECT * FROM player WHERE name = ?
+        print(statement.sql)
+    }
+}
+
+ +
+

:point_up: Note: the generated SQL may change between GRDB releases, without notice: don’t have your application rely on any specific SQL output.

+
+

FAQ: General

+ + +

How do I monitor the duration of database statements execution?

+ +

Use the trace(options:_:) method, with the .profile option:

+
var config = Configuration()
+config.prepareDatabase { db in
+    db.trace(options: .profile) { event in
+        // Prints all SQL statements with their duration
+        print(event)
+
+        // Access to detailed profiling information
+        if case let .profile(statement, duration) = event, duration > 0.5 {
+            print("Slow query: \(statement.sql)")
+        }
+    }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    let players = try Player.filter(Column("name") == "O'Brien").fetchAll(db)
+    // Prints "0.003s SELECT * FROM player WHERE name = 'O''Brien'"
+}
+
+

What Are Experimental Features?

+ +

Since GRDB 1.0, all backwards compatibility guarantees of semantic versioning apply: no breaking change will happen until the next major version of the library.

+ +

There is an exception, though: experimental features, marked with the “:fire: EXPERIMENTAL” badge. Those are advanced features that are too young, or lack user feedback. They are not stabilized yet.

+ +

Those experimental features are not protected by semantic versioning, and may break between two minor releases of the library. To help them becoming stable, your feedback is greatly appreciated.

+

Does GRDB support library evolution and ABI stability?

+ +

No, GRDB does not support library evolution and ABI stability. The only promise is API stability according to semantic versioning, with an exception for experimental features.

+ +

Yet, GRDB can be built with the “Build Libraries for Distribution” Xcode option (BUILD_LIBRARY_FOR_DISTRIBUTION), so that you can build binary frameworks at your convenience.

+

FAQ: Associations

+ + +

How do I filter records and only keep those that are associated to another record?

+ +

Let’s say you have two record types, Book and Author, and you want to only fetch books that have an author, and discard anonymous books.

+ +

We start by defining the association between books and authors:

+
struct Book: TableRecord {
+    ...
+    static let author = belongsTo(Author.self)
+}
+
+struct Author: TableRecord {
+    ...
+}
+
+ +

And then we can write our request and only fetch books that have an author, discarding anonymous ones:

+
let books: [Book] = try dbQueue.read { db in
+    // SELECT book.* FROM book 
+    // JOIN author ON author.id = book.authorID
+    let request = Book.joining(required: Book.author)
+    return try request.fetchAll(db)
+}
+
+ +

Note how this request does not use the filter method. Indeed, we don’t have any condition to express on any column. Instead, we just need to “require that a book can be joined to its author”.

+ +

See How do I filter records and only keep those that are NOT associated to another record? below for the opposite question.

+

How do I filter records and only keep those that are NOT associated to another record?

+ +

Let’s say you have two record types, Book and Author, and you want to only fetch anonymous books that do not have any author.

+ +

We start by defining the association between books and authors:

+
struct Book: TableRecord {
+    ...
+    static let author = belongsTo(Author.self)
+}
+
+struct Author: TableRecord {
+    ...
+}
+
+ +

And then we can write our request and only fetch anonymous books that don’t have any author:

+
let books: [Book] = try dbQueue.read { db in
+    // SELECT book.* FROM book
+    // LEFT JOIN author ON author.id = book.authorID
+    // WHERE author.id IS NULL
+    let authorAlias = TableAlias()
+    let request = Book
+        .joining(optional: Book.author.aliased(authorAlias))
+        .filter(!authorAlias.exists)
+    return try request.fetchAll(db)
+}
+
+ +

This request uses a TableAlias in order to be able to filter on the eventual associated author. We make sure that the Author.primaryKey is nil, which is another way to say it does not exist: the book has no author.

+ +

See How do I filter records and only keep those that are associated to another record? above for the opposite question.

+

How do I select only one column of an associated record?

+ +

Let’s say you have two record types, Book and Author, and you want to fetch all books with their author name, but not the full associated author records.

+ +

We start by defining the association between books and authors:

+
struct Book: Decodable, TableRecord {
+    ...
+    static let author = belongsTo(Author.self)
+}
+
+struct Author: Decodable, TableRecord {
+    ...
+    enum Columns {
+        static let name = Column(CodingKeys.name)
+    }
+}
+
+ +

And then we can write our request and the ad-hoc record that decodes it:

+
struct BookInfo: Decodable, FetchableRecord {
+    var book: Book
+    var authorName: String? // nil when the book is anonymous
+
+    static func all() -> QueryInterfaceRequest<BookInfo> {
+        // SELECT book.*, author.name AS authorName
+        // FROM book
+        // LEFT JOIN author ON author.id = book.authorID
+        let authorName = Author.Columns.name.forKey(CodingKeys.authorName)
+        return Book
+            .annotated(withOptional: Book.author.select(authorName))
+            .asRequest(of: BookInfo.self)
+    }
+}
+
+let bookInfos: [BookInfo] = try dbQueue.read { db in
+    BookInfo.all().fetchAll(db)
+}
+
+ +

By defining the request as a static method of BookInfo, you have access to the private CodingKeys.authorName, and a compiler-checked SQL column name.

+ +

By using the annotated(withOptional:) method, you append the author name to the top-level selection that can be decoded by the ad-hoc record.

+ +

By using asRequest(of:), you enhance the type-safety of your request.

+

FAQ: ValueObservation

+ + +

Why is ValueObservation not publishing value changes?

+ +

Sometimes it looks that a ValueObservation does not notify the changes you expect.

+ +

There may be four possible reasons for this:

+ +
    +
  1. The expected changes were not committed into the database.
  2. +
  3. The expected changes were committed into the database, but were quickly overwritten.
  4. +
  5. The observation was stopped.
  6. +
  7. The observation does not track the expected database region.
  8. +
+ +

To answer the first two questions, look at SQL statements executed by the database. This is done when you open the database connection:

+
// Prints all SQL statements
+var config = Configuration()
+config.prepareDatabase { db in
+    db.trace { print("SQL: \($0)") }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

If, after that, you are convinced that the expected changes were committed into the database, and not overwritten soon after, trace observation events:

+
let observation = ValueObservation
+    .tracking { db in ... }
+    .print() // <- trace observation events
+let cancellable = observation.start(...)
+
+ +

Look at the observation logs which start with cancel or failure: maybe the observation was cancelled by your app, or did fail with an error.

+ +

Look at the observation logs which start with value: make sure, again, that the expected value was not actually notified, then overwritten.

+ +

Finally, look at the observation logs which start with tracked region. Does the printed database region cover the expected changes?

+ +

For example:

+ +
    +
  • empty: The empty region, which tracks nothing and never triggers the observation.
  • +
  • player(*): The full player table
  • +
  • player(id,name): The id and name columns of the player table
  • +
  • player(id,name)[1]: The id and name columns of the row with id 1 in the player table
  • +
  • player(*),team(*): Both the full player and team tables
  • +
+ +

If you happen to use the ValueObservation.trackingConstantRegion(_:) method and see a mismatch between the tracked region and your expectation, then change the definition of your observation by using tracking(_:). You should witness that the logs which start with tracked region now evolve in order to include the expected changes, and that you get the expected notifications.

+ +

If after all those steps (thanks you!), your observation is still failing you, please open an issue and provide a minimal reproducible example!

+

FAQ: Errors

+ + +

Generic parameter ‘T’ could not be inferred

+ +

You may get this error when using the read and write methods of database queues and pools:

+
// Generic parameter 'T' could not be inferred
+let string = try dbQueue.read { db in
+    let result = try String.fetchOne(db, ...)
+    return result
+}
+
+ +

This is a limitation of the Swift compiler.

+ +

The general workaround is to explicitly declare the type of the closure result:

+
// General Workaround
+let string = try dbQueue.read { db -> String? in
+    let result = try String.fetchOne(db, ...)
+    return result
+}
+
+ +

You can also, when possible, write a single-line closure:

+
// Single-line closure workaround:
+let string = try dbQueue.read { db in
+    try String.fetchOne(db, ...)
+}
+
+

SQLite error 1 “no such column”

+ +

This error message is self-explanatory: do check for misspelled or non-existing column names.

+ +

However, sometimes this error only happens when an app runs on a recent operating system (iOS 14+, Big Sur+, etc.) The error does not happen with previous ones.

+ +

When this is the case, there are two possible explanations:

+ +
    +
  1. Maybe a column name is really misspelled or missing from the database schema.

    + +

    To find it, check the SQL statement that comes with the DatabaseError.

  2. +
  3. Maybe the application is using the character " instead of the single quote ' as the delimiter for string literals in raw SQL queries. Recent versions of SQLite have learned to tell about this deviation from the SQL standard, and this is why you are seeing this error.

    + +

    For example: this is not standard SQL: UPDATE player SET name = "Arthur".

    + +

    The standard version is: UPDATE player SET name = 'Arthur'.

    + +

    It just happens that old versions of SQLite used to accept the former, non-standard version. Newer versions are able to reject it with an error.

    + +

    The fix is to change the SQL statements run by the application: replace " with ' in your string literals.

    + +

    It may also be time to learn about statement arguments and SQL injection:

    +
    let name: String = ...
    +
    +// NOT STANDARD (double quote)
    +try db.execute(sql: """
    +    UPDATE player SET name = "\(name)"
    +    """)
    +
    +// STANDARD, BUT STILL NOT RECOMMENDED (single quote)
    +try db.execute(sql: "UPDATE player SET name = '\(name)'")
    +
    +// STANDARD, AND RECOMMENDED (statement arguments)
    +try db.execute(sql: "UPDATE player SET name = ?", arguments: [name])
    +
  4. +
+ +

For more information, see Double-quoted String Literals Are Accepted, and Configuration.acceptsDoubleQuotedStringLiterals.

+

SQLite error 10 “disk I/O error”, SQLite error 23 “not authorized”

+ +

Those errors may be the sign that SQLite can’t access the database due to data protection.

+ +

When your application should be able to run in the background on a locked device, it has to catch this error, and, for example, wait for UIApplicationDelegate.applicationProtectedDataDidBecomeAvailable(_:) or UIApplicationProtectedDataDidBecomeAvailable notification and retry the failed database operation.

+
do {
+    try ...
+} catch DatabaseError.SQLITE_IOERR, DatabaseError.SQLITE_AUTH {
+    // Handle possible data protection error
+}
+
+ +

This error can also be prevented altogether by using a more relaxed file protection.

+

SQLite error 21 “wrong number of statement arguments” with LIKE queries

+ +

You may get the error “wrong number of statement arguments” when executing a LIKE query similar to:

+
let name = textField.text
+let players = try dbQueue.read { db in
+    try Player.fetchAll(db, sql: "SELECT * FROM player WHERE name LIKE '%?%'", arguments: [name])
+}
+
+ +

The problem lies in the '%?%' pattern.

+ +

SQLite only interprets ? as a parameter when it is a placeholder for a whole value (int, double, string, blob, null). In this incorrect query, ? is just a character in the '%?%' string: it is not a query parameter, and is not processed in any way. See https://www.sqlite.org/lang_expr.html#varparam for more information about SQLite parameters.

+ +

To fix the error, you can feed the request with the pattern itself, instead of the name:

+
let name = textField.text
+let players: [Player] = try dbQueue.read { db in
+    let pattern = "%\(name)%"
+    return try Player.fetchAll(db, sql: "SELECT * FROM player WHERE name LIKE ?", arguments: [pattern])
+}
+
+

Sample Code

+ + + +
+ +

Thanks

+ + + +
+ +

URIs don’t change: people change them.

+

Changes Tracking

+ +

This chapter has been renamed Record Comparison.

+

Customized Decoding of Database Rows

+ +

This chapter has been renamed Beyond FetchableRecord.

+

Dealing with External Connections

+ +

This chapter has been superseded by the Sharing a Database guide.

+

Enabling FTS5 Support

+ +

This chapter has moved.

+

FetchedRecordsController

+ +

FetchedRecordsController has been removed in GRDB 5.

+ +

The Database Observation chapter describes the other ways to observe the database.

+ + +

This chapter has moved.

+

Migrations

+ +

This chapter has moved.

+

NSNumber and NSDecimalNumber

+ +

This chapter has moved

+

Persistable Protocol

+ +

This protocol has been renamed PersistableRecord in GRDB 3.0.

+

RowConvertible Protocol

+ +

This protocol has been renamed FetchableRecord in GRDB 3.0.

+

TableMapping Protocol

+ +

This protocol has been renamed TableRecord in GRDB 3.0.

+

ValueObservation and DatabaseRegionObservation

+ +

This chapter has been superseded by ValueObservation and DatabaseRegionObservation.

+

Concurrency

+ +

This chapter has moved.

+

Guarantees and Rules

+ +

This chapter is now split into Concurrency Rules and Safe and Unsafe Database Accesses.

+

Differences between Database Queues and Pools

+ +

This chapter has moved.

+

Advanced DatabasePool

+ +

This chapter has moved.

+

Database Snapshots

+ +

This chapter has moved.

+

DatabaseWriter and DatabaseReader Protocols

+ +

This chapter was removed. See the references of DatabaseReader and DatabaseWriter.

+

Asynchronous APIs

+ +

This chapter has moved.

+

Unsafe Concurrency APIs

+ +

This chapter has moved.

+ +
+
+ +
+
+ + diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jazzy.js b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jazzy.js new file mode 100755 index 000000000..198441660 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jazzy.js @@ -0,0 +1,74 @@ +// Jazzy - https://github.com/realm/jazzy +// Copyright Realm Inc. +// SPDX-License-Identifier: MIT + +window.jazzy = {'docset': false} +if (typeof window.dash != 'undefined') { + document.documentElement.className += ' dash' + window.jazzy.docset = true +} +if (navigator.userAgent.match(/xcode/i)) { + document.documentElement.className += ' xcode' + window.jazzy.docset = true +} + +function toggleItem($link, $content) { + var animationDuration = 300; + $link.toggleClass('token-open'); + $content.slideToggle(animationDuration); +} + +function itemLinkToContent($link) { + return $link.parent().parent().next(); +} + +// On doc load + hash-change, open any targetted item +function openCurrentItemIfClosed() { + if (window.jazzy.docset) { + return; + } + var $link = $(`a[name="${location.hash.substring(1)}"]`).nextAll('.token'); + $content = itemLinkToContent($link); + if ($content.is(':hidden')) { + toggleItem($link, $content); + } +} + +$(openCurrentItemIfClosed); +$(window).on('hashchange', openCurrentItemIfClosed); + +// On item link ('token') click, toggle its discussion +$('.token').on('click', function(event) { + if (window.jazzy.docset) { + return; + } + var $link = $(this); + toggleItem($link, itemLinkToContent($link)); + + // Keeps the document from jumping to the hash. + var href = $link.attr('href'); + if (history.pushState) { + history.pushState({}, '', href); + } else { + location.hash = href; + } + event.preventDefault(); +}); + +// Clicks on links to the current, closed, item need to open the item +$("a:not('.token')").on('click', function() { + if (location == this.href) { + openCurrentItemIfClosed(); + } +}); + +// KaTeX rendering +if ("katex" in window) { + $($('.math').each( (_, element) => { + katex.render(element.textContent, element, { + displayMode: $(element).hasClass('m-block'), + throwOnError: false, + trust: true + }); + })) +} diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jazzy.search.js b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jazzy.search.js new file mode 100644 index 000000000..359cdbb8b --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jazzy.search.js @@ -0,0 +1,74 @@ +// Jazzy - https://github.com/realm/jazzy +// Copyright Realm Inc. +// SPDX-License-Identifier: MIT + +$(function(){ + var $typeahead = $('[data-typeahead]'); + var $form = $typeahead.parents('form'); + var searchURL = $form.attr('action'); + + function displayTemplate(result) { + return result.name; + } + + function suggestionTemplate(result) { + var t = '
'; + t += '' + result.name + ''; + if (result.parent_name) { + t += '' + result.parent_name + ''; + } + t += '
'; + return t; + } + + $typeahead.one('focus', function() { + $form.addClass('loading'); + + $.getJSON(searchURL).then(function(searchData) { + const searchIndex = lunr(function() { + this.ref('url'); + this.field('name'); + this.field('abstract'); + for (const [url, doc] of Object.entries(searchData)) { + this.add({url: url, name: doc.name, abstract: doc.abstract}); + } + }); + + $typeahead.typeahead( + { + highlight: true, + minLength: 3, + autoselect: true + }, + { + limit: 10, + display: displayTemplate, + templates: { suggestion: suggestionTemplate }, + source: function(query, sync) { + const lcSearch = query.toLowerCase(); + const results = searchIndex.query(function(q) { + q.term(lcSearch, { boost: 100 }); + q.term(lcSearch, { + boost: 10, + wildcard: lunr.Query.wildcard.TRAILING + }); + }).map(function(result) { + var doc = searchData[result.ref]; + doc.url = result.ref; + return doc; + }); + sync(results); + } + } + ); + $form.removeClass('loading'); + $typeahead.trigger('focus'); + }); + }); + + var baseURL = searchURL.slice(0, -"search.json".length); + + $typeahead.on('typeahead:select', function(e, result) { + window.location = baseURL + result.url; + }); +}); diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jquery.min.js b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jquery.min.js new file mode 100644 index 000000000..c4c6022f2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/jquery.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 00){var c=e.utils.clone(r)||{};c.position=[a,l],c.index=s.length,s.push(new e.Token(i.slice(a,o),c))}a=o+1}}return s},e.tokenizer.separator=/[\s\-]+/,e.Pipeline=function(){this._stack=[]},e.Pipeline.registeredFunctions=Object.create(null),e.Pipeline.registerFunction=function(t,r){r in this.registeredFunctions&&e.utils.warn("Overwriting existing registered function: "+r),t.label=r,e.Pipeline.registeredFunctions[t.label]=t},e.Pipeline.warnIfFunctionNotRegistered=function(t){var r=t.label&&t.label in this.registeredFunctions;r||e.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",t)},e.Pipeline.load=function(t){var r=new e.Pipeline;return t.forEach(function(t){var i=e.Pipeline.registeredFunctions[t];if(!i)throw new Error("Cannot load unregistered function: "+t);r.add(i)}),r},e.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(t){e.Pipeline.warnIfFunctionNotRegistered(t),this._stack.push(t)},this)},e.Pipeline.prototype.after=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,r)},e.Pipeline.prototype.before=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");this._stack.splice(i,0,r)},e.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);t!=-1&&this._stack.splice(t,1)},e.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r1&&(se&&(r=n),s!=e);)i=r-t,n=t+Math.floor(i/2),s=this.elements[2*n];return s==e?2*n:s>e?2*n:sa?l+=2:o==a&&(t+=r[u+1]*i[l+1],u+=2,l+=2);return t},e.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},e.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t0){var o,a=s.str.charAt(0);a in s.node.edges?o=s.node.edges[a]:(o=new e.TokenSet,s.node.edges[a]=o),1==s.str.length&&(o["final"]=!0),n.push({node:o,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(0!=s.editsRemaining){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new e.TokenSet;s.node.edges["*"]=u}if(0==s.str.length&&(u["final"]=!0),n.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&n.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),1==s.str.length&&(s.node["final"]=!0),s.str.length>=1){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new e.TokenSet;s.node.edges["*"]=l}1==s.str.length&&(l["final"]=!0),n.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var c,h=s.str.charAt(0),d=s.str.charAt(1);d in s.node.edges?c=s.node.edges[d]:(c=new e.TokenSet,s.node.edges[d]=c),1==s.str.length&&(c["final"]=!0),n.push({node:c,editsRemaining:s.editsRemaining-1,str:h+s.str.slice(2)})}}}return i},e.TokenSet.fromString=function(t){for(var r=new e.TokenSet,i=r,n=0,s=t.length;n=e;t--){var r=this.uncheckedNodes[t],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r["char"]]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}},e.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},e.Index.prototype.search=function(t){return this.query(function(r){var i=new e.QueryParser(t,r);i.parse()})},e.Index.prototype.query=function(t){for(var r=new e.Query(this.fields),i=Object.create(null),n=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),u=0;u1?this._b=1:this._b=e},e.Builder.prototype.k1=function(e){this._k1=e},e.Builder.prototype.add=function(t,r){var i=t[this._ref],n=Object.keys(this._fields);this._documents[i]=r||{},this.documentCount+=1;for(var s=0;s=this.length)return e.QueryLexer.EOS;var t=this.str.charAt(this.pos);return this.pos+=1,t},e.QueryLexer.prototype.width=function(){return this.pos-this.start},e.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},e.QueryLexer.prototype.backup=function(){this.pos-=1},e.QueryLexer.prototype.acceptDigitRun=function(){var t,r;do t=this.next(),r=t.charCodeAt(0);while(r>47&&r<58);t!=e.QueryLexer.EOS&&this.backup()},e.QueryLexer.prototype.more=function(){return this.pos1&&(t.backup(),t.emit(e.QueryLexer.TERM)),t.ignore(),t.more())return e.QueryLexer.lexText},e.QueryLexer.lexEditDistance=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.EDIT_DISTANCE),e.QueryLexer.lexText},e.QueryLexer.lexBoost=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.BOOST),e.QueryLexer.lexText},e.QueryLexer.lexEOS=function(t){t.width()>0&&t.emit(e.QueryLexer.TERM)},e.QueryLexer.termSeparator=e.tokenizer.separator,e.QueryLexer.lexText=function(t){for(;;){var r=t.next();if(r==e.QueryLexer.EOS)return e.QueryLexer.lexEOS;if(92!=r.charCodeAt(0)){if(":"==r)return e.QueryLexer.lexField;if("~"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexEditDistance;if("^"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexBoost;if("+"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if("-"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if(r.match(e.QueryLexer.termSeparator))return e.QueryLexer.lexTerm}else t.escapeCharacter()}},e.QueryParser=function(t,r){this.lexer=new e.QueryLexer(t),this.query=r,this.currentClause={},this.lexemeIdx=0},e.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var t=e.QueryParser.parseClause;t;)t=t(this);return this.query},e.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},e.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},e.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},e.QueryParser.parseClause=function(t){var r=t.peekLexeme();if(void 0!=r)switch(r.type){case e.QueryLexer.PRESENCE:return e.QueryParser.parsePresence;case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expected either a field or a term, found "+r.type;throw r.str.length>=1&&(i+=" with value '"+r.str+"'"),new e.QueryParseError(i,r.start,r.end)}},e.QueryParser.parsePresence=function(t){var r=t.consumeLexeme();if(void 0!=r){switch(r.str){case"-":t.currentClause.presence=e.Query.presence.PROHIBITED;break;case"+":t.currentClause.presence=e.Query.presence.REQUIRED;break;default:var i="unrecognised presence operator'"+r.str+"'";throw new e.QueryParseError(i,r.start,r.end)}var n=t.peekLexeme();if(void 0==n){var i="expecting term or field, found nothing";throw new e.QueryParseError(i,r.start,r.end)}switch(n.type){case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expecting term or field, found '"+n.type+"'";throw new e.QueryParseError(i,n.start,n.end)}}},e.QueryParser.parseField=function(t){var r=t.consumeLexeme();if(void 0!=r){if(t.query.allFields.indexOf(r.str)==-1){var i=t.query.allFields.map(function(e){return"'"+e+"'"}).join(", "),n="unrecognised field '"+r.str+"', possible fields: "+i;throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.fields=[r.str];var s=t.peekLexeme();if(void 0==s){var n="expecting term, found nothing";throw new e.QueryParseError(n,r.start,r.end)}switch(s.type){case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var n="expecting term, found '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseTerm=function(t){var r=t.consumeLexeme();if(void 0!=r){t.currentClause.term=r.str.toLowerCase(),r.str.indexOf("*")!=-1&&(t.currentClause.usePipeline=!1);var i=t.peekLexeme();if(void 0==i)return void t.nextClause();switch(i.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+i.type+"'";throw new e.QueryParseError(n,i.start,i.end)}}},e.QueryParser.parseEditDistance=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="edit distance must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.editDistance=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseBoost=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="boost must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.boost=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.lunr=t()}(this,function(){return e})}(); diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/typeahead.jquery.js b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/typeahead.jquery.js new file mode 100644 index 000000000..3a2d2ab03 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/js/typeahead.jquery.js @@ -0,0 +1,1694 @@ +/*! + * typeahead.js 1.3.1 + * https://github.com/corejavascript/typeahead.js + * Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT + */ + + +(function(root, factory) { + if (typeof define === "function" && define.amd) { + define([ "jquery" ], function(a0) { + return factory(a0); + }); + } else if (typeof module === "object" && module.exports) { + module.exports = factory(require("jquery")); + } else { + factory(root["jQuery"]); + } +})(this, function($) { + var _ = function() { + "use strict"; + return { + isMsie: function() { + return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false; + }, + isBlankString: function(str) { + return !str || /^\s*$/.test(str); + }, + escapeRegExChars: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + isString: function(obj) { + return typeof obj === "string"; + }, + isNumber: function(obj) { + return typeof obj === "number"; + }, + isArray: $.isArray, + isFunction: $.isFunction, + isObject: $.isPlainObject, + isUndefined: function(obj) { + return typeof obj === "undefined"; + }, + isElement: function(obj) { + return !!(obj && obj.nodeType === 1); + }, + isJQuery: function(obj) { + return obj instanceof $; + }, + toStr: function toStr(s) { + return _.isUndefined(s) || s === null ? "" : s + ""; + }, + bind: $.proxy, + each: function(collection, cb) { + $.each(collection, reverseArgs); + function reverseArgs(index, value) { + return cb(value, index); + } + }, + map: $.map, + filter: $.grep, + every: function(obj, test) { + var result = true; + if (!obj) { + return result; + } + $.each(obj, function(key, val) { + if (!(result = test.call(null, val, key, obj))) { + return false; + } + }); + return !!result; + }, + some: function(obj, test) { + var result = false; + if (!obj) { + return result; + } + $.each(obj, function(key, val) { + if (result = test.call(null, val, key, obj)) { + return false; + } + }); + return !!result; + }, + mixin: $.extend, + identity: function(x) { + return x; + }, + clone: function(obj) { + return $.extend(true, {}, obj); + }, + getIdGenerator: function() { + var counter = 0; + return function() { + return counter++; + }; + }, + templatify: function templatify(obj) { + return $.isFunction(obj) ? obj : template; + function template() { + return String(obj); + } + }, + defer: function(fn) { + setTimeout(fn, 0); + }, + debounce: function(func, wait, immediate) { + var timeout, result; + return function() { + var context = this, args = arguments, later, callNow; + later = function() { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + } + }; + callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + } + return result; + }; + }, + throttle: function(func, wait) { + var context, args, timeout, result, previous, later; + previous = 0; + later = function() { + previous = new Date(); + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date(), remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }, + stringify: function(val) { + return _.isString(val) ? val : JSON.stringify(val); + }, + guid: function() { + function _p8(s) { + var p = (Math.random().toString(16) + "000000000").substr(2, 8); + return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p; + } + return "tt-" + _p8() + _p8(true) + _p8(true) + _p8(); + }, + noop: function() {} + }; + }(); + var WWW = function() { + "use strict"; + var defaultClassNames = { + wrapper: "twitter-typeahead", + input: "tt-input", + hint: "tt-hint", + menu: "tt-menu", + dataset: "tt-dataset", + suggestion: "tt-suggestion", + selectable: "tt-selectable", + empty: "tt-empty", + open: "tt-open", + cursor: "tt-cursor", + highlight: "tt-highlight" + }; + return build; + function build(o) { + var www, classes; + classes = _.mixin({}, defaultClassNames, o); + www = { + css: buildCss(), + classes: classes, + html: buildHtml(classes), + selectors: buildSelectors(classes) + }; + return { + css: www.css, + html: www.html, + classes: www.classes, + selectors: www.selectors, + mixin: function(o) { + _.mixin(o, www); + } + }; + } + function buildHtml(c) { + return { + wrapper: '', + menu: '
' + }; + } + function buildSelectors(classes) { + var selectors = {}; + _.each(classes, function(v, k) { + selectors[k] = "." + v; + }); + return selectors; + } + function buildCss() { + var css = { + wrapper: { + position: "relative", + display: "inline-block" + }, + hint: { + position: "absolute", + top: "0", + left: "0", + borderColor: "transparent", + boxShadow: "none", + opacity: "1" + }, + input: { + position: "relative", + verticalAlign: "top", + backgroundColor: "transparent" + }, + inputWithNoHint: { + position: "relative", + verticalAlign: "top" + }, + menu: { + position: "absolute", + top: "100%", + left: "0", + zIndex: "100", + display: "none" + }, + ltr: { + left: "0", + right: "auto" + }, + rtl: { + left: "auto", + right: " 0" + } + }; + if (_.isMsie()) { + _.mixin(css.input, { + backgroundImage: "url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)" + }); + } + return css; + } + }(); + var EventBus = function() { + "use strict"; + var namespace, deprecationMap; + namespace = "typeahead:"; + deprecationMap = { + render: "rendered", + cursorchange: "cursorchanged", + select: "selected", + autocomplete: "autocompleted" + }; + function EventBus(o) { + if (!o || !o.el) { + $.error("EventBus initialized without el"); + } + this.$el = $(o.el); + } + _.mixin(EventBus.prototype, { + _trigger: function(type, args) { + var $e = $.Event(namespace + type); + this.$el.trigger.call(this.$el, $e, args || []); + return $e; + }, + before: function(type) { + var args, $e; + args = [].slice.call(arguments, 1); + $e = this._trigger("before" + type, args); + return $e.isDefaultPrevented(); + }, + trigger: function(type) { + var deprecatedType; + this._trigger(type, [].slice.call(arguments, 1)); + if (deprecatedType = deprecationMap[type]) { + this._trigger(deprecatedType, [].slice.call(arguments, 1)); + } + } + }); + return EventBus; + }(); + var EventEmitter = function() { + "use strict"; + var splitter = /\s+/, nextTick = getNextTick(); + return { + onSync: onSync, + onAsync: onAsync, + off: off, + trigger: trigger + }; + function on(method, types, cb, context) { + var type; + if (!cb) { + return this; + } + types = types.split(splitter); + cb = context ? bindContext(cb, context) : cb; + this._callbacks = this._callbacks || {}; + while (type = types.shift()) { + this._callbacks[type] = this._callbacks[type] || { + sync: [], + async: [] + }; + this._callbacks[type][method].push(cb); + } + return this; + } + function onAsync(types, cb, context) { + return on.call(this, "async", types, cb, context); + } + function onSync(types, cb, context) { + return on.call(this, "sync", types, cb, context); + } + function off(types) { + var type; + if (!this._callbacks) { + return this; + } + types = types.split(splitter); + while (type = types.shift()) { + delete this._callbacks[type]; + } + return this; + } + function trigger(types) { + var type, callbacks, args, syncFlush, asyncFlush; + if (!this._callbacks) { + return this; + } + types = types.split(splitter); + args = [].slice.call(arguments, 1); + while ((type = types.shift()) && (callbacks = this._callbacks[type])) { + syncFlush = getFlush(callbacks.sync, this, [ type ].concat(args)); + asyncFlush = getFlush(callbacks.async, this, [ type ].concat(args)); + syncFlush() && nextTick(asyncFlush); + } + return this; + } + function getFlush(callbacks, context, args) { + return flush; + function flush() { + var cancelled; + for (var i = 0, len = callbacks.length; !cancelled && i < len; i += 1) { + cancelled = callbacks[i].apply(context, args) === false; + } + return !cancelled; + } + } + function getNextTick() { + var nextTickFn; + if (window.setImmediate) { + nextTickFn = function nextTickSetImmediate(fn) { + setImmediate(function() { + fn(); + }); + }; + } else { + nextTickFn = function nextTickSetTimeout(fn) { + setTimeout(function() { + fn(); + }, 0); + }; + } + return nextTickFn; + } + function bindContext(fn, context) { + return fn.bind ? fn.bind(context) : function() { + fn.apply(context, [].slice.call(arguments, 0)); + }; + } + }(); + var highlight = function(doc) { + "use strict"; + var defaults = { + node: null, + pattern: null, + tagName: "strong", + className: null, + wordsOnly: false, + caseSensitive: false, + diacriticInsensitive: false + }; + var accented = { + A: "[AaªÀ-Åà-åĀ-ąǍǎȀ-ȃȦȧᴬᵃḀḁẚẠ-ảₐ℀℁℻⒜Ⓐⓐ㍱-㍴㎀-㎄㎈㎉㎩-㎯㏂㏊㏟㏿Aa]", + B: "[BbᴮᵇḂ-ḇℬ⒝Ⓑⓑ㍴㎅-㎇㏃㏈㏔㏝Bb]", + C: "[CcÇçĆ-čᶜ℀ℂ℃℅℆ℭⅭⅽ⒞Ⓒⓒ㍶㎈㎉㎝㎠㎤㏄-㏇Cc]", + D: "[DdĎďDŽ-džDZ-dzᴰᵈḊ-ḓⅅⅆⅮⅾ⒟Ⓓⓓ㋏㍲㍷-㍹㎗㎭-㎯㏅㏈Dd]", + E: "[EeÈ-Ëè-ëĒ-ěȄ-ȇȨȩᴱᵉḘ-ḛẸ-ẽₑ℡ℯℰⅇ⒠Ⓔⓔ㉐㋍㋎Ee]", + F: "[FfᶠḞḟ℉ℱ℻⒡Ⓕⓕ㎊-㎌㎙ff-fflFf]", + G: "[GgĜ-ģǦǧǴǵᴳᵍḠḡℊ⒢Ⓖⓖ㋌㋍㎇㎍-㎏㎓㎬㏆㏉㏒㏿Gg]", + H: "[HhĤĥȞȟʰᴴḢ-ḫẖℋ-ℎ⒣Ⓗⓗ㋌㍱㎐-㎔㏊㏋㏗Hh]", + I: "[IiÌ-Ïì-ïĨ-İIJijǏǐȈ-ȋᴵᵢḬḭỈ-ịⁱℐℑℹⅈⅠ-ⅣⅥ-ⅨⅪⅫⅰ-ⅳⅵ-ⅸⅺⅻ⒤Ⓘⓘ㍺㏌㏕fiffiIi]", + J: "[JjIJ-ĵLJ-njǰʲᴶⅉ⒥ⒿⓙⱼJj]", + K: "[KkĶķǨǩᴷᵏḰ-ḵK⒦Ⓚⓚ㎄㎅㎉㎏㎑㎘㎞㎢㎦㎪㎸㎾㏀㏆㏍-㏏Kk]", + L: "[LlĹ-ŀLJ-ljˡᴸḶḷḺ-ḽℒℓ℡Ⅼⅼ⒧Ⓛⓛ㋏㎈㎉㏐-㏓㏕㏖㏿flfflLl]", + M: "[MmᴹᵐḾ-ṃ℠™ℳⅯⅿ⒨Ⓜⓜ㍷-㍹㎃㎆㎎㎒㎖㎙-㎨㎫㎳㎷㎹㎽㎿㏁㏂㏎㏐㏔-㏖㏘㏙㏞㏟Mm]", + N: "[NnÑñŃ-ʼnNJ-njǸǹᴺṄ-ṋⁿℕ№⒩Ⓝⓝ㎁㎋㎚㎱㎵㎻㏌㏑Nn]", + O: "[OoºÒ-Öò-öŌ-őƠơǑǒǪǫȌ-ȏȮȯᴼᵒỌ-ỏₒ℅№ℴ⒪Ⓞⓞ㍵㏇㏒㏖Oo]", + P: "[PpᴾᵖṔ-ṗℙ⒫Ⓟⓟ㉐㍱㍶㎀㎊㎩-㎬㎰㎴㎺㏋㏗-㏚Pp]", + Q: "[Qqℚ⒬Ⓠⓠ㏃Qq]", + R: "[RrŔ-řȐ-ȓʳᴿᵣṘ-ṛṞṟ₨ℛ-ℝ⒭Ⓡⓡ㋍㍴㎭-㎯㏚㏛Rr]", + S: "[SsŚ-šſȘșˢṠ-ṣ₨℁℠⒮Ⓢⓢ㎧㎨㎮-㎳㏛㏜stSs]", + T: "[TtŢ-ťȚțᵀᵗṪ-ṱẗ℡™⒯Ⓣⓣ㉐㋏㎔㏏ſtstTt]", + U: "[UuÙ-Üù-üŨ-ųƯưǓǔȔ-ȗᵁᵘᵤṲ-ṷỤ-ủ℆⒰Ⓤⓤ㍳㍺Uu]", + V: "[VvᵛᵥṼ-ṿⅣ-Ⅷⅳ-ⅷ⒱Ⓥⓥⱽ㋎㍵㎴-㎹㏜㏞Vv]", + W: "[WwŴŵʷᵂẀ-ẉẘ⒲Ⓦⓦ㎺-㎿㏝Ww]", + X: "[XxˣẊ-ẍₓ℻Ⅸ-Ⅻⅸ-ⅻ⒳Ⓧⓧ㏓Xx]", + Y: "[YyÝýÿŶ-ŸȲȳʸẎẏẙỲ-ỹ⒴Ⓨⓨ㏉Yy]", + Z: "[ZzŹ-žDZ-dzᶻẐ-ẕℤℨ⒵Ⓩⓩ㎐-㎔Zz]" + }; + return function hightlight(o) { + var regex; + o = _.mixin({}, defaults, o); + if (!o.node || !o.pattern) { + return; + } + o.pattern = _.isArray(o.pattern) ? o.pattern : [ o.pattern ]; + regex = getRegex(o.pattern, o.caseSensitive, o.wordsOnly, o.diacriticInsensitive); + traverse(o.node, hightlightTextNode); + function hightlightTextNode(textNode) { + var match, patternNode, wrapperNode; + if (match = regex.exec(textNode.data)) { + wrapperNode = doc.createElement(o.tagName); + o.className && (wrapperNode.className = o.className); + patternNode = textNode.splitText(match.index); + patternNode.splitText(match[0].length); + wrapperNode.appendChild(patternNode.cloneNode(true)); + textNode.parentNode.replaceChild(wrapperNode, patternNode); + } + return !!match; + } + function traverse(el, hightlightTextNode) { + var childNode, TEXT_NODE_TYPE = 3; + for (var i = 0; i < el.childNodes.length; i++) { + childNode = el.childNodes[i]; + if (childNode.nodeType === TEXT_NODE_TYPE) { + i += hightlightTextNode(childNode) ? 1 : 0; + } else { + traverse(childNode, hightlightTextNode); + } + } + } + }; + function accent_replacer(chr) { + return accented[chr.toUpperCase()] || chr; + } + function getRegex(patterns, caseSensitive, wordsOnly, diacriticInsensitive) { + var escapedPatterns = [], regexStr; + for (var i = 0, len = patterns.length; i < len; i++) { + var escapedWord = _.escapeRegExChars(patterns[i]); + if (diacriticInsensitive) { + escapedWord = escapedWord.replace(/\S/g, accent_replacer); + } + escapedPatterns.push(escapedWord); + } + regexStr = wordsOnly ? "\\b(" + escapedPatterns.join("|") + ")\\b" : "(" + escapedPatterns.join("|") + ")"; + return caseSensitive ? new RegExp(regexStr) : new RegExp(regexStr, "i"); + } + }(window.document); + var Input = function() { + "use strict"; + var specialKeyCodeMap; + specialKeyCodeMap = { + 9: "tab", + 27: "esc", + 37: "left", + 39: "right", + 13: "enter", + 38: "up", + 40: "down" + }; + function Input(o, www) { + var id; + o = o || {}; + if (!o.input) { + $.error("input is missing"); + } + www.mixin(this); + this.$hint = $(o.hint); + this.$input = $(o.input); + this.$menu = $(o.menu); + id = this.$input.attr("id") || _.guid(); + this.$menu.attr("id", id + "_listbox"); + this.$hint.attr({ + "aria-hidden": true + }); + this.$input.attr({ + "aria-owns": id + "_listbox", + role: "combobox", + "aria-autocomplete": "list", + "aria-expanded": false + }); + this.query = this.$input.val(); + this.queryWhenFocused = this.hasFocus() ? this.query : null; + this.$overflowHelper = buildOverflowHelper(this.$input); + this._checkLanguageDirection(); + if (this.$hint.length === 0) { + this.setHint = this.getHint = this.clearHint = this.clearHintIfInvalid = _.noop; + } + this.onSync("cursorchange", this._updateDescendent); + } + Input.normalizeQuery = function(str) { + return _.toStr(str).replace(/^\s*/g, "").replace(/\s{2,}/g, " "); + }; + _.mixin(Input.prototype, EventEmitter, { + _onBlur: function onBlur() { + this.resetInputValue(); + this.trigger("blurred"); + }, + _onFocus: function onFocus() { + this.queryWhenFocused = this.query; + this.trigger("focused"); + }, + _onKeydown: function onKeydown($e) { + var keyName = specialKeyCodeMap[$e.which || $e.keyCode]; + this._managePreventDefault(keyName, $e); + if (keyName && this._shouldTrigger(keyName, $e)) { + this.trigger(keyName + "Keyed", $e); + } + }, + _onInput: function onInput() { + this._setQuery(this.getInputValue()); + this.clearHintIfInvalid(); + this._checkLanguageDirection(); + }, + _managePreventDefault: function managePreventDefault(keyName, $e) { + var preventDefault; + switch (keyName) { + case "up": + case "down": + preventDefault = !withModifier($e); + break; + + default: + preventDefault = false; + } + preventDefault && $e.preventDefault(); + }, + _shouldTrigger: function shouldTrigger(keyName, $e) { + var trigger; + switch (keyName) { + case "tab": + trigger = !withModifier($e); + break; + + default: + trigger = true; + } + return trigger; + }, + _checkLanguageDirection: function checkLanguageDirection() { + var dir = (this.$input.css("direction") || "ltr").toLowerCase(); + if (this.dir !== dir) { + this.dir = dir; + this.$hint.attr("dir", dir); + this.trigger("langDirChanged", dir); + } + }, + _setQuery: function setQuery(val, silent) { + var areEquivalent, hasDifferentWhitespace; + areEquivalent = areQueriesEquivalent(val, this.query); + hasDifferentWhitespace = areEquivalent ? this.query.length !== val.length : false; + this.query = val; + if (!silent && !areEquivalent) { + this.trigger("queryChanged", this.query); + } else if (!silent && hasDifferentWhitespace) { + this.trigger("whitespaceChanged", this.query); + } + }, + _updateDescendent: function updateDescendent(event, id) { + this.$input.attr("aria-activedescendant", id); + }, + bind: function() { + var that = this, onBlur, onFocus, onKeydown, onInput; + onBlur = _.bind(this._onBlur, this); + onFocus = _.bind(this._onFocus, this); + onKeydown = _.bind(this._onKeydown, this); + onInput = _.bind(this._onInput, this); + this.$input.on("blur.tt", onBlur).on("focus.tt", onFocus).on("keydown.tt", onKeydown); + if (!_.isMsie() || _.isMsie() > 9) { + this.$input.on("input.tt", onInput); + } else { + this.$input.on("keydown.tt keypress.tt cut.tt paste.tt", function($e) { + if (specialKeyCodeMap[$e.which || $e.keyCode]) { + return; + } + _.defer(_.bind(that._onInput, that, $e)); + }); + } + return this; + }, + focus: function focus() { + this.$input.focus(); + }, + blur: function blur() { + this.$input.blur(); + }, + getLangDir: function getLangDir() { + return this.dir; + }, + getQuery: function getQuery() { + return this.query || ""; + }, + setQuery: function setQuery(val, silent) { + this.setInputValue(val); + this._setQuery(val, silent); + }, + hasQueryChangedSinceLastFocus: function hasQueryChangedSinceLastFocus() { + return this.query !== this.queryWhenFocused; + }, + getInputValue: function getInputValue() { + return this.$input.val(); + }, + setInputValue: function setInputValue(value) { + this.$input.val(value); + this.clearHintIfInvalid(); + this._checkLanguageDirection(); + }, + resetInputValue: function resetInputValue() { + this.setInputValue(this.query); + }, + getHint: function getHint() { + return this.$hint.val(); + }, + setHint: function setHint(value) { + this.$hint.val(value); + }, + clearHint: function clearHint() { + this.setHint(""); + }, + clearHintIfInvalid: function clearHintIfInvalid() { + var val, hint, valIsPrefixOfHint, isValid; + val = this.getInputValue(); + hint = this.getHint(); + valIsPrefixOfHint = val !== hint && hint.indexOf(val) === 0; + isValid = val !== "" && valIsPrefixOfHint && !this.hasOverflow(); + !isValid && this.clearHint(); + }, + hasFocus: function hasFocus() { + return this.$input.is(":focus"); + }, + hasOverflow: function hasOverflow() { + var constraint = this.$input.width() - 2; + this.$overflowHelper.text(this.getInputValue()); + return this.$overflowHelper.width() >= constraint; + }, + isCursorAtEnd: function() { + var valueLength, selectionStart, range; + valueLength = this.$input.val().length; + selectionStart = this.$input[0].selectionStart; + if (_.isNumber(selectionStart)) { + return selectionStart === valueLength; + } else if (document.selection) { + range = document.selection.createRange(); + range.moveStart("character", -valueLength); + return valueLength === range.text.length; + } + return true; + }, + destroy: function destroy() { + this.$hint.off(".tt"); + this.$input.off(".tt"); + this.$overflowHelper.remove(); + this.$hint = this.$input = this.$overflowHelper = $("
"); + }, + setAriaExpanded: function setAriaExpanded(value) { + this.$input.attr("aria-expanded", value); + } + }); + return Input; + function buildOverflowHelper($input) { + return $('').css({ + position: "absolute", + visibility: "hidden", + whiteSpace: "pre", + fontFamily: $input.css("font-family"), + fontSize: $input.css("font-size"), + fontStyle: $input.css("font-style"), + fontVariant: $input.css("font-variant"), + fontWeight: $input.css("font-weight"), + wordSpacing: $input.css("word-spacing"), + letterSpacing: $input.css("letter-spacing"), + textIndent: $input.css("text-indent"), + textRendering: $input.css("text-rendering"), + textTransform: $input.css("text-transform") + }).insertAfter($input); + } + function areQueriesEquivalent(a, b) { + return Input.normalizeQuery(a) === Input.normalizeQuery(b); + } + function withModifier($e) { + return $e.altKey || $e.ctrlKey || $e.metaKey || $e.shiftKey; + } + }(); + var Dataset = function() { + "use strict"; + var keys, nameGenerator; + keys = { + dataset: "tt-selectable-dataset", + val: "tt-selectable-display", + obj: "tt-selectable-object" + }; + nameGenerator = _.getIdGenerator(); + function Dataset(o, www) { + o = o || {}; + o.templates = o.templates || {}; + o.templates.notFound = o.templates.notFound || o.templates.empty; + if (!o.source) { + $.error("missing source"); + } + if (!o.node) { + $.error("missing node"); + } + if (o.name && !isValidName(o.name)) { + $.error("invalid dataset name: " + o.name); + } + www.mixin(this); + this.highlight = !!o.highlight; + this.name = _.toStr(o.name || nameGenerator()); + this.limit = o.limit || 5; + this.displayFn = getDisplayFn(o.display || o.displayKey); + this.templates = getTemplates(o.templates, this.displayFn); + this.source = o.source.__ttAdapter ? o.source.__ttAdapter() : o.source; + this.async = _.isUndefined(o.async) ? this.source.length > 2 : !!o.async; + this._resetLastSuggestion(); + this.$el = $(o.node).attr("role", "presentation").addClass(this.classes.dataset).addClass(this.classes.dataset + "-" + this.name); + } + Dataset.extractData = function extractData(el) { + var $el = $(el); + if ($el.data(keys.obj)) { + return { + dataset: $el.data(keys.dataset) || "", + val: $el.data(keys.val) || "", + obj: $el.data(keys.obj) || null + }; + } + return null; + }; + _.mixin(Dataset.prototype, EventEmitter, { + _overwrite: function overwrite(query, suggestions) { + suggestions = suggestions || []; + if (suggestions.length) { + this._renderSuggestions(query, suggestions); + } else if (this.async && this.templates.pending) { + this._renderPending(query); + } else if (!this.async && this.templates.notFound) { + this._renderNotFound(query); + } else { + this._empty(); + } + this.trigger("rendered", suggestions, false, this.name); + }, + _append: function append(query, suggestions) { + suggestions = suggestions || []; + if (suggestions.length && this.$lastSuggestion.length) { + this._appendSuggestions(query, suggestions); + } else if (suggestions.length) { + this._renderSuggestions(query, suggestions); + } else if (!this.$lastSuggestion.length && this.templates.notFound) { + this._renderNotFound(query); + } + this.trigger("rendered", suggestions, true, this.name); + }, + _renderSuggestions: function renderSuggestions(query, suggestions) { + var $fragment; + $fragment = this._getSuggestionsFragment(query, suggestions); + this.$lastSuggestion = $fragment.children().last(); + this.$el.html($fragment).prepend(this._getHeader(query, suggestions)).append(this._getFooter(query, suggestions)); + }, + _appendSuggestions: function appendSuggestions(query, suggestions) { + var $fragment, $lastSuggestion; + $fragment = this._getSuggestionsFragment(query, suggestions); + $lastSuggestion = $fragment.children().last(); + this.$lastSuggestion.after($fragment); + this.$lastSuggestion = $lastSuggestion; + }, + _renderPending: function renderPending(query) { + var template = this.templates.pending; + this._resetLastSuggestion(); + template && this.$el.html(template({ + query: query, + dataset: this.name + })); + }, + _renderNotFound: function renderNotFound(query) { + var template = this.templates.notFound; + this._resetLastSuggestion(); + template && this.$el.html(template({ + query: query, + dataset: this.name + })); + }, + _empty: function empty() { + this.$el.empty(); + this._resetLastSuggestion(); + }, + _getSuggestionsFragment: function getSuggestionsFragment(query, suggestions) { + var that = this, fragment; + fragment = document.createDocumentFragment(); + _.each(suggestions, function getSuggestionNode(suggestion) { + var $el, context; + context = that._injectQuery(query, suggestion); + $el = $(that.templates.suggestion(context)).data(keys.dataset, that.name).data(keys.obj, suggestion).data(keys.val, that.displayFn(suggestion)).addClass(that.classes.suggestion + " " + that.classes.selectable); + fragment.appendChild($el[0]); + }); + this.highlight && highlight({ + className: this.classes.highlight, + node: fragment, + pattern: query + }); + return $(fragment); + }, + _getFooter: function getFooter(query, suggestions) { + return this.templates.footer ? this.templates.footer({ + query: query, + suggestions: suggestions, + dataset: this.name + }) : null; + }, + _getHeader: function getHeader(query, suggestions) { + return this.templates.header ? this.templates.header({ + query: query, + suggestions: suggestions, + dataset: this.name + }) : null; + }, + _resetLastSuggestion: function resetLastSuggestion() { + this.$lastSuggestion = $(); + }, + _injectQuery: function injectQuery(query, obj) { + return _.isObject(obj) ? _.mixin({ + _query: query + }, obj) : obj; + }, + update: function update(query) { + var that = this, canceled = false, syncCalled = false, rendered = 0; + this.cancel(); + this.cancel = function cancel() { + canceled = true; + that.cancel = $.noop; + that.async && that.trigger("asyncCanceled", query, that.name); + }; + this.source(query, sync, async); + !syncCalled && sync([]); + function sync(suggestions) { + if (syncCalled) { + return; + } + syncCalled = true; + suggestions = (suggestions || []).slice(0, that.limit); + rendered = suggestions.length; + that._overwrite(query, suggestions); + if (rendered < that.limit && that.async) { + that.trigger("asyncRequested", query, that.name); + } + } + function async(suggestions) { + suggestions = suggestions || []; + if (!canceled && rendered < that.limit) { + that.cancel = $.noop; + var idx = Math.abs(rendered - that.limit); + rendered += idx; + that._append(query, suggestions.slice(0, idx)); + that.async && that.trigger("asyncReceived", query, that.name); + } + } + }, + cancel: $.noop, + clear: function clear() { + this._empty(); + this.cancel(); + this.trigger("cleared"); + }, + isEmpty: function isEmpty() { + return this.$el.is(":empty"); + }, + destroy: function destroy() { + this.$el = $("
"); + } + }); + return Dataset; + function getDisplayFn(display) { + display = display || _.stringify; + return _.isFunction(display) ? display : displayFn; + function displayFn(obj) { + return obj[display]; + } + } + function getTemplates(templates, displayFn) { + return { + notFound: templates.notFound && _.templatify(templates.notFound), + pending: templates.pending && _.templatify(templates.pending), + header: templates.header && _.templatify(templates.header), + footer: templates.footer && _.templatify(templates.footer), + suggestion: templates.suggestion ? userSuggestionTemplate : suggestionTemplate + }; + function userSuggestionTemplate(context) { + var template = templates.suggestion; + return $(template(context)).attr("id", _.guid()); + } + function suggestionTemplate(context) { + return $('
').attr("id", _.guid()).text(displayFn(context)); + } + } + function isValidName(str) { + return /^[_a-zA-Z0-9-]+$/.test(str); + } + }(); + var Menu = function() { + "use strict"; + function Menu(o, www) { + var that = this; + o = o || {}; + if (!o.node) { + $.error("node is required"); + } + www.mixin(this); + this.$node = $(o.node); + this.query = null; + this.datasets = _.map(o.datasets, initializeDataset); + function initializeDataset(oDataset) { + var node = that.$node.find(oDataset.node).first(); + oDataset.node = node.length ? node : $("
").appendTo(that.$node); + return new Dataset(oDataset, www); + } + } + _.mixin(Menu.prototype, EventEmitter, { + _onSelectableClick: function onSelectableClick($e) { + this.trigger("selectableClicked", $($e.currentTarget)); + }, + _onRendered: function onRendered(type, dataset, suggestions, async) { + this.$node.toggleClass(this.classes.empty, this._allDatasetsEmpty()); + this.trigger("datasetRendered", dataset, suggestions, async); + }, + _onCleared: function onCleared() { + this.$node.toggleClass(this.classes.empty, this._allDatasetsEmpty()); + this.trigger("datasetCleared"); + }, + _propagate: function propagate() { + this.trigger.apply(this, arguments); + }, + _allDatasetsEmpty: function allDatasetsEmpty() { + return _.every(this.datasets, _.bind(function isDatasetEmpty(dataset) { + var isEmpty = dataset.isEmpty(); + this.$node.attr("aria-expanded", !isEmpty); + return isEmpty; + }, this)); + }, + _getSelectables: function getSelectables() { + return this.$node.find(this.selectors.selectable); + }, + _removeCursor: function _removeCursor() { + var $selectable = this.getActiveSelectable(); + $selectable && $selectable.removeClass(this.classes.cursor); + }, + _ensureVisible: function ensureVisible($el) { + var elTop, elBottom, nodeScrollTop, nodeHeight; + elTop = $el.position().top; + elBottom = elTop + $el.outerHeight(true); + nodeScrollTop = this.$node.scrollTop(); + nodeHeight = this.$node.height() + parseInt(this.$node.css("paddingTop"), 10) + parseInt(this.$node.css("paddingBottom"), 10); + if (elTop < 0) { + this.$node.scrollTop(nodeScrollTop + elTop); + } else if (nodeHeight < elBottom) { + this.$node.scrollTop(nodeScrollTop + (elBottom - nodeHeight)); + } + }, + bind: function() { + var that = this, onSelectableClick; + onSelectableClick = _.bind(this._onSelectableClick, this); + this.$node.on("click.tt", this.selectors.selectable, onSelectableClick); + this.$node.on("mouseover", this.selectors.selectable, function() { + that.setCursor($(this)); + }); + this.$node.on("mouseleave", function() { + that._removeCursor(); + }); + _.each(this.datasets, function(dataset) { + dataset.onSync("asyncRequested", that._propagate, that).onSync("asyncCanceled", that._propagate, that).onSync("asyncReceived", that._propagate, that).onSync("rendered", that._onRendered, that).onSync("cleared", that._onCleared, that); + }); + return this; + }, + isOpen: function isOpen() { + return this.$node.hasClass(this.classes.open); + }, + open: function open() { + this.$node.scrollTop(0); + this.$node.addClass(this.classes.open); + }, + close: function close() { + this.$node.attr("aria-expanded", false); + this.$node.removeClass(this.classes.open); + this._removeCursor(); + }, + setLanguageDirection: function setLanguageDirection(dir) { + this.$node.attr("dir", dir); + }, + selectableRelativeToCursor: function selectableRelativeToCursor(delta) { + var $selectables, $oldCursor, oldIndex, newIndex; + $oldCursor = this.getActiveSelectable(); + $selectables = this._getSelectables(); + oldIndex = $oldCursor ? $selectables.index($oldCursor) : -1; + newIndex = oldIndex + delta; + newIndex = (newIndex + 1) % ($selectables.length + 1) - 1; + newIndex = newIndex < -1 ? $selectables.length - 1 : newIndex; + return newIndex === -1 ? null : $selectables.eq(newIndex); + }, + setCursor: function setCursor($selectable) { + this._removeCursor(); + if ($selectable = $selectable && $selectable.first()) { + $selectable.addClass(this.classes.cursor); + this._ensureVisible($selectable); + } + }, + getSelectableData: function getSelectableData($el) { + return $el && $el.length ? Dataset.extractData($el) : null; + }, + getActiveSelectable: function getActiveSelectable() { + var $selectable = this._getSelectables().filter(this.selectors.cursor).first(); + return $selectable.length ? $selectable : null; + }, + getTopSelectable: function getTopSelectable() { + var $selectable = this._getSelectables().first(); + return $selectable.length ? $selectable : null; + }, + update: function update(query) { + var isValidUpdate = query !== this.query; + if (isValidUpdate) { + this.query = query; + _.each(this.datasets, updateDataset); + } + return isValidUpdate; + function updateDataset(dataset) { + dataset.update(query); + } + }, + empty: function empty() { + _.each(this.datasets, clearDataset); + this.query = null; + this.$node.addClass(this.classes.empty); + function clearDataset(dataset) { + dataset.clear(); + } + }, + destroy: function destroy() { + this.$node.off(".tt"); + this.$node = $("
"); + _.each(this.datasets, destroyDataset); + function destroyDataset(dataset) { + dataset.destroy(); + } + } + }); + return Menu; + }(); + var Status = function() { + "use strict"; + function Status(options) { + this.$el = $("", { + role: "status", + "aria-live": "polite" + }).css({ + position: "absolute", + padding: "0", + border: "0", + height: "1px", + width: "1px", + "margin-bottom": "-1px", + "margin-right": "-1px", + overflow: "hidden", + clip: "rect(0 0 0 0)", + "white-space": "nowrap" + }); + options.$input.after(this.$el); + _.each(options.menu.datasets, _.bind(function(dataset) { + if (dataset.onSync) { + dataset.onSync("rendered", _.bind(this.update, this)); + dataset.onSync("cleared", _.bind(this.cleared, this)); + } + }, this)); + } + _.mixin(Status.prototype, { + update: function update(event, suggestions) { + var length = suggestions.length; + var words; + if (length === 1) { + words = { + result: "result", + is: "is" + }; + } else { + words = { + result: "results", + is: "are" + }; + } + this.$el.text(length + " " + words.result + " " + words.is + " available, use up and down arrow keys to navigate."); + }, + cleared: function() { + this.$el.text(""); + } + }); + return Status; + }(); + var DefaultMenu = function() { + "use strict"; + var s = Menu.prototype; + function DefaultMenu() { + Menu.apply(this, [].slice.call(arguments, 0)); + } + _.mixin(DefaultMenu.prototype, Menu.prototype, { + open: function open() { + !this._allDatasetsEmpty() && this._show(); + return s.open.apply(this, [].slice.call(arguments, 0)); + }, + close: function close() { + this._hide(); + return s.close.apply(this, [].slice.call(arguments, 0)); + }, + _onRendered: function onRendered() { + if (this._allDatasetsEmpty()) { + this._hide(); + } else { + this.isOpen() && this._show(); + } + return s._onRendered.apply(this, [].slice.call(arguments, 0)); + }, + _onCleared: function onCleared() { + if (this._allDatasetsEmpty()) { + this._hide(); + } else { + this.isOpen() && this._show(); + } + return s._onCleared.apply(this, [].slice.call(arguments, 0)); + }, + setLanguageDirection: function setLanguageDirection(dir) { + this.$node.css(dir === "ltr" ? this.css.ltr : this.css.rtl); + return s.setLanguageDirection.apply(this, [].slice.call(arguments, 0)); + }, + _hide: function hide() { + this.$node.hide(); + }, + _show: function show() { + this.$node.css("display", "block"); + } + }); + return DefaultMenu; + }(); + var Typeahead = function() { + "use strict"; + function Typeahead(o, www) { + var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged; + o = o || {}; + if (!o.input) { + $.error("missing input"); + } + if (!o.menu) { + $.error("missing menu"); + } + if (!o.eventBus) { + $.error("missing event bus"); + } + www.mixin(this); + this.eventBus = o.eventBus; + this.minLength = _.isNumber(o.minLength) ? o.minLength : 1; + this.input = o.input; + this.menu = o.menu; + this.enabled = true; + this.autoselect = !!o.autoselect; + this.active = false; + this.input.hasFocus() && this.activate(); + this.dir = this.input.getLangDir(); + this._hacks(); + this.menu.bind().onSync("selectableClicked", this._onSelectableClicked, this).onSync("asyncRequested", this._onAsyncRequested, this).onSync("asyncCanceled", this._onAsyncCanceled, this).onSync("asyncReceived", this._onAsyncReceived, this).onSync("datasetRendered", this._onDatasetRendered, this).onSync("datasetCleared", this._onDatasetCleared, this); + onFocused = c(this, "activate", "open", "_onFocused"); + onBlurred = c(this, "deactivate", "_onBlurred"); + onEnterKeyed = c(this, "isActive", "isOpen", "_onEnterKeyed"); + onTabKeyed = c(this, "isActive", "isOpen", "_onTabKeyed"); + onEscKeyed = c(this, "isActive", "_onEscKeyed"); + onUpKeyed = c(this, "isActive", "open", "_onUpKeyed"); + onDownKeyed = c(this, "isActive", "open", "_onDownKeyed"); + onLeftKeyed = c(this, "isActive", "isOpen", "_onLeftKeyed"); + onRightKeyed = c(this, "isActive", "isOpen", "_onRightKeyed"); + onQueryChanged = c(this, "_openIfActive", "_onQueryChanged"); + onWhitespaceChanged = c(this, "_openIfActive", "_onWhitespaceChanged"); + this.input.bind().onSync("focused", onFocused, this).onSync("blurred", onBlurred, this).onSync("enterKeyed", onEnterKeyed, this).onSync("tabKeyed", onTabKeyed, this).onSync("escKeyed", onEscKeyed, this).onSync("upKeyed", onUpKeyed, this).onSync("downKeyed", onDownKeyed, this).onSync("leftKeyed", onLeftKeyed, this).onSync("rightKeyed", onRightKeyed, this).onSync("queryChanged", onQueryChanged, this).onSync("whitespaceChanged", onWhitespaceChanged, this).onSync("langDirChanged", this._onLangDirChanged, this); + } + _.mixin(Typeahead.prototype, { + _hacks: function hacks() { + var $input, $menu; + $input = this.input.$input || $("
"); + $menu = this.menu.$node || $("
"); + $input.on("blur.tt", function($e) { + var active, isActive, hasActive; + active = document.activeElement; + isActive = $menu.is(active); + hasActive = $menu.has(active).length > 0; + if (_.isMsie() && (isActive || hasActive)) { + $e.preventDefault(); + $e.stopImmediatePropagation(); + _.defer(function() { + $input.focus(); + }); + } + }); + $menu.on("mousedown.tt", function($e) { + $e.preventDefault(); + }); + }, + _onSelectableClicked: function onSelectableClicked(type, $el) { + this.select($el); + }, + _onDatasetCleared: function onDatasetCleared() { + this._updateHint(); + }, + _onDatasetRendered: function onDatasetRendered(type, suggestions, async, dataset) { + this._updateHint(); + if (this.autoselect) { + var cursorClass = this.selectors.cursor.substr(1); + this.menu.$node.find(this.selectors.suggestion).first().addClass(cursorClass); + } + this.eventBus.trigger("render", suggestions, async, dataset); + }, + _onAsyncRequested: function onAsyncRequested(type, dataset, query) { + this.eventBus.trigger("asyncrequest", query, dataset); + }, + _onAsyncCanceled: function onAsyncCanceled(type, dataset, query) { + this.eventBus.trigger("asynccancel", query, dataset); + }, + _onAsyncReceived: function onAsyncReceived(type, dataset, query) { + this.eventBus.trigger("asyncreceive", query, dataset); + }, + _onFocused: function onFocused() { + this._minLengthMet() && this.menu.update(this.input.getQuery()); + }, + _onBlurred: function onBlurred() { + if (this.input.hasQueryChangedSinceLastFocus()) { + this.eventBus.trigger("change", this.input.getQuery()); + } + }, + _onEnterKeyed: function onEnterKeyed(type, $e) { + var $selectable; + if ($selectable = this.menu.getActiveSelectable()) { + if (this.select($selectable)) { + $e.preventDefault(); + $e.stopPropagation(); + } + } else if (this.autoselect) { + if (this.select(this.menu.getTopSelectable())) { + $e.preventDefault(); + $e.stopPropagation(); + } + } + }, + _onTabKeyed: function onTabKeyed(type, $e) { + var $selectable; + if ($selectable = this.menu.getActiveSelectable()) { + this.select($selectable) && $e.preventDefault(); + } else if (this.autoselect) { + if ($selectable = this.menu.getTopSelectable()) { + this.autocomplete($selectable) && $e.preventDefault(); + } + } + }, + _onEscKeyed: function onEscKeyed() { + this.close(); + }, + _onUpKeyed: function onUpKeyed() { + this.moveCursor(-1); + }, + _onDownKeyed: function onDownKeyed() { + this.moveCursor(+1); + }, + _onLeftKeyed: function onLeftKeyed() { + if (this.dir === "rtl" && this.input.isCursorAtEnd()) { + this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable()); + } + }, + _onRightKeyed: function onRightKeyed() { + if (this.dir === "ltr" && this.input.isCursorAtEnd()) { + this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable()); + } + }, + _onQueryChanged: function onQueryChanged(e, query) { + this._minLengthMet(query) ? this.menu.update(query) : this.menu.empty(); + }, + _onWhitespaceChanged: function onWhitespaceChanged() { + this._updateHint(); + }, + _onLangDirChanged: function onLangDirChanged(e, dir) { + if (this.dir !== dir) { + this.dir = dir; + this.menu.setLanguageDirection(dir); + } + }, + _openIfActive: function openIfActive() { + this.isActive() && this.open(); + }, + _minLengthMet: function minLengthMet(query) { + query = _.isString(query) ? query : this.input.getQuery() || ""; + return query.length >= this.minLength; + }, + _updateHint: function updateHint() { + var $selectable, data, val, query, escapedQuery, frontMatchRegEx, match; + $selectable = this.menu.getTopSelectable(); + data = this.menu.getSelectableData($selectable); + val = this.input.getInputValue(); + if (data && !_.isBlankString(val) && !this.input.hasOverflow()) { + query = Input.normalizeQuery(val); + escapedQuery = _.escapeRegExChars(query); + frontMatchRegEx = new RegExp("^(?:" + escapedQuery + ")(.+$)", "i"); + match = frontMatchRegEx.exec(data.val); + match && this.input.setHint(val + match[1]); + } else { + this.input.clearHint(); + } + }, + isEnabled: function isEnabled() { + return this.enabled; + }, + enable: function enable() { + this.enabled = true; + }, + disable: function disable() { + this.enabled = false; + }, + isActive: function isActive() { + return this.active; + }, + activate: function activate() { + if (this.isActive()) { + return true; + } else if (!this.isEnabled() || this.eventBus.before("active")) { + return false; + } else { + this.active = true; + this.eventBus.trigger("active"); + return true; + } + }, + deactivate: function deactivate() { + if (!this.isActive()) { + return true; + } else if (this.eventBus.before("idle")) { + return false; + } else { + this.active = false; + this.close(); + this.eventBus.trigger("idle"); + return true; + } + }, + isOpen: function isOpen() { + return this.menu.isOpen(); + }, + open: function open() { + if (!this.isOpen() && !this.eventBus.before("open")) { + this.input.setAriaExpanded(true); + this.menu.open(); + this._updateHint(); + this.eventBus.trigger("open"); + } + return this.isOpen(); + }, + close: function close() { + if (this.isOpen() && !this.eventBus.before("close")) { + this.input.setAriaExpanded(false); + this.menu.close(); + this.input.clearHint(); + this.input.resetInputValue(); + this.eventBus.trigger("close"); + } + return !this.isOpen(); + }, + setVal: function setVal(val) { + this.input.setQuery(_.toStr(val)); + }, + getVal: function getVal() { + return this.input.getQuery(); + }, + select: function select($selectable) { + var data = this.menu.getSelectableData($selectable); + if (data && !this.eventBus.before("select", data.obj, data.dataset)) { + this.input.setQuery(data.val, true); + this.eventBus.trigger("select", data.obj, data.dataset); + this.close(); + return true; + } + return false; + }, + autocomplete: function autocomplete($selectable) { + var query, data, isValid; + query = this.input.getQuery(); + data = this.menu.getSelectableData($selectable); + isValid = data && query !== data.val; + if (isValid && !this.eventBus.before("autocomplete", data.obj, data.dataset)) { + this.input.setQuery(data.val); + this.eventBus.trigger("autocomplete", data.obj, data.dataset); + return true; + } + return false; + }, + moveCursor: function moveCursor(delta) { + var query, $candidate, data, suggestion, datasetName, cancelMove, id; + query = this.input.getQuery(); + $candidate = this.menu.selectableRelativeToCursor(delta); + data = this.menu.getSelectableData($candidate); + suggestion = data ? data.obj : null; + datasetName = data ? data.dataset : null; + id = $candidate ? $candidate.attr("id") : null; + this.input.trigger("cursorchange", id); + cancelMove = this._minLengthMet() && this.menu.update(query); + if (!cancelMove && !this.eventBus.before("cursorchange", suggestion, datasetName)) { + this.menu.setCursor($candidate); + if (data) { + if (typeof data.val === "string") { + this.input.setInputValue(data.val); + } + } else { + this.input.resetInputValue(); + this._updateHint(); + } + this.eventBus.trigger("cursorchange", suggestion, datasetName); + return true; + } + return false; + }, + destroy: function destroy() { + this.input.destroy(); + this.menu.destroy(); + } + }); + return Typeahead; + function c(ctx) { + var methods = [].slice.call(arguments, 1); + return function() { + var args = [].slice.call(arguments); + _.each(methods, function(method) { + return ctx[method].apply(ctx, args); + }); + }; + } + }(); + (function() { + "use strict"; + var old, keys, methods; + old = $.fn.typeahead; + keys = { + www: "tt-www", + attrs: "tt-attrs", + typeahead: "tt-typeahead" + }; + methods = { + initialize: function initialize(o, datasets) { + var www; + datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1); + o = o || {}; + www = WWW(o.classNames); + return this.each(attach); + function attach() { + var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu, eventBus, input, menu, status, typeahead, MenuConstructor; + _.each(datasets, function(d) { + d.highlight = !!o.highlight; + }); + $input = $(this); + $wrapper = $(www.html.wrapper); + $hint = $elOrNull(o.hint); + $menu = $elOrNull(o.menu); + defaultHint = o.hint !== false && !$hint; + defaultMenu = o.menu !== false && !$menu; + defaultHint && ($hint = buildHintFromInput($input, www)); + defaultMenu && ($menu = $(www.html.menu).css(www.css.menu)); + $hint && $hint.val(""); + $input = prepInput($input, www); + if (defaultHint || defaultMenu) { + $wrapper.css(www.css.wrapper); + $input.css(defaultHint ? www.css.input : www.css.inputWithNoHint); + $input.wrap($wrapper).parent().prepend(defaultHint ? $hint : null).append(defaultMenu ? $menu : null); + } + MenuConstructor = defaultMenu ? DefaultMenu : Menu; + eventBus = new EventBus({ + el: $input + }); + input = new Input({ + hint: $hint, + input: $input, + menu: $menu + }, www); + menu = new MenuConstructor({ + node: $menu, + datasets: datasets + }, www); + status = new Status({ + $input: $input, + menu: menu + }); + typeahead = new Typeahead({ + input: input, + menu: menu, + eventBus: eventBus, + minLength: o.minLength, + autoselect: o.autoselect + }, www); + $input.data(keys.www, www); + $input.data(keys.typeahead, typeahead); + } + }, + isEnabled: function isEnabled() { + var enabled; + ttEach(this.first(), function(t) { + enabled = t.isEnabled(); + }); + return enabled; + }, + enable: function enable() { + ttEach(this, function(t) { + t.enable(); + }); + return this; + }, + disable: function disable() { + ttEach(this, function(t) { + t.disable(); + }); + return this; + }, + isActive: function isActive() { + var active; + ttEach(this.first(), function(t) { + active = t.isActive(); + }); + return active; + }, + activate: function activate() { + ttEach(this, function(t) { + t.activate(); + }); + return this; + }, + deactivate: function deactivate() { + ttEach(this, function(t) { + t.deactivate(); + }); + return this; + }, + isOpen: function isOpen() { + var open; + ttEach(this.first(), function(t) { + open = t.isOpen(); + }); + return open; + }, + open: function open() { + ttEach(this, function(t) { + t.open(); + }); + return this; + }, + close: function close() { + ttEach(this, function(t) { + t.close(); + }); + return this; + }, + select: function select(el) { + var success = false, $el = $(el); + ttEach(this.first(), function(t) { + success = t.select($el); + }); + return success; + }, + autocomplete: function autocomplete(el) { + var success = false, $el = $(el); + ttEach(this.first(), function(t) { + success = t.autocomplete($el); + }); + return success; + }, + moveCursor: function moveCursoe(delta) { + var success = false; + ttEach(this.first(), function(t) { + success = t.moveCursor(delta); + }); + return success; + }, + val: function val(newVal) { + var query; + if (!arguments.length) { + ttEach(this.first(), function(t) { + query = t.getVal(); + }); + return query; + } else { + ttEach(this, function(t) { + t.setVal(_.toStr(newVal)); + }); + return this; + } + }, + destroy: function destroy() { + ttEach(this, function(typeahead, $input) { + revert($input); + typeahead.destroy(); + }); + return this; + } + }; + $.fn.typeahead = function(method) { + if (methods[method]) { + return methods[method].apply(this, [].slice.call(arguments, 1)); + } else { + return methods.initialize.apply(this, arguments); + } + }; + $.fn.typeahead.noConflict = function noConflict() { + $.fn.typeahead = old; + return this; + }; + function ttEach($els, fn) { + $els.each(function() { + var $input = $(this), typeahead; + (typeahead = $input.data(keys.typeahead)) && fn(typeahead, $input); + }); + } + function buildHintFromInput($input, www) { + return $input.clone().addClass(www.classes.hint).removeData().css(www.css.hint).css(getBackgroundStyles($input)).prop({ + readonly: true, + required: false + }).removeAttr("id name placeholder").removeClass("required").attr({ + spellcheck: "false", + tabindex: -1 + }); + } + function prepInput($input, www) { + $input.data(keys.attrs, { + dir: $input.attr("dir"), + autocomplete: $input.attr("autocomplete"), + spellcheck: $input.attr("spellcheck"), + style: $input.attr("style") + }); + $input.addClass(www.classes.input).attr({ + spellcheck: false + }); + try { + !$input.attr("dir") && $input.attr("dir", "auto"); + } catch (e) {} + return $input; + } + function getBackgroundStyles($el) { + return { + backgroundAttachment: $el.css("background-attachment"), + backgroundClip: $el.css("background-clip"), + backgroundColor: $el.css("background-color"), + backgroundImage: $el.css("background-image"), + backgroundOrigin: $el.css("background-origin"), + backgroundPosition: $el.css("background-position"), + backgroundRepeat: $el.css("background-repeat"), + backgroundSize: $el.css("background-size") + }; + } + function revert($input) { + var www, $wrapper; + www = $input.data(keys.www); + $wrapper = $input.parent().filter(www.selectors.wrapper); + _.each($input.data(keys.attrs), function(val, key) { + _.isUndefined(val) ? $input.removeAttr(key) : $input.attr(key, val); + }); + $input.removeData(keys.typeahead).removeData(keys.www).removeData(keys.attr).removeClass(www.classes.input); + if ($wrapper.length) { + $input.detach().insertAfter($wrapper); + $wrapper.remove(); + } + } + function $elOrNull(obj) { + var isValid, $el; + isValid = _.isJQuery(obj) || _.isElement(obj); + $el = isValid ? $(obj).first() : []; + return $el.length ? $el : null; + } + })(); +}); \ No newline at end of file diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/search.json b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/search.json new file mode 100644 index 000000000..d7091f8c2 --- /dev/null +++ b/docs/5.16/docsets/GRDB.docset/Contents/Resources/Documents/search.json @@ -0,0 +1 @@ +{"Typealiases.html#/s:4GRDB16SQLiteConnectiona":{"name":"SQLiteConnection","abstract":"

A raw SQLite connection, suitable for the SQLite C API.

"},"Typealiases.html#/s:4GRDB15SQLiteStatementa":{"name":"SQLiteStatement","abstract":"

A raw SQLite statement, suitable for the SQLite C API.

"},"Typealiases.html#/s:4GRDB15SelectStatementa":{"name":"SelectStatement","abstract":"

Undocumented

"},"Typealiases.html#/s:4GRDB15UpdateStatementa":{"name":"UpdateStatement","abstract":"

Undocumented

"},"Typealiases.html#/FTS5TokenCallback":{"name":"FTS5TokenCallback","abstract":"

A low-level SQLite function that lets FTS5Tokenizer notify tokens.

"},"Typealiases.html#/FTS5WrapperTokenCallback":{"name":"FTS5WrapperTokenCallback","abstract":"

A function that lets FTS5WrapperTokenizer notify tokens.

"},"Typealiases.html#/s:4GRDB10SQLLiterala":{"name":"SQLLiteral","abstract":"

Undocumented

"},"Typealiases.html#/s:4GRDB9SQLiterala":{"name":"SQLiteral","abstract":"

Undocumented

"},"Typealiases.html#/s:4GRDB28SQLAssociativeBinaryOperatora":{"name":"SQLAssociativeBinaryOperator","abstract":"

Undocumented

"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV19requiresWriteAccessSbvp":{"name":"requiresWriteAccess","abstract":"

Default is false. Set this property to true when the observation","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV6shared2in10scheduling6extentAA06SharedbC0Cy0B0QzGAA14DatabaseReader_p_AA0bC9SchedulerCAA0hbC6ExtentOtF":{"name":"shared(in:scheduling:extent:)","abstract":"

Returns a shared value observation that shares a single underlying","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV5start2in10scheduling7onError0G6ChangeAA19DatabaseCancellable_pAA0J6Reader_p_AA0bC9SchedulerCys0H0_pcy0B0QzctF":{"name":"start(in:scheduling:onError:onChange:)","abstract":"

Starts the value observation in the provided database reader (such as","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV12handleEvents9willStart0F5Fetch0F11TrackRegion17databaseDidChange010didReceiveB00N4Fail0N6CancelACyAA0B8ReducersO5TraceVy_xGGyycSg_ARyAA08DatabaseJ0VcSgARy0B0QzcSgys5Error_pcSgARtF":{"name":"handleEvents(willStart:willFetch:willTrackRegion:databaseDidChange:didReceiveValue:didFail:didCancel:)","abstract":"

Performs the specified closures when ValueObservation events occur.

","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV5print_2toACyAA0B8ReducersO5TraceVy_xGGSS_s16TextOutputStream_pSgtF":{"name":"print(_:to:)","abstract":"

Prints log messages for all ValueObservation events.

","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV9publisher2in10schedulingAA18DatabasePublishersO0B0Vy_AIQzGAA0G6Reader_p_AA0bC9SchedulerCtF":{"name":"publisher(in:scheduling:)","abstract":"

Creates a publisher which tracks changes in database values.

","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV3mapyACyAA0B8ReducersO3MapVy_xqd__GGqd__0B0QzclF":{"name":"map(_:)","abstract":"

Returns a ValueObservation which notifies the results of calling the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE22trackingConstantRegionyACyAE5FetchVy_qd__GGqd__AA8DatabaseCKclFZ":{"name":"trackingConstantRegion(_:)","abstract":"

Creates an optimized ValueObservation that notifies the values","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE8tracking6region5fetchACyAE5FetchVy_qd__GGAA25DatabaseRegionConvertible_pd_qd__AA0J0CKctlFZ":{"name":"tracking(region:fetch:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE8tracking7regions5fetchACyAE5FetchVy_qd__GGSayAA25DatabaseRegionConvertible_pG_qd__AA0J0CKctlFZ":{"name":"tracking(regions:fetch:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE8trackingyACyAE5FetchVy_qd__GGqd__AA8DatabaseCKclFZ":{"name":"tracking(_:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE21trackingVaryingRegionyACyAE5FetchVy_qd__GGqd__AA8DatabaseCKclFZ":{"name":"trackingVaryingRegion(_:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVAASQ0B0RpzrlE16removeDuplicatesACyAA0B8ReducersO06RemoveE0Vy_xGGyF":{"name":"removeDuplicates()","abstract":"

Returns a ValueObservation which filters out consecutive equal values.

","parent_name":"ValueObservation"},"Structs/Inflections.html#/s:4GRDB11InflectionsVACycfc":{"name":"init()","abstract":"

Undocumented

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV6plural_7options_ySS_So26NSRegularExpressionOptionsVSStF":{"name":"plural(_:options:_:)","abstract":"

Appends a pluralization rule.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV8singular_7options_ySS_So26NSRegularExpressionOptionsVSStF":{"name":"singular(_:options:_:)","abstract":"

Appends a singularization rule.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV16uncountableWordsyySaySSGF":{"name":"uncountableWords(_:)","abstract":"

Appends uncountable words.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV15irregularSuffixyySS_SStF":{"name":"irregularSuffix(_:_:)","abstract":"

Appends an irregular singular/plural pair.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV9pluralizeyS2SF":{"name":"pluralize(_:)","abstract":"

Returns a pluralized string.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV11singularizeyS2SF":{"name":"singularize(_:)","abstract":"

Returns a singularized string.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV7defaultACvpZ":{"name":"default","abstract":"

The default inflections

","parent_name":"Inflections"},"Structs/PersistenceConflictPolicy.html#/s:4GRDB25PersistenceConflictPolicyV27conflictResolutionForInsertAA8DatabaseC0cF0Ovp":{"name":"conflictResolutionForInsert","abstract":"

The conflict resolution algorithm for insertions

","parent_name":"PersistenceConflictPolicy"},"Structs/PersistenceConflictPolicy.html#/s:4GRDB25PersistenceConflictPolicyV27conflictResolutionForUpdateAA8DatabaseC0cF0Ovp":{"name":"conflictResolutionForUpdate","abstract":"

The conflict resolution algorithm for updates

","parent_name":"PersistenceConflictPolicy"},"Structs/PersistenceConflictPolicy.html#/s:4GRDB25PersistenceConflictPolicyV6insert6updateAcA8DatabaseC0C10ResolutionO_AItcfc":{"name":"init(insert:update:)","abstract":"

Creates a policy

","parent_name":"PersistenceConflictPolicy"},"Structs/Table.html#/s:4GRDB5TableV9tableNameSSvp":{"name":"tableName","abstract":"

The table name

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVyACyxGSScfc":{"name":"init(_:)","abstract":"

Create a Table

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB25DatabaseRegionConvertibleP08databaseC0yAA0bC0VAA0B0CKF":{"name":"databaseRegion(_:)","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV3allAA21QueryInterfaceRequestVyxGyF":{"name":"all()","abstract":"

Creates a request for all rows of the table.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV4noneAA21QueryInterfaceRequestVyxGyF":{"name":"none()","abstract":"

Creates a request which fetches no row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6selectyAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tF":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6selectyAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pGF":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtF":{"name":"select(sql:arguments:)","abstract":"

Creates a request which selects sql.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tF":{"name":"select(literal:)","abstract":"

Creates a request which selects an SQL literal.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select_2asAA21QueryInterfaceRequestVyqd__GSayAA13SQLSelectable_pG_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select_2asAA21QueryInterfaceRequestVyqd__GAA13SQLSelectable_pd_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select3sql9arguments2asAA21QueryInterfaceRequestVyqd__GSS_AA18StatementArgumentsVqd__mtlF":{"name":"select(sql:arguments:as:)","abstract":"

Creates a request which selects sql, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select7literal2asAA21QueryInterfaceRequestVyqd__GAA3SQLV_qd__mtlF":{"name":"select(literal:as:)","abstract":"

Creates a request which selects an SQL literal, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pG_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filteryAA21QueryInterfaceRequestVyxGAA22SQLSpecificExpressible_pF":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter3keyAA21QueryInterfaceRequestVyxGqd__Sg_tAA24DatabaseValueConvertibleRd__lF":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter4keysAA21QueryInterfaceRequestVyxGqd___tSTRd__AA24DatabaseValueConvertible7ElementRpd__lF":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter3keyAA21QueryInterfaceRequestVyxGSDySSAA24DatabaseValueConvertible_pSgGSg_tF":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter4keysAA21QueryInterfaceRequestVyxGSaySDySSAA24DatabaseValueConvertible_pSgGG_tF":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtF":{"name":"filter(sql:arguments:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tF":{"name":"filter(literal:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5orderyAA21QueryInterfaceRequestVyxGAA15SQLOrderingTerm_pd_tF":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5orderyAA21QueryInterfaceRequestVyxGSayAA15SQLOrderingTerm_pGF":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV17orderByPrimaryKeyAA21QueryInterfaceRequestVyxGyF":{"name":"orderByPrimaryKey()","abstract":"

Creates a request sorted by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5order3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtF":{"name":"order(sql:arguments:)","abstract":"

Creates a request sorted according to sql.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5order7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tF":{"name":"order(literal:)","abstract":"

Creates a request sorted according to an SQL literal.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5limit_6offsetAA21QueryInterfaceRequestVyxGSi_SiSgtF":{"name":"limit(_:offset:)","abstract":"

Creates a request which fetches limit rows, starting at","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7aliasedyAA21QueryInterfaceRequestVyxGAA0B5AliasCF":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV4withyAA21QueryInterfaceRequestVyxGAA06CommonB10ExpressionVyqd__GlF":{"name":"with(_:)","abstract":"

Returns a request which embeds the common table expression.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","abstract":"

The number of rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9belongsTo_3key5usingAA07BelongsD11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAA0B6RecordRd__lF":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7hasMany_3key5usingAA03HasD11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAA0B6RecordRd__lF":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination type,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6hasOne_3key5usingAA03HasD11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAA0B6RecordRd__lF":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination type,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9belongsTo_3key5usingAA07BelongsD11AssociationVyxqd__GACyqd__G_SSSgAA10ForeignKeyVSgtlF":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7hasMany_3key5usingAA03HasD11AssociationVyxqd__GACyqd__G_SSSgAA10ForeignKeyVSgtlF":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination table,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6hasOne_3key5usingAA03HasD11AssociationVyxqd__GACyqd__G_SSSgAA10ForeignKeyVSgtlF":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination table,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV11association2to2onAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_AA14SQLExpressible_pAA0B5AliasC_AOtctlF":{"name":"association(to:on:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV11association2toAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_tlF":{"name":"association(to:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7hasMany_7through5using3keyAA03HasD18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginkL0Qyd__RszAA0J0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lF":{"name":"hasMany(_:through:using:key:)","abstract":"

Creates a “Has Many Through” association between Self and the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6hasOne_7through5using3keyAA03HasD18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginkL0Qyd__RszAA0j2ToD0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lF":{"name":"hasOne(_:through:using:key:)","abstract":"

Creates a “Has One Through” association between Self and the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9including3allAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA17AssociationToManyRd__lF":{"name":"including(all:)","abstract":"

Creates a request that prefetches an association.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9including8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"including(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9including8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"including(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7joining8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"joining(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7joining8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"joining(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated12withOptionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"annotated(withOptional:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated12withRequiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"annotated(withRequired:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGd_tF":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGSayAA20AssociationAggregateVyxGG_tF":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6havingyAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGF":{"name":"having(_:)","abstract":"

Creates a request with the provided aggregate predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteAllySiAA8DatabaseCKF":{"name":"deleteAll(_:)","abstract":"

Deletes all rows; returns the number of deleted rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6exists_3keySbAA8DatabaseC_qd__tKAA0E16ValueConvertibleRd__lF":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6exists_3keySbAA8DatabaseC_SDySSAA0E16ValueConvertible_pSgGtKF":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this unique key (primary key or any key","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteAll_4keysSiAA8DatabaseC_qd__tKSTRd__AA0F16ValueConvertible7ElementRpd__lF":{"name":"deleteAll(_:keys:)","abstract":"

Delete rows identified by their primary keys; returns the number of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteOne_3keySbAA8DatabaseC_qd__SgtKAA0F16ValueConvertibleRd__lF":{"name":"deleteOne(_:key:)","abstract":"

Delete a row, identified by its primary key; returns whether a","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteAll_4keysSiAA8DatabaseC_SaySDySSAA0F16ValueConvertible_pSgGGtKF":{"name":"deleteAll(_:keys:)","abstract":"

Delete rows identified by the provided unique keys (primary key or","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteOne_3keySbAA8DatabaseC_SDySSAA0F16ValueConvertible_pSgGtKF":{"name":"deleteOne(_:key:)","abstract":"

Delete a row, identified by a unique key (the primary key or any key","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9updateAll_10onConflict_SiAA8DatabaseC_AG0F10ResolutionOSgSayAA16ColumnAssignmentVGtKF":{"name":"updateAll(_:onConflict:_:)","abstract":"

Updates all rows; returns the number of updated rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9updateAll_10onConflict__SiAA8DatabaseC_AG0F10ResolutionOSgAA16ColumnAssignmentVALdtKF":{"name":"updateAll(_:onConflict:_:_:)","abstract":"

Updates all rows; returns the number of updated rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlEyACyAEGSScfc":{"name":"init(_:)","abstract":"

Create a Table of Row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE6filter2idAA21QueryInterfaceRequestVyxGAG_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__7ElementQyd__AGRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE06selectG0AA21QueryInterfaceRequestVyAGGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE6filter2idAA21QueryInterfaceRequestVyxGAK_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__AaH7ElementRpd__AkRRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE06selectF0AA21QueryInterfaceRequestVyAKGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzlE11fetchCursoryAA0dF0CyxGAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all records fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzlE8fetchAllySayxGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of all records fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzlE8fetchOneyxSgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first found record.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzSHRzlE8fetchSetyShyxGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of all records fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE11fetchCursoryAA0cE0CAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all rows fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE8fetchAllySayAEGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of all rows fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE8fetchOneyAESgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first found row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE8fetchSetyShyAEGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of all rows fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzlE11fetchCursoryAA0cdG0CyxGAA0C0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzlE8fetchAllySayxGAA0C0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzlE8fetchOneyxSgAA0C0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzSHRzlE8fetchSetyShyxGAA0C0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzlE11fetchCursoryAA08NullableefJ0CyAGGAA0E0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzlE8fetchAllySayAGSgGAA0E0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzlE8fetchOneyAGSgAA0E0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzSHAGRQlE8fetchSetyShyAGSgGAA0E0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzlE11fetchCursoryAA04FastcdI0CyxGAA0C0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzlE8fetchAllySayxGAA0C0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzlE8fetchOneyxSgAA0C0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzSHRzlE8fetchSetyShyxGAA0C0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQlE11fetchCursoryAA012FastNullableefL0CyAGGAA0E0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQlE8fetchAllySayAGSgGAA0E0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQlE8fetchOneyAGSgAA0E0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQSHAGRQlE8fetchSetyShyAGSgGAA0E0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE6exists_2idSbAA0D0C_AGtKF":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE6exists_2idSbAA0G0C_AKtKF":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE9deleteAll_3idsSiAA0D0C_qd__tKSlRd__7ElementQyd__AGRSlF":{"name":"deleteAll(_:ids:)","abstract":"

Delete rows identified by their primary keys; returns the number of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE9deleteOne_2idSbAA0D0C_AGtKF":{"name":"deleteOne(_:id:)","abstract":"

Delete a row, identified by its primary key; returns whether a","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE9deleteAll_3idsSiAA0G0C_qd__tKSlRd__AaH7ElementRpd__AkQRSlF":{"name":"deleteAll(_:ids:)","abstract":"

Delete rows identified by their primary keys; returns the number of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE9deleteOne_2idSbAA0G0C_AKtKF":{"name":"deleteOne(_:id:)","abstract":"

Delete a row, identified by its primary key; returns whether a","parent_name":"Table"},"Structs/SQLSubquery.html#/s:4GRDB11SQLSubqueryV11sqlSubqueryACvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"SQLSubquery"},"Structs/AllColumns.html#/s:4GRDB10AllColumnsVACycfc":{"name":"init()","abstract":"

The * selection.

","parent_name":"AllColumns"},"Structs/AllColumns.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"AllColumns"},"Structs/SQLSelection.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"SQLSelection"},"Structs/PersistenceContainer.html#/s:4GRDB20PersistenceContainerVyAA24DatabaseValueConvertible_pSgSScip":{"name":"subscript(_:)","abstract":"

Accesses the value associated with the given column.

","parent_name":"PersistenceContainer"},"Structs/PersistenceContainer.html#/s:4GRDB20PersistenceContainerVyAA24DatabaseValueConvertible_pSgxcAA16ColumnExpressionRzluip":{"name":"subscript(_:)","abstract":"

Accesses the value associated with the given column.

","parent_name":"PersistenceContainer"},"Structs/SQLOrdering.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","parent_name":"SQLOrdering"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV3addAEvpZ":{"name":"add","abstract":"

The + binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV8multiplyAEvpZ":{"name":"multiply","abstract":"

The * binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV3andAEvpZ":{"name":"and","abstract":"

The AND binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV2orAEvpZ":{"name":"or","abstract":"

The OR binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV6concatAEvpZ":{"name":"concat","abstract":"

The || string concatenation operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html":{"name":"AssociativeBinaryOperator","abstract":"

AssociativeBinaryOperator is an associative binary operator,","parent_name":"SQLExpression"},"Structs/SQLExpression.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"SQLExpression"},"Structs/Column.html#/s:4GRDB6ColumnV5rowIDACvpZ":{"name":"rowID","abstract":"

The hidden rowID column

","parent_name":"Column"},"Structs/Column.html#/s:4GRDB6ColumnV4nameSSvp":{"name":"name","abstract":"

The name of the column

","parent_name":"Column"},"Structs/Column.html#/s:4GRDB6ColumnVyACSScfc":{"name":"init(_:)","abstract":"

Creates a column given its name.

","parent_name":"Column"},"Structs/Column.html#/s:4GRDB6ColumnVyACs9CodingKey_pcfc":{"name":"init(_:)","abstract":"

Creates a column given a CodingKey.

","parent_name":"Column"},"Structs/Column.html#/s:SQ2eeoiySbx_xtFZ":{"name":"==(_:_:)","parent_name":"Column"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6selectyACyxGSayAA13SQLSelectable_pGAA8DatabaseCKcF":{"name":"select(_:)","abstract":"

Creates a request which selects selection promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select_2asACyqd__GSayAA13SQLSelectable_pG_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select_2asACyqd__GAA13SQLSelectable_pd_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select3sql9arguments2asACyqd__GSS_AA18StatementArgumentsVqd__mtlF":{"name":"select(sql:arguments:as:)","abstract":"

Creates a request which selects sql, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select7literal2asACyqd__GAA3SQLV_qd__mtlF":{"name":"select(literal:as:)","abstract":"

Creates a request which selects an SQL literal, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9annotated4withACyxGSayAA13SQLSelectable_pGAA8DatabaseCKc_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6filteryACyxGAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV5orderyACyxGSayAA15SQLOrderingTerm_pGAA8DatabaseCKcF":{"name":"order(_:)","abstract":"

Creates a request with the provided orderings promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV8reversedACyxGyF":{"name":"reversed()","abstract":"

Creates a request that reverses applied orderings.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9unorderedACyxGyF":{"name":"unordered()","abstract":"

Creates a request without any ordering.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV5groupyACyxGSayAA14SQLExpressible_pGAA8DatabaseCKcF":{"name":"group(_:)","abstract":"

Creates a request grouped according to expressions promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6havingyACyxGAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"having(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV7aliasedyACyxGAA10TableAliasCF":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB16DerivableRequestP8distinctxyF":{"name":"distinct()","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV5limit_6offsetACyxGSi_SiSgtF":{"name":"limit(_:offset:)","abstract":"

Creates a request which fetches limit rows, starting at offset.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB16DerivableRequestP4withyxAA21CommonTableExpressionVyqd__GlF":{"name":"with(_:)","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV02asD02ofACyqd__Gqd__m_tlF":{"name":"asRequest(of:)","abstract":"

Creates a request bound to type RowDecoder.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV7isEmptyySbAA8DatabaseCKF":{"name":"isEmpty(_:)","abstract":"

Returns true if the request matches no row in the database.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9deleteAllySiAA8DatabaseCKF":{"name":"deleteAll(_:)","abstract":"

Deletes matching rows; returns the number of deleted rows.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9updateAll_10onConflict_SiAA8DatabaseC_AG0H10ResolutionOSgSayAA16ColumnAssignmentVGtKF":{"name":"updateAll(_:onConflict:_:)","abstract":"

Updates matching rows; returns the number of updated rows.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9updateAll_10onConflict__SiAA8DatabaseC_AG0H10ResolutionOSgAA16ColumnAssignmentVALdtKF":{"name":"updateAll(_:onConflict:_:_:)","abstract":"

Updates matching rows; returns the number of updated rows.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE06selectI0ACyAGGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE06selectH0ACyAKGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"QueryInterfaceRequest"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9tableNameSSvp":{"name":"tableName","abstract":"

The table name of the common table expression.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9recursive5named7columns7requestACyxGSb_SSSaySSGSgqd__tcAA15SQLSubqueryableRd__lufc":{"name":"init(recursive:named:columns:request:)","abstract":"

Creates a common table expression from a request.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9recursive5named7columns3sql9argumentsACyxGSb_SSSaySSGSgSSAA18StatementArgumentsVtcfc":{"name":"init(recursive:named:columns:sql:arguments:)","abstract":"

Creates a common table expression from an SQL string and","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9recursive5named7columns7literalACyxGSb_SSSaySSGSgAA3SQLVtcfc":{"name":"init(recursive:named:columns:literal:)","abstract":"

Creates a common table expression from an SQL literal.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV3allAA21QueryInterfaceRequestVyxGyF":{"name":"all()","abstract":"

Creates a request for all rows of the common table expression.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV8containsyAA13SQLExpressionVAA14SQLExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2to2onAA15JoinAssociationVyxqd__GACyqd__G_AA14SQLExpressible_pAA0C5AliasC_AMtctlF":{"name":"association(to:on:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2toAA15JoinAssociationVyxqd__GACyqd__G_tlF":{"name":"association(to:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2to2onAA15JoinAssociationVyxqd__Gqd__m_AA14SQLExpressible_pAA0C5AliasC_ALtctAA0C6RecordRd__lF":{"name":"association(to:on:)","abstract":"

Creates an association to a table record that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2toAA15JoinAssociationVyxqd__Gqd__m_tAA0C6RecordRd__lF":{"name":"association(to:)","abstract":"

Creates an association to a table record that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2to2onAA15JoinAssociationVyxqd__GAA0C0Vyqd__G_AA14SQLExpressible_pAA0C5AliasC_AOtctlF":{"name":"association(to:on:)","abstract":"

Creates an association to a table that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2toAA15JoinAssociationVyxqd__GAA0C0Vyqd__G_tlF":{"name":"association(to:)","abstract":"

Creates an association to a table that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionVA2A3RowCRszlE9recursive5named7columns7requestACyAEGSb_SSSaySSGSgqd__tcAA15SQLSubqueryableRd__lufc":{"name":"init(recursive:named:columns:request:)","abstract":"

Creates a common table expression from a request.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionVA2A3RowCRszlE9recursive5named7columns3sql9argumentsACyAEGSb_SSSaySSGSgSSAA18StatementArgumentsVtcfc":{"name":"init(recursive:named:columns:sql:arguments:)","abstract":"

Creates a common table expression from an SQL string and","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionVA2A3RowCRszlE9recursive5named7columns7literalACyAEGSb_SSSaySSGSgAA3SQLVtcfc":{"name":"init(recursive:named:columns:literal:)","abstract":"

Creates a common table expression from an SQL literal.

","parent_name":"CommonTableExpression"},"Structs/AssociationAggregate.html#/s:4GRDB20AssociationAggregateV6forKeyyACyxGSSF":{"name":"forKey(_:)","abstract":"

Returns an aggregate that is selected in a column with the given name.

","parent_name":"AssociationAggregate"},"Structs/AssociationAggregate.html#/s:4GRDB20AssociationAggregateV6forKeyyACyxGs06CodingE0_pF":{"name":"forKey(_:)","abstract":"

Returns an aggregate that is selected in a column named like the given","parent_name":"AssociationAggregate"},"Structs/ForeignKey.html#/s:4GRDB10ForeignKeyV_2toACSaySSG_AESgtcfc":{"name":"init(_:to:)","abstract":"

Creates a ForeignKey intended to define a record association.

","parent_name":"ForeignKey"},"Structs/ForeignKey.html#/s:4GRDB10ForeignKeyV_2toACSayAA16ColumnExpression_pG_AFSgtcfc":{"name":"init(_:to:)","abstract":"

Creates a ForeignKey intended to define a record association.

","parent_name":"ForeignKey"},"Structs/DatabaseMigrator/ForeignKeyChecks.html#/s:4GRDB16DatabaseMigratorV16ForeignKeyChecksO8deferredyA2EmF":{"name":"deferred","abstract":"

The migration runs with disabled foreign keys, until foreign keys","parent_name":"ForeignKeyChecks"},"Structs/DatabaseMigrator/ForeignKeyChecks.html#/s:4GRDB16DatabaseMigratorV16ForeignKeyChecksO9immediateyA2EmF":{"name":"immediate","abstract":"

The migration runs for foreign keys on.

","parent_name":"ForeignKeyChecks"},"Structs/DatabaseMigrator/ForeignKeyChecks.html":{"name":"ForeignKeyChecks","abstract":"

Controls how migrations handle foreign keys constraints.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV05eraseB14OnSchemaChangeSbvp":{"name":"eraseDatabaseOnSchemaChange","abstract":"

When the eraseDatabaseOnSchemaChange flag is true, the migrator will","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorVACycfc":{"name":"init()","abstract":"

A new migrator.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV33disablingDeferredForeignKeyChecksACyF":{"name":"disablingDeferredForeignKeyChecks()","abstract":"

Returns a migrator that will not perform deferred foreign key checks in","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV17registerMigration_16foreignKeyChecks7migrateySS_AC07ForeigngH0OyAA0B0CKctF":{"name":"registerMigration(_:foreignKeyChecks:migrate:)","abstract":"

Registers a migration.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV7migrateyyAA0B6Writer_pKF":{"name":"migrate(_:)","abstract":"

Iterate migrations in the same order as they were registered. If a","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV7migrate_4upToyAA0B6Writer_p_SStKF":{"name":"migrate(_:upTo:)","abstract":"

Iterate migrations in the same order as they were registered, up to the","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV12asyncMigrate_10completionyAA0B6Writer_p_yAA0B0C_s5Error_pSgtctF":{"name":"asyncMigrate(_:completion:)","abstract":"

Iterate migrations in the same order as they were registered. If a","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV10migrationsSaySSGvp":{"name":"migrations","abstract":"

The list of registered migration identifiers, in the same order as they","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV17appliedMigrationsySaySSGAA0B0CKF":{"name":"appliedMigrations(_:)","abstract":"

Returns the identifiers of registered and applied migrations, in the","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV18appliedIdentifiersyShySSGAA0B0CKF":{"name":"appliedIdentifiers(_:)","abstract":"

Returns the applied migration identifiers, even unregistered ones.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV19completedMigrationsySaySSGAA0B0CKF":{"name":"completedMigrations(_:)","abstract":"

Returns the identifiers of completed migrations, of which all previous","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV22hasCompletedMigrationsySbAA0B0CKF":{"name":"hasCompletedMigrations(_:)","abstract":"

Returns true if all migrations are applied.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV17hasBeenSupersededySbAA0B0CKF":{"name":"hasBeenSuperseded(_:)","abstract":"

Returns whether database contains unknown migration","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV16migratePublisheryAA0B10PublishersO7MigrateVAA0B6Writer_pF":{"name":"migratePublisher(_:)","abstract":"

Returns a Publisher that asynchronously migrates a database.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV16migratePublisher_9receiveOnAA0B10PublishersO7MigrateVAA0B6Writer_p_xt7Combine9SchedulerRzlF":{"name":"migratePublisher(_:receiveOn:)","abstract":"

Returns a Publisher that asynchronously migrates a database.

","parent_name":"DatabaseMigrator"},"Structs/FTS5TokenFlags.html#/rawValue":{"name":"rawValue","parent_name":"FTS5TokenFlags"},"Structs/FTS5TokenFlags.html#/init(rawValue:)":{"name":"init(rawValue:)","parent_name":"FTS5TokenFlags"},"Structs/FTS5TokenFlags.html#/colocated":{"name":"colocated","abstract":"

FTS5_TOKEN_COLOCATED

","parent_name":"FTS5TokenFlags"},"Structs/FTS5TokenizerDescriptor.html#/components":{"name":"components","abstract":"

The tokenizer components

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/init(components:)":{"name":"init(components:)","abstract":"

Creates an FTS5 tokenizer descriptor.

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/ascii(separators:tokenCharacters:)":{"name":"ascii(separators:tokenCharacters:)","abstract":"

The “ascii” tokenizer

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/porter(wrapping:)":{"name":"porter(wrapping:)","abstract":"

See https://www.sqlite.org/fts5.html#porter_tokenizer

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/unicode61(diacritics:separators:tokenCharacters:)":{"name":"unicode61(diacritics:separators:tokenCharacters:)","abstract":"

An “unicode61” tokenizer

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5Tokenization.html#/rawValue":{"name":"rawValue","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/init(rawValue:)":{"name":"init(rawValue:)","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/query":{"name":"query","abstract":"

FTS5_TOKENIZE_QUERY

","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/prefix":{"name":"prefix","abstract":"

FTS5_TOKENIZE_PREFIX

","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/document":{"name":"document","abstract":"

FTS5_TOKENIZE_DOCUMENT

","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/aux":{"name":"aux","abstract":"

FTS5_TOKENIZE_AUX

","parent_name":"FTS5Tokenization"},"Structs/FTS5Pattern.html#/rawPattern":{"name":"rawPattern","abstract":"

The raw pattern string. Guaranteed to be a valid FTS5 pattern.

","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingAnyTokenIn:)":{"name":"init(matchingAnyTokenIn:)","abstract":"

Creates a pattern that matches any token found in the input string;","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingAllTokensIn:)":{"name":"init(matchingAllTokensIn:)","abstract":"

Creates a pattern that matches all tokens found in the input string;","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingAllPrefixesIn:)":{"name":"init(matchingAllPrefixesIn:)","abstract":"

Creates a pattern that matches all token prefixes found in the input","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingPhrase:)":{"name":"init(matchingPhrase:)","abstract":"

Creates a pattern that matches a contiguous string; returns nil if no","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingPrefixPhrase:)":{"name":"init(matchingPrefixPhrase:)","abstract":"

Creates a pattern that matches the prefix of an indexed document;","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/databaseValue":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/fromDatabaseValue(_:)":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an FTS5Pattern initialized from dbValue, if it","parent_name":"FTS5Pattern"},"Structs/FTS5/Diacritics.html#/keep":{"name":"keep","abstract":"

Do not remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS5/Diacritics.html#/removeLegacy":{"name":"removeLegacy","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS5/Diacritics.html#/remove":{"name":"remove","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS5/Diacritics.html":{"name":"Diacritics","abstract":"

Options for Latin script characters. Matches the raw “remove_diacritics”","parent_name":"FTS5"},"Structs/FTS5.html#/init()":{"name":"init()","abstract":"

Creates a FTS5 module suitable for the Database","parent_name":"FTS5"},"Structs/FTS5.html#/moduleName":{"name":"moduleName","abstract":"

The virtual table module name

","parent_name":"FTS5"},"Structs/FTS5.html#/makeTableDefinition()":{"name":"makeTableDefinition()","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS5"},"Structs/FTS5.html#/makeTableDefinition(configuration:)":{"name":"makeTableDefinition(configuration:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS5"},"Structs/FTS5.html#/moduleArguments(for:in:)":{"name":"moduleArguments(for:in:)","abstract":"

Don’t use this method.

","parent_name":"FTS5"},"Structs/FTS5.html#/database(_:didCreate:using:)":{"name":"database(_:didCreate:using:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS5"},"Structs/FTS4.html#/s:4GRDB4FTS4VACycfc":{"name":"init()","abstract":"

Creates a FTS4 module suitable for the Database","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V10moduleNameSSvp":{"name":"moduleName","abstract":"

The virtual table module name

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V19makeTableDefinitionAA0bdE0CyF":{"name":"makeTableDefinition()","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V19makeTableDefinition13configurationAA0bdE0CAA07VirtualD13ConfigurationV_tF":{"name":"makeTableDefinition(configuration:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V15moduleArguments3for2inSaySSGAA0B15TableDefinitionC_AA8DatabaseCtF":{"name":"moduleArguments(for:in:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V8database_9didCreate5usingyAA8DatabaseC_SSAA0B15TableDefinitionCtKF":{"name":"database(_:didCreate:using:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS3TokenizerDescriptor.html#/s:4GRDB23FTS3TokenizerDescriptorV6simpleACvpZ":{"name":"simple","abstract":"

The “simple” tokenizer.

","parent_name":"FTS3TokenizerDescriptor"},"Structs/FTS3TokenizerDescriptor.html#/s:4GRDB23FTS3TokenizerDescriptorV6porterACvpZ":{"name":"porter","abstract":"

The “porter” tokenizer.

","parent_name":"FTS3TokenizerDescriptor"},"Structs/FTS3TokenizerDescriptor.html#/s:4GRDB23FTS3TokenizerDescriptorV9unicode6110diacritics10separators15tokenCharactersAcA0B0V10DiacriticsO_ShySJGALtFZ":{"name":"unicode61(diacritics:separators:tokenCharacters:)","abstract":"

The “unicode61” tokenizer.

","parent_name":"FTS3TokenizerDescriptor"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV03rawC0SSvp":{"name":"rawPattern","abstract":"

The raw pattern string. Guaranteed to be a valid FTS3/4 pattern.

","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV03rawC0ACSS_tKcfc":{"name":"init(rawPattern:)","abstract":"

Creates a pattern from a raw pattern string; throws DatabaseError on","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV18matchingAnyTokenInACSgSS_tcfc":{"name":"init(matchingAnyTokenIn:)","abstract":"

Creates a pattern that matches any token found in the input string;","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV19matchingAllTokensInACSgSS_tcfc":{"name":"init(matchingAllTokensIn:)","abstract":"

Creates a pattern that matches all tokens found in the input string;","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV21matchingAllPrefixesInACSgSS_tcfc":{"name":"init(matchingAllPrefixesIn:)","abstract":"

Creates a pattern that matches all token prefixes found in the input","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV14matchingPhraseACSgSS_tcfc":{"name":"init(matchingPhrase:)","abstract":"

Creates a pattern that matches a contiguous string; returns nil if no","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV13databaseValueAA08DatabaseE0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV17fromDatabaseValueyACSgAA0eF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an FTS3Pattern initialized from dbValue, if it contains","parent_name":"FTS3Pattern"},"Structs/FTS3/Diacritics.html#/s:4GRDB4FTS3V10DiacriticsO4keepyA2EmF":{"name":"keep","abstract":"

Do not remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html#/s:4GRDB4FTS3V10DiacriticsO12removeLegacyyA2EmF":{"name":"removeLegacy","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html#/remove":{"name":"remove","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html#/s:4GRDB4FTS3V10DiacriticsO6removeyA2EmF":{"name":"remove","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html":{"name":"Diacritics","abstract":"

Options for Latin script characters. Matches the raw “remove_diacritics”","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3VACycfc":{"name":"init()","abstract":"

Creates a FTS3 module suitable for the Database","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V8tokenize_13withTokenizerSaySSGSS_AA0bE10DescriptorVtFZ":{"name":"tokenize(_:withTokenizer:)","abstract":"

Returns an array of tokens found in the string argument.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V10moduleNameSSvp":{"name":"moduleName","abstract":"

The virtual table module name

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V19makeTableDefinitionAA0bdE0CyF":{"name":"makeTableDefinition()","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V19makeTableDefinition13configurationAA0bdE0CAA07VirtualD13ConfigurationV_tF":{"name":"makeTableDefinition(configuration:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V15moduleArguments3for2inSaySSGAA0B15TableDefinitionC_AA8DatabaseCtF":{"name":"moduleArguments(for:in:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V8database_9didCreate5usingyAA8DatabaseC_SSAA0B15TableDefinitionCtF":{"name":"database(_:didCreate:using:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/DatabasePreUpdateEvent/Kind.html#/insert":{"name":"insert","abstract":"

SQLITE_INSERT

","parent_name":"Kind"},"Structs/DatabasePreUpdateEvent/Kind.html#/delete":{"name":"delete","abstract":"

SQLITE_DELETE

","parent_name":"Kind"},"Structs/DatabasePreUpdateEvent/Kind.html#/update":{"name":"update","abstract":"

SQLITE_UPDATE

","parent_name":"Kind"},"Structs/DatabasePreUpdateEvent/Kind.html":{"name":"Kind","abstract":"

An event kind

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/kind":{"name":"kind","abstract":"

The event kind

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/databaseName":{"name":"databaseName","abstract":"

The database name

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/tableName":{"name":"tableName","abstract":"

The table name

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/count":{"name":"count","abstract":"

The number of columns in the row that is being inserted, updated, or deleted.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/depth":{"name":"depth","abstract":"

1 for inserts, updates, or deletes invoked by top-level triggers;","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/initialRowID":{"name":"initialRowID","abstract":"

The initial rowID of the row being changed for .Update and .Delete changes,","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/finalRowID":{"name":"finalRowID","abstract":"

The final rowID of the row being changed for .Update and .Insert changes,","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/initialDatabaseValues":{"name":"initialDatabaseValues","abstract":"

The initial database values in the row.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/initialDatabaseValue(atIndex:)":{"name":"initialDatabaseValue(atIndex:)","abstract":"

Returns the initial DatabaseValue at given index.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/finalDatabaseValues":{"name":"finalDatabaseValues","abstract":"

The final database values in the row.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/finalDatabaseValue(atIndex:)":{"name":"finalDatabaseValue(atIndex:)","abstract":"

Returns the final DatabaseValue at given index.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/copy()":{"name":"copy()","abstract":"

Returns an event that can be stored:

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabaseEvent/Kind.html#/s:4GRDB13DatabaseEventV4KindO6insertyA2EmF":{"name":"insert","abstract":"

SQLITE_INSERT

","parent_name":"Kind"},"Structs/DatabaseEvent/Kind.html#/s:4GRDB13DatabaseEventV4KindO6deleteyA2EmF":{"name":"delete","abstract":"

SQLITE_DELETE

","parent_name":"Kind"},"Structs/DatabaseEvent/Kind.html#/s:4GRDB13DatabaseEventV4KindO6updateyA2EmF":{"name":"update","abstract":"

SQLITE_UPDATE

","parent_name":"Kind"},"Structs/DatabaseEvent/Kind.html":{"name":"Kind","abstract":"

An event kind

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV4kindAC4KindOvp":{"name":"kind","abstract":"

The event kind

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV12databaseNameSSvp":{"name":"databaseName","abstract":"

The database name

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV9tableNameSSvp":{"name":"tableName","abstract":"

The table name

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV5rowIDs5Int64Vvp":{"name":"rowID","abstract":"

The rowID of the changed row.

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV4copyACyF":{"name":"copy()","abstract":"

Returns an event that can be stored:

","parent_name":"DatabaseEvent"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO3YMDyA2EmF":{"name":"YMD","abstract":"

The format “yyyy-MM-dd”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO6YMD_HMyA2EmF":{"name":"YMD_HM","abstract":"

The format “yyyy-MM-dd HH:mm”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO7YMD_HMSyA2EmF":{"name":"YMD_HMS","abstract":"

The format “yyyy-MM-dd HH:mm:ss”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO8YMD_HMSSyA2EmF":{"name":"YMD_HMSS","abstract":"

The format “yyyy-MM-dd HH:mm:ss.SSS”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO2HMyA2EmF":{"name":"HM","abstract":"

The format “HH:mm”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO3HMSyA2EmF":{"name":"HMS","abstract":"

The format “HH:mm:ss”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO4HMSSyA2EmF":{"name":"HMSS","abstract":"

The format “HH:mm:ss.SSS”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html":{"name":"Format","abstract":"

The available formats for reading and storing date components.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV04dateD010Foundation0cD0Vvp":{"name":"dateComponents","abstract":"

The date components

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV6formatAC6FormatOvp":{"name":"format","abstract":"

The database format

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV_6formatAC10Foundation0cD0V_AC6FormatOtcfc":{"name":"init(_:format:)","abstract":"

Creates a DatabaseDateComponents from a DateComponents and a format.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV15sqliteStatement5indexACSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV13databaseValueAA0bF0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV04fromB5ValueyACSgAA0bF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a DatabaseDateComponents if dbValue contains a","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV4fromACs7Decoder_p_tKcfc":{"name":"init(from:)","abstract":"

Creates a new instance by decoding from the given decoder.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV6encode2toys7Encoder_p_tKF":{"name":"encode(to:)","abstract":"

Encodes this value into the given encoder.

","parent_name":"DatabaseDateComponents"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV7isEmptySbvp":{"name":"isEmpty","abstract":"

Undocumented

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVACycfc":{"name":"init()","abstract":"

Creates empty StatementArguments.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACxcSTRzAA24DatabaseValueConvertible_pSg7ElementRtzlufc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of optional values.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACxcSTRzAA24DatabaseValueConvertible7ElementRpzlufc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of optional values.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACSgSayypGcfc":{"name":"init(_:)","abstract":"

Creates statement arguments from any array. The result is nil unless all","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACSDySSAA24DatabaseValueConvertible_pSgGcfc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of (key, value) dictionary,","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACxcSTRzSS_AA24DatabaseValueConvertible_pSgt7ElementRtzlufc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of (key, value) pairs, such","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACSgSDys11AnyHashableVypGcfc":{"name":"init(_:)","abstract":"

Creates statement arguments from [AnyHashable: Any].

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV6append10contentsOfSDySSAA13DatabaseValueVGAC_tF":{"name":"append(contentsOf:)","abstract":"

Extends statement arguments with other arguments.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV1poiyA2C_ACtFZ":{"name":"+(_:_:)","abstract":"

Creates a new StatementArguments by extending the left-hand size","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV2apoiyA2C_ACtFZ":{"name":"&+(_:_:)","abstract":"

Creates a new StatementArguments by extending the left-hand size","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV2peoiyyACz_ACtFZ":{"name":"+=(_:_:)","abstract":"

Extends the left-hand size arguments with the right-hand side arguments.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV12arrayLiteralAcA24DatabaseValueConvertible_pSgd_tcfc":{"name":"init(arrayLiteral:)","abstract":"

Returns a StatementArguments from an array literal:

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV17dictionaryLiteralACSS_AA24DatabaseValueConvertible_pSgtd_tcfc":{"name":"init(dictionaryLiteral:)","abstract":"

Returns a StatementArguments from a dictionary literal:

","parent_name":"StatementArguments"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV7adapterAA10RowAdapter_pSgvp":{"name":"adapter","abstract":"

The request adapter

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV3sql9arguments7adapter6cachedACyxGSS_AA18StatementArgumentsVAA10RowAdapter_pSgSbtcfc":{"name":"init(sql:arguments:adapter:cached:)","abstract":"

Creates a request from an SQL string, optional arguments, and","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV7literal7adapter6cachedACyxGAA3SQLV_AA10RowAdapter_pSgSbtcfc":{"name":"init(literal:adapter:cached:)","abstract":"

Creates a request from an SQL literal, and optional row adapter.

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV20unicodeScalarLiteralACyxGSS_tcfc":{"name":"init(unicodeScalarLiteral:)","abstract":"

:nodoc

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestVA2A3RowCRszlE3sql9arguments7adapter6cachedACyAEGSS_AA18StatementArgumentsVAA0C7Adapter_pSgSbtcfc":{"name":"init(sql:arguments:adapter:cached:)","abstract":"

Creates a request from an SQL string, optional arguments, and","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestVA2A3RowCRszlE7literal7adapter6cachedACyAEGAA3SQLV_AA0C7Adapter_pSgSbtcfc":{"name":"init(literal:adapter:cached:)","abstract":"

Creates a request from an SQL literal, and optional row adapter.

","parent_name":"SQLRequest"},"Structs/SQL.html#/s:4GRDB3SQLV3sql9argumentsACSS_AA18StatementArgumentsVtcfc":{"name":"init(sql:arguments:)","abstract":"

Creates an SQL literal from a plain SQL string, and","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLVyAcA22SQLSpecificExpressible_pcfc":{"name":"init(_:)","abstract":"

Creates an SQL literal from an SQL expression.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV7isEmptySbvp":{"name":"isEmpty","abstract":"

Returns true if this literal generates an empty SQL string

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV5buildySS3sql_AA18StatementArgumentsV9argumentstAA8DatabaseCKF":{"name":"build(_:)","abstract":"

Turn a SQL literal into raw SQL and arguments.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV1poiyA2C_ACtFZ":{"name":"+(_:_:)","abstract":"

Returns the SQL literal produced by the concatenation of two literals.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV2peoiyyACz_ACtFZ":{"name":"+=(_:_:)","abstract":"

Appends an SQL literal to the receiver.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV6append7literalyAC_tF":{"name":"append(literal:)","abstract":"

Appends an SQL literal to the receiver.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV6append3sql9argumentsySS_AA18StatementArgumentsVtF":{"name":"append(sql:arguments:)","abstract":"

Appends a plain SQL string to the receiver, and eventual arguments.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","abstract":"

Creates a literal SQL expression.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV20unicodeScalarLiteralACSS_tcfc":{"name":"init(unicodeScalarLiteral:)","abstract":"

:nodoc

","parent_name":"SQL"},"Structs/RenameColumnAdapter.html#/s:4GRDB19RenameColumnAdapterVyACS2Sccfc":{"name":"init(_:)","abstract":"

Creates a RenameColumnAdapter adapter that renames columns according to the","parent_name":"RenameColumnAdapter"},"Structs/ScopeAdapter.html#/s:4GRDB12ScopeAdapterVyACSDySSAA03RowC0_pGcfc":{"name":"init(_:)","abstract":"

Creates an adapter that preserves row contents and add scoped rows.

","parent_name":"ScopeAdapter"},"Structs/ScopeAdapter.html#/s:4GRDB12ScopeAdapterV4base6scopesAcA03RowC0_p_SDySSAaF_pGtcfc":{"name":"init(base:scopes:)","abstract":"

Creates an adapter based on the base adapter, and add scoped rows.

","parent_name":"ScopeAdapter"},"Structs/RangeRowAdapter.html#/s:4GRDB15RangeRowAdapterVyACSnySiGcfc":{"name":"init(_:)","abstract":"

Creates a RangeRowAdapter that only exposes a range of columns.

","parent_name":"RangeRowAdapter"},"Structs/RangeRowAdapter.html#/s:4GRDB15RangeRowAdapterVyACSNySiGcfc":{"name":"init(_:)","abstract":"

Creates a RangeRowAdapter that only exposes a range of columns.

","parent_name":"RangeRowAdapter"},"Structs/SuffixRowAdapter.html#/s:4GRDB16SuffixRowAdapterV9fromIndexACSi_tcfc":{"name":"init(fromIndex:)","abstract":"

Creates a SuffixRowAdapter that hides all columns before the","parent_name":"SuffixRowAdapter"},"Structs/ColumnMapping.html#/s:4GRDB13ColumnMappingVyACSDyS2SGcfc":{"name":"init(_:)","abstract":"

Creates a ColumnMapping with a dictionary from mapped column names to","parent_name":"ColumnMapping"},"Structs/EmptyRowAdapter.html#/s:4GRDB15EmptyRowAdapterVACycfc":{"name":"init()","abstract":"

Creates an EmptyRowAdapter

","parent_name":"EmptyRowAdapter"},"Structs/AnyFetchRequest.html#/s:4GRDB15AnyFetchRequestV02asD02ofACyqd__Gqd__m_tlF":{"name":"asRequest(of:)","abstract":"

Creates a request bound to type RowDecoder.

","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB15AnyFetchRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB15AnyFetchRequestVyACyxGqd__c10RowDecoderQyd__RszAA0cD0Rd__lufc":{"name":"init(_:)","abstract":"

Creates a request that wraps and forwards operations to request.

","parent_name":"AnyFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB12FetchRequestP10RowDecoderQa":{"name":"RowDecoder","parent_name":"AdaptedFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB19AdaptedFetchRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"AdaptedFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"AdaptedFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"AdaptedFetchRequest"},"Structs/PreparedRequest.html#/s:4GRDB15PreparedRequestV9statementAA9StatementCvp":{"name":"statement","abstract":"

A prepared statement

","parent_name":"PreparedRequest"},"Structs/PreparedRequest.html#/s:4GRDB15PreparedRequestV7adapterAA10RowAdapter_pSgvp":{"name":"adapter","abstract":"

An eventual adapter for rows fetched by the select statement

","parent_name":"PreparedRequest"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO4nullyA2EmF":{"name":"null","abstract":"

The NULL storage class.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO5int64yAEs5Int64VcAEmF":{"name":"int64(_:)","abstract":"

The INTEGER storage class, wrapping an Int64.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO6doubleyAESdcAEmF":{"name":"double(_:)","abstract":"

The REAL storage class, wrapping a Double.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO6stringyAESScAEmF":{"name":"string(_:)","abstract":"

The TEXT storage class, wrapping a String.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO4blobyAE10Foundation4DataVcAEmF":{"name":"blob(_:)","abstract":"

The BLOB storage class, wrapping Data.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO5valueAA0bC11Convertible_pSgvp":{"name":"value","abstract":"

Returns Int64, Double, String, Data or nil.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO2eeoiySbAE_AEtFZ":{"name":"==(_:_:)","abstract":"

Return true if the storages are identical.

","parent_name":"Storage"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV7storageAC7StorageOvp":{"name":"storage","abstract":"

The SQLite storage

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV4nullACvpZ":{"name":"null","abstract":"

The NULL DatabaseValue.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue/Storage.html":{"name":"Storage","abstract":"

An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV5valueACSgyp_tcfc":{"name":"init(value:)","abstract":"

Creates a DatabaseValue from Any.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV6isNullSbvp":{"name":"isNull","abstract":"

Returns true if databaseValue is NULL.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV2eeoiySbAC_ACtFZ":{"name":"==(_:_:)","abstract":"

Returns whether two DatabaseValues are equal.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV08databaseC0ACvp":{"name":"databaseValue","abstract":"

Returns self

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV04frombC0yACSgACFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns the database value

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"DatabaseValue"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV6extentAA0B0C011TransactionD6ExtentOvp":{"name":"extent","abstract":"

The extent of the database observation. The default is","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV8trackingAcA0bC11Convertible_pd_tcfc":{"name":"init(tracking:)","abstract":"

Creates a DatabaseRegionObservation which observes regions, and","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV8trackingACSayAA0bC11Convertible_pG_tcfc":{"name":"init(tracking:)","abstract":"

Creates a DatabaseRegionObservation which observes regions, and","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV5start2in8onChangeAA19TransactionObserver_pAA0B6Writer_p_yAA0B0CctKF":{"name":"start(in:onChange:)","abstract":"

Starts the observation in the provided database writer (such as","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV9publisher2inAA0B10PublishersO0bC0VAA0B6Writer_p_tF":{"name":"publisher(in:)","abstract":"

Returns a publisher that tracks changes in a database region.

","parent_name":"DatabaseRegionObservation"},"Structs/AnyDatabaseRegionConvertible.html#/s:4GRDB28AnyDatabaseRegionConvertibleVyAcA0cD0VAA0C0CKccfc":{"name":"init(_:)","abstract":"

Undocumented

","parent_name":"AnyDatabaseRegionConvertible"},"Structs/AnyDatabaseRegionConvertible.html#/s:4GRDB28AnyDatabaseRegionConvertibleVyAcA0cdE0_pcfc":{"name":"init(_:)","abstract":"

Undocumented

","parent_name":"AnyDatabaseRegionConvertible"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV7isEmptySbvp":{"name":"isEmpty","abstract":"

Returns whether the region is empty.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV06isFullB0Sbvp":{"name":"isFullDatabase","abstract":"

Returns whether the region covers the full database: all columns and all","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV04fullB0ACvpZ":{"name":"fullDatabase","abstract":"

The region that covers the full database: all columns and all rows","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionVACycfc":{"name":"init()","abstract":"

Creates an empty database region.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV5tableACSS_tcfc":{"name":"init(table:)","abstract":"

Creates a region that spans all rows and columns of a database table.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV5unionyA2CF":{"name":"union(_:)","abstract":"

Returns the union of this region and the given one.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV9formUnionyyACF":{"name":"formUnion(_:)","abstract":"

Inserts the given region into this region

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified14byEventsOfKindSbAA0b5EventI0O_tF":{"name":"isModified(byEventsOfKind:)","abstract":"

Returns whether the content in the region would be impacted if the","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF":{"name":"isModified(by:)","abstract":"

Returns whether the content in the region is impacted by this event.

","parent_name":"DatabaseRegion"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV10resultCodeAA06ResultE0Vvp":{"name":"resultCode","abstract":"

The SQLite error code (see","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18extendedResultCodeAA0eF0Vvp":{"name":"extendedResultCode","abstract":"

The SQLite extended error code (see","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV7messageSSSgvp":{"name":"message","abstract":"

The SQLite error message.

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV3sqlSSSgvp":{"name":"sql","abstract":"

The SQL query that yielded the error (if relevant).

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV9argumentsAA18StatementArgumentsVSgvp":{"name":"arguments","abstract":"

The query arguments that yielded the error (if relevant).

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV10resultCode7message3sql9argumentsAcA06ResultE0V_SSSgAjA18StatementArgumentsVSgtcfc":{"name":"init(resultCode:message:sql:arguments:)","abstract":"

Creates a Database Error

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV9SQLITE_OKAA10ResultCodeVvpZ":{"name":"SQLITE_OK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_ERRORAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_INTERNALAA10ResultCodeVvpZ":{"name":"SQLITE_INTERNAL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_PERMAA10ResultCodeVvpZ":{"name":"SQLITE_PERM","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_ABORTAA10ResultCodeVvpZ":{"name":"SQLITE_ABORT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_BUSYAA10ResultCodeVvpZ":{"name":"SQLITE_BUSY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_LOCKEDAA10ResultCodeVvpZ":{"name":"SQLITE_LOCKED","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_NOMEMAA10ResultCodeVvpZ":{"name":"SQLITE_NOMEM","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_READONLYAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV16SQLITE_INTERRUPTAA10ResultCodeVvpZ":{"name":"SQLITE_INTERRUPT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_IOERRAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV14SQLITE_CORRUPTAA10ResultCodeVvpZ":{"name":"SQLITE_CORRUPT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_NOTFOUNDAA10ResultCodeVvpZ":{"name":"SQLITE_NOTFOUND","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_FULLAA10ResultCodeVvpZ":{"name":"SQLITE_FULL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_CANTOPENAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_PROTOCOLAA10ResultCodeVvpZ":{"name":"SQLITE_PROTOCOL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_EMPTYAA10ResultCodeVvpZ":{"name":"SQLITE_EMPTY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_SCHEMAAA10ResultCodeVvpZ":{"name":"SQLITE_SCHEMA","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_TOOBIGAA10ResultCodeVvpZ":{"name":"SQLITE_TOOBIG","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_CONSTRAINTAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_MISMATCHAA10ResultCodeVvpZ":{"name":"SQLITE_MISMATCH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_MISUSEAA10ResultCodeVvpZ":{"name":"SQLITE_MISUSE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_NOLFSAA10ResultCodeVvpZ":{"name":"SQLITE_NOLFS","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_AUTHAA10ResultCodeVvpZ":{"name":"SQLITE_AUTH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_FORMATAA10ResultCodeVvpZ":{"name":"SQLITE_FORMAT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_RANGEAA10ResultCodeVvpZ":{"name":"SQLITE_RANGE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_NOTADBAA10ResultCodeVvpZ":{"name":"SQLITE_NOTADB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_NOTICEAA10ResultCodeVvpZ":{"name":"SQLITE_NOTICE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV14SQLITE_WARNINGAA10ResultCodeVvpZ":{"name":"SQLITE_WARNING","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV10SQLITE_ROWAA10ResultCodeVvpZ":{"name":"SQLITE_ROW","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_DONEAA10ResultCodeVvpZ":{"name":"SQLITE_DONE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_ERROR_MISSING_COLLSEQAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR_MISSING_COLLSEQ","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_ERROR_RETRYAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR_RETRY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_ERROR_SNAPSHOTAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR_SNAPSHOT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_READAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_READ","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_IOERR_SHORT_READAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHORT_READ","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_WRITEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_WRITE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_FSYNCAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_FSYNC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV22SQLITE_IOERR_DIR_FSYNCAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DIR_FSYNC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_IOERR_TRUNCATEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_TRUNCATE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_FSTATAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_FSTAT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_UNLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_UNLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_RDLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_RDLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_DELETEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DELETE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_BLOCKEDAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_BLOCKED","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_NOMEMAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_NOMEM","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_ACCESSAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_ACCESS","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV30SQLITE_IOERR_CHECKRESERVEDLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_CHECKRESERVEDLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_LOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_LOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_CLOSEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_CLOSE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV22SQLITE_IOERR_DIR_CLOSEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DIR_CLOSE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_SHMOPENAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMOPEN","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_SHMSIZEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMSIZE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_SHMLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_SHMMAPAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMMAP","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_SEEKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SEEK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_IOERR_DELETE_NOENTAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DELETE_NOENT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_MMAPAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_MMAP","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_IOERR_GETTEMPPATHAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_GETTEMPPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_IOERR_CONVPATHAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_CONVPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_VNODEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_VNODE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_AUTHAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_AUTH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_IOERR_BEGIN_ATOMICAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_BEGIN_ATOMIC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV26SQLITE_IOERR_COMMIT_ATOMICAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_COMMIT_ATOMIC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_IOERR_ROLLBACK_ATOMICAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_ROLLBACK_ATOMIC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_LOCKED_SHAREDCACHEAA10ResultCodeVvpZ":{"name":"SQLITE_LOCKED_SHAREDCACHE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_LOCKED_VTABAA10ResultCodeVvpZ":{"name":"SQLITE_LOCKED_VTAB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_BUSY_RECOVERYAA10ResultCodeVvpZ":{"name":"SQLITE_BUSY_RECOVERY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_BUSY_SNAPSHOTAA10ResultCodeVvpZ":{"name":"SQLITE_BUSY_SNAPSHOT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_CANTOPEN_NOTEMPDIRAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_NOTEMPDIR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_CANTOPEN_ISDIRAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_ISDIR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CANTOPEN_FULLPATHAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_FULLPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CANTOPEN_CONVPATHAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_CONVPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CANTOPEN_DIRTYWALAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_DIRTYWAL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_CORRUPT_VTABAA10ResultCodeVvpZ":{"name":"SQLITE_CORRUPT_VTAB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_CORRUPT_SEQUENCEAA10ResultCodeVvpZ":{"name":"SQLITE_CORRUPT_SEQUENCE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_RECOVERYAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_RECOVERY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_CANTLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_CANTLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_ROLLBACKAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_ROLLBACK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_READONLY_DBMOVEDAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_DBMOVED","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_CANTINITAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_CANTINIT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_READONLY_DIRECTORYAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_DIRECTORY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_ABORT_ROLLBACKAA10ResultCodeVvpZ":{"name":"SQLITE_ABORT_ROLLBACK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_CONSTRAINT_CHECKAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_CHECK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_CONSTRAINT_COMMITHOOKAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_COMMITHOOK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_CONSTRAINT_FOREIGNKEYAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_FOREIGNKEY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV26SQLITE_CONSTRAINT_FUNCTIONAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_FUNCTION","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_CONSTRAINT_NOTNULLAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_NOTNULL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_CONSTRAINT_PRIMARYKEYAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_PRIMARYKEY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_CONSTRAINT_TRIGGERAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_TRIGGER","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CONSTRAINT_UNIQUEAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_UNIQUE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV22SQLITE_CONSTRAINT_VTABAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_VTAB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_CONSTRAINT_ROWIDAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_ROWID","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_NOTICE_RECOVER_WALAA10ResultCodeVvpZ":{"name":"SQLITE_NOTICE_RECOVER_WAL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV30SQLITE_NOTICE_RECOVER_ROLLBACKAA10ResultCodeVvpZ":{"name":"SQLITE_NOTICE_RECOVER_ROLLBACK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_WARNING_AUTOINDEXAA10ResultCodeVvpZ":{"name":"SQLITE_WARNING_AUTOINDEX","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV16SQLITE_AUTH_USERAA10ResultCodeVvpZ":{"name":"SQLITE_AUTH_USER","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV26SQLITE_OK_LOAD_PERMANENTLYAA10ResultCodeVvpZ":{"name":"SQLITE_OK_LOAD_PERMANENTLY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV014isInterruptionC0Sbvp":{"name":"isInterruptionError","abstract":"

Returns true if the error has code SQLITE_ABORT or SQLITE_INTERRUPT.

","parent_name":"DatabaseError"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV8rawValues5Int32Vvp":{"name":"rawValue","abstract":"

The raw SQLite result code

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV8rawValueACs5Int32V_tcfc":{"name":"init(rawValue:)","abstract":"

Creates a ResultCode from a raw SQLite result code.

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV07primarybC0ACvp":{"name":"primaryResultCode","abstract":"

A result code limited to the least significant 8 bits of the receiver.","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV2teoiySbAC_ACtFZ":{"name":"~=(_:_:)","abstract":"

Returns true if the code on the left matches the code on the right.

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV9SQLITE_OKACvpZ":{"name":"SQLITE_OK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_ERRORACvpZ":{"name":"SQLITE_ERROR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_INTERNALACvpZ":{"name":"SQLITE_INTERNAL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_PERMACvpZ":{"name":"SQLITE_PERM","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_ABORTACvpZ":{"name":"SQLITE_ABORT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_BUSYACvpZ":{"name":"SQLITE_BUSY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_LOCKEDACvpZ":{"name":"SQLITE_LOCKED","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_NOMEMACvpZ":{"name":"SQLITE_NOMEM","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_READONLYACvpZ":{"name":"SQLITE_READONLY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV16SQLITE_INTERRUPTACvpZ":{"name":"SQLITE_INTERRUPT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_IOERRACvpZ":{"name":"SQLITE_IOERR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV14SQLITE_CORRUPTACvpZ":{"name":"SQLITE_CORRUPT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_NOTFOUNDACvpZ":{"name":"SQLITE_NOTFOUND","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_FULLACvpZ":{"name":"SQLITE_FULL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_CANTOPENACvpZ":{"name":"SQLITE_CANTOPEN","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_PROTOCOLACvpZ":{"name":"SQLITE_PROTOCOL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_EMPTYACvpZ":{"name":"SQLITE_EMPTY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_SCHEMAACvpZ":{"name":"SQLITE_SCHEMA","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_TOOBIGACvpZ":{"name":"SQLITE_TOOBIG","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_CONSTRAINTACvpZ":{"name":"SQLITE_CONSTRAINT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_MISMATCHACvpZ":{"name":"SQLITE_MISMATCH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_MISUSEACvpZ":{"name":"SQLITE_MISUSE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_NOLFSACvpZ":{"name":"SQLITE_NOLFS","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_AUTHACvpZ":{"name":"SQLITE_AUTH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_FORMATACvpZ":{"name":"SQLITE_FORMAT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_RANGEACvpZ":{"name":"SQLITE_RANGE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_NOTADBACvpZ":{"name":"SQLITE_NOTADB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_NOTICEACvpZ":{"name":"SQLITE_NOTICE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV14SQLITE_WARNINGACvpZ":{"name":"SQLITE_WARNING","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV10SQLITE_ROWACvpZ":{"name":"SQLITE_ROW","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_DONEACvpZ":{"name":"SQLITE_DONE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_ERROR_MISSING_COLLSEQACvpZ":{"name":"SQLITE_ERROR_MISSING_COLLSEQ","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_ERROR_RETRYACvpZ":{"name":"SQLITE_ERROR_RETRY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_ERROR_SNAPSHOTACvpZ":{"name":"SQLITE_ERROR_SNAPSHOT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_READACvpZ":{"name":"SQLITE_IOERR_READ","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_IOERR_SHORT_READACvpZ":{"name":"SQLITE_IOERR_SHORT_READ","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_WRITEACvpZ":{"name":"SQLITE_IOERR_WRITE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_FSYNCACvpZ":{"name":"SQLITE_IOERR_FSYNC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV22SQLITE_IOERR_DIR_FSYNCACvpZ":{"name":"SQLITE_IOERR_DIR_FSYNC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_IOERR_TRUNCATEACvpZ":{"name":"SQLITE_IOERR_TRUNCATE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_FSTATACvpZ":{"name":"SQLITE_IOERR_FSTAT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_UNLOCKACvpZ":{"name":"SQLITE_IOERR_UNLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_RDLOCKACvpZ":{"name":"SQLITE_IOERR_RDLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_DELETEACvpZ":{"name":"SQLITE_IOERR_DELETE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_BLOCKEDACvpZ":{"name":"SQLITE_IOERR_BLOCKED","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_NOMEMACvpZ":{"name":"SQLITE_IOERR_NOMEM","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_ACCESSACvpZ":{"name":"SQLITE_IOERR_ACCESS","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV30SQLITE_IOERR_CHECKRESERVEDLOCKACvpZ":{"name":"SQLITE_IOERR_CHECKRESERVEDLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_LOCKACvpZ":{"name":"SQLITE_IOERR_LOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_CLOSEACvpZ":{"name":"SQLITE_IOERR_CLOSE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV22SQLITE_IOERR_DIR_CLOSEACvpZ":{"name":"SQLITE_IOERR_DIR_CLOSE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_SHMOPENACvpZ":{"name":"SQLITE_IOERR_SHMOPEN","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_SHMSIZEACvpZ":{"name":"SQLITE_IOERR_SHMSIZE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_SHMLOCKACvpZ":{"name":"SQLITE_IOERR_SHMLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_SHMMAPACvpZ":{"name":"SQLITE_IOERR_SHMMAP","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_SEEKACvpZ":{"name":"SQLITE_IOERR_SEEK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_IOERR_DELETE_NOENTACvpZ":{"name":"SQLITE_IOERR_DELETE_NOENT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_MMAPACvpZ":{"name":"SQLITE_IOERR_MMAP","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_IOERR_GETTEMPPATHACvpZ":{"name":"SQLITE_IOERR_GETTEMPPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_IOERR_CONVPATHACvpZ":{"name":"SQLITE_IOERR_CONVPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_VNODEACvpZ":{"name":"SQLITE_IOERR_VNODE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_AUTHACvpZ":{"name":"SQLITE_IOERR_AUTH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_IOERR_BEGIN_ATOMICACvpZ":{"name":"SQLITE_IOERR_BEGIN_ATOMIC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV26SQLITE_IOERR_COMMIT_ATOMICACvpZ":{"name":"SQLITE_IOERR_COMMIT_ATOMIC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_IOERR_ROLLBACK_ATOMICACvpZ":{"name":"SQLITE_IOERR_ROLLBACK_ATOMIC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_LOCKED_SHAREDCACHEACvpZ":{"name":"SQLITE_LOCKED_SHAREDCACHE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_LOCKED_VTABACvpZ":{"name":"SQLITE_LOCKED_VTAB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_BUSY_RECOVERYACvpZ":{"name":"SQLITE_BUSY_RECOVERY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_BUSY_SNAPSHOTACvpZ":{"name":"SQLITE_BUSY_SNAPSHOT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_CANTOPEN_NOTEMPDIRACvpZ":{"name":"SQLITE_CANTOPEN_NOTEMPDIR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_CANTOPEN_ISDIRACvpZ":{"name":"SQLITE_CANTOPEN_ISDIR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CANTOPEN_FULLPATHACvpZ":{"name":"SQLITE_CANTOPEN_FULLPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CANTOPEN_CONVPATHACvpZ":{"name":"SQLITE_CANTOPEN_CONVPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CANTOPEN_DIRTYWALACvpZ":{"name":"SQLITE_CANTOPEN_DIRTYWAL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_CORRUPT_VTABACvpZ":{"name":"SQLITE_CORRUPT_VTAB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_CORRUPT_SEQUENCEACvpZ":{"name":"SQLITE_CORRUPT_SEQUENCE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_RECOVERYACvpZ":{"name":"SQLITE_READONLY_RECOVERY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_CANTLOCKACvpZ":{"name":"SQLITE_READONLY_CANTLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_ROLLBACKACvpZ":{"name":"SQLITE_READONLY_ROLLBACK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_READONLY_DBMOVEDACvpZ":{"name":"SQLITE_READONLY_DBMOVED","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_CANTINITACvpZ":{"name":"SQLITE_READONLY_CANTINIT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_READONLY_DIRECTORYACvpZ":{"name":"SQLITE_READONLY_DIRECTORY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_ABORT_ROLLBACKACvpZ":{"name":"SQLITE_ABORT_ROLLBACK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_CONSTRAINT_CHECKACvpZ":{"name":"SQLITE_CONSTRAINT_CHECK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_CONSTRAINT_COMMITHOOKACvpZ":{"name":"SQLITE_CONSTRAINT_COMMITHOOK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_CONSTRAINT_FOREIGNKEYACvpZ":{"name":"SQLITE_CONSTRAINT_FOREIGNKEY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV26SQLITE_CONSTRAINT_FUNCTIONACvpZ":{"name":"SQLITE_CONSTRAINT_FUNCTION","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_CONSTRAINT_NOTNULLACvpZ":{"name":"SQLITE_CONSTRAINT_NOTNULL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_CONSTRAINT_PRIMARYKEYACvpZ":{"name":"SQLITE_CONSTRAINT_PRIMARYKEY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_CONSTRAINT_TRIGGERACvpZ":{"name":"SQLITE_CONSTRAINT_TRIGGER","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CONSTRAINT_UNIQUEACvpZ":{"name":"SQLITE_CONSTRAINT_UNIQUE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV22SQLITE_CONSTRAINT_VTABACvpZ":{"name":"SQLITE_CONSTRAINT_VTAB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_CONSTRAINT_ROWIDACvpZ":{"name":"SQLITE_CONSTRAINT_ROWID","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_NOTICE_RECOVER_WALACvpZ":{"name":"SQLITE_NOTICE_RECOVER_WAL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV30SQLITE_NOTICE_RECOVER_ROLLBACKACvpZ":{"name":"SQLITE_NOTICE_RECOVER_ROLLBACK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_WARNING_AUTOINDEXACvpZ":{"name":"SQLITE_WARNING_AUTOINDEX","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV16SQLITE_AUTH_USERACvpZ":{"name":"SQLITE_AUTH_USER","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV26SQLITE_OK_LOAD_PERMANENTLYACvpZ":{"name":"SQLITE_OK_LOAD_PERMANENTLY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV2teoiySbAC_s5Error_ptFZ":{"name":"~=(_:_:)","abstract":"

Returns true if the code on the left matches the error on the right.

","parent_name":"ResultCode"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV2idSivp":{"name":"id","abstract":"

The first column in the output of the foreign_key_list pragma

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV16destinationTableSSvp":{"name":"destinationTable","abstract":"

The name of the destination table

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV7mappingSaySS6origin_SS11destinationtGvp":{"name":"mapping","abstract":"

The column to column mapping

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV13originColumnsSaySSGvp":{"name":"originColumns","abstract":"

The origin columns

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV18destinationColumnsSaySSGvp":{"name":"destinationColumns","abstract":"

The destination columns

","parent_name":"ForeignKeyInfo"},"Structs/PrimaryKeyInfo.html#/s:4GRDB14PrimaryKeyInfoV7columnsSaySSGvp":{"name":"columns","abstract":"

The columns in the primary key; this array is never empty.

","parent_name":"PrimaryKeyInfo"},"Structs/PrimaryKeyInfo.html#/s:4GRDB14PrimaryKeyInfoV11rowIDColumnSSSgvp":{"name":"rowIDColumn","abstract":"

When not nil, the name of the column that contains the INTEGER PRIMARY KEY.

","parent_name":"PrimaryKeyInfo"},"Structs/PrimaryKeyInfo.html#/s:4GRDB14PrimaryKeyInfoV7isRowIDSbvp":{"name":"isRowID","abstract":"

When true, the primary key is the rowid:

","parent_name":"PrimaryKeyInfo"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV11originTableSSvp":{"name":"originTable","abstract":"

The name of the table that contains the REFERENCES clause

","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV11originRowIDs5Int64VSgvp":{"name":"originRowID","abstract":"

The rowid of the row that contains the invalid REFERENCES clause, or","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV16destinationTableSSvp":{"name":"destinationTable","abstract":"

The name of the table that is referred to.

","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV07foreignC2IdSivp":{"name":"foreignKeyId","abstract":"

The id of the specific foreign key constraint that failed. This id","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB15FetchableRecordP3rowxAA3RowC_tcfc":{"name":"init(row:)","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV18failureDescriptionySSAA8DatabaseCKF":{"name":"failureDescription(_:)","abstract":"

Returns a precise description of the foreign key violation.

","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV13databaseErroryAA08DatabaseF0VAA0G0CF":{"name":"databaseError(_:)","abstract":"

Returns a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY

","parent_name":"ForeignKeyViolation"},"Structs/IndexInfo.html#/s:4GRDB9IndexInfoV4nameSSvp":{"name":"name","abstract":"

The name of the index

","parent_name":"IndexInfo"},"Structs/IndexInfo.html#/s:4GRDB9IndexInfoV7columnsSaySSGvp":{"name":"columns","abstract":"

The indexed columns

","parent_name":"IndexInfo"},"Structs/IndexInfo.html#/s:4GRDB9IndexInfoV8isUniqueSbvp":{"name":"isUnique","abstract":"

True if the index is unique

","parent_name":"IndexInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV4nameSSvp":{"name":"name","abstract":"

The column name

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV4typeSSvp":{"name":"type","abstract":"

The column data type

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV9isNotNullSbvp":{"name":"isNotNull","abstract":"

True if and only if the column is constrained to be not null.

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV15defaultValueSQLSSSgvp":{"name":"defaultValueSQL","abstract":"

The SQL snippet that defines the default value, if any.

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV15primaryKeyIndexSivp":{"name":"primaryKeyIndex","abstract":"

Zero for columns that are not part of the primary key.

","parent_name":"ColumnInfo"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV18foreignKeysEnabledSbvp":{"name":"foreignKeysEnabled","abstract":"

If true, foreign key constraints are checked.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV8readonlySbvp":{"name":"readonly","abstract":"

If true, database modifications are disallowed.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV5labelSSSgvp":{"name":"label","abstract":"

The configuration label.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV33acceptsDoubleQuotedStringLiteralsSbvp":{"name":"acceptsDoubleQuotedStringLiterals","abstract":"

If false, SQLite from version 3.29.0 will not interpret a double-quoted","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV31observesSuspensionNotificationsSbvp":{"name":"observesSuspensionNotifications","abstract":"

When true, the Database.suspendNotification and","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV15prepareDatabaseyyyAA0D0CKcF":{"name":"prepareDatabase(_:)","abstract":"

The function argument is run when an SQLite connection is opened,","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV22defaultTransactionKindAA8DatabaseC0dE0Ovp":{"name":"defaultTransactionKind","abstract":"

The default kind of transaction.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV24allowsUnsafeTransactionsSbvp":{"name":"allowsUnsafeTransactions","abstract":"

If false, it is a programmer error to leave a transaction opened at the","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV8busyModeAA8DatabaseC04BusyD0Ovp":{"name":"busyMode","abstract":"

The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV18maximumReaderCountSivp":{"name":"maximumReaderCount","abstract":"

The maximum number of concurrent readers (applies to database","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV3qos8Dispatch0D3QoSVvp":{"name":"qos","abstract":"

The quality of service class for the work performed by the database.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV11targetQueueSo17OS_dispatch_queueCSgvp":{"name":"targetQueue","abstract":"

The target queue for all database accesses.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationVACycfc":{"name":"init()","abstract":"

Creates a factory configuration

","parent_name":"Configuration"},"Structs/Configuration.html":{"name":"Configuration","abstract":"

Configuration for a DatabaseQueue or DatabasePool.

"},"Structs/ColumnInfo.html":{"name":"ColumnInfo","abstract":"

A column of a database table.

"},"Structs/IndexInfo.html":{"name":"IndexInfo","abstract":"

An index on a database table.

"},"Structs/ForeignKeyViolation.html":{"name":"ForeignKeyViolation","abstract":"

A foreign key violation produced by PRAGMA foreign_key_check

"},"Structs/PrimaryKeyInfo.html":{"name":"PrimaryKeyInfo","abstract":"

Primary keys are returned from the Database.primaryKey(_:) method.

"},"Structs/ForeignKeyInfo.html":{"name":"ForeignKeyInfo","abstract":"

You get foreign keys from table names, with the"},"Structs/ResultCode.html":{"name":"ResultCode","abstract":"

An SQLite result code.

"},"Structs/DatabaseError.html":{"name":"DatabaseError","abstract":"

DatabaseError wraps an SQLite error.

"},"Structs/DatabaseRegion.html":{"name":"DatabaseRegion","abstract":"

DatabaseRegion defines a region in the database. DatabaseRegion is dedicated"},"Structs/AnyDatabaseRegionConvertible.html":{"name":"AnyDatabaseRegionConvertible","abstract":"

A type-erased DatabaseRegionConvertible

"},"Structs/DatabaseRegionObservation.html":{"name":"DatabaseRegionObservation","abstract":"

DatabaseRegionObservation tracks changes in the results of database"},"Structs/DatabaseValue.html":{"name":"DatabaseValue","abstract":"

DatabaseValue is the intermediate type between SQLite and your values.

"},"Structs/PreparedRequest.html":{"name":"PreparedRequest","abstract":"

A PreparedRequest is a request that is ready to be executed.

"},"Structs/AdaptedFetchRequest.html":{"name":"AdaptedFetchRequest","abstract":"

An adapted request.

"},"Structs/AnyFetchRequest.html":{"name":"AnyFetchRequest","abstract":"

A type-erased FetchRequest.

"},"Structs.html#/s:4GRDB8RowIndexV":{"name":"RowIndex","abstract":"

Indexes to (ColumnName, DatabaseValue) pairs in a database row.

"},"Structs/EmptyRowAdapter.html":{"name":"EmptyRowAdapter","abstract":"

EmptyRowAdapter is a row adapter that hides all columns.

"},"Structs/ColumnMapping.html":{"name":"ColumnMapping","abstract":"

ColumnMapping is a row adapter that maps column names.

"},"Structs/SuffixRowAdapter.html":{"name":"SuffixRowAdapter","abstract":"

SuffixRowAdapter is a row adapter that hides the first columns in a row.

"},"Structs/RangeRowAdapter.html":{"name":"RangeRowAdapter","abstract":"

RangeRowAdapter is a row adapter that only exposes a range of columns.

"},"Structs/ScopeAdapter.html":{"name":"ScopeAdapter","abstract":"

ScopeAdapter is a row adapter that lets you define scopes on rows.

"},"Structs/RenameColumnAdapter.html":{"name":"RenameColumnAdapter","abstract":"

RenameColumnAdapter is a row adapter that renames columns.

"},"Structs/SQL.html":{"name":"SQL","abstract":"

SQL helps you build SQL literal with"},"Structs/SQLRequest.html":{"name":"SQLRequest","abstract":"

A FetchRequest built from raw SQL.

"},"Structs/StatementArguments.html":{"name":"StatementArguments","abstract":"

StatementArguments provide values to argument placeholders in raw"},"Structs/DatabaseDateComponents.html":{"name":"DatabaseDateComponents","abstract":"

DatabaseDateComponents reads and stores DateComponents in the database.

"},"Structs/DatabaseEvent.html":{"name":"DatabaseEvent","abstract":"

A database event, notified to TransactionObserver.

"},"Structs/DatabasePreUpdateEvent.html":{"name":"DatabasePreUpdateEvent"},"Structs/FTS3.html":{"name":"FTS3","abstract":"

FTS3 lets you define “fts3” virtual tables.

"},"Structs/FTS3Pattern.html":{"name":"FTS3Pattern","abstract":"

A full text pattern that can query FTS3 and FTS4 virtual tables.

"},"Structs/FTS3TokenizerDescriptor.html":{"name":"FTS3TokenizerDescriptor","abstract":"

An FTS3 tokenizer, suitable for FTS3 and FTS4 table definitions:

"},"Structs/FTS4.html":{"name":"FTS4","abstract":"

FTS4 lets you define “fts4” virtual tables.

"},"Structs/FTS5.html":{"name":"FTS5","abstract":"

FTS5 lets you define “fts5” virtual tables.

"},"Structs/FTS5Pattern.html":{"name":"FTS5Pattern","abstract":"

A full text pattern that can query FTS5 virtual tables.

"},"Structs/FTS5Tokenization.html":{"name":"FTS5Tokenization","abstract":"

The reason why FTS5 is requesting tokenization.

"},"Structs/FTS5TokenizerDescriptor.html":{"name":"FTS5TokenizerDescriptor","abstract":"

An FTS5 tokenizer, suitable for FTS5 table definitions:

"},"Structs/FTS5TokenFlags.html":{"name":"FTS5TokenFlags","abstract":"

Flags that tell SQLite how to register a token.

"},"Structs/DatabaseMigrator.html":{"name":"DatabaseMigrator","abstract":"

A DatabaseMigrator registers and applies database migrations.

"},"Structs/ForeignKey.html":{"name":"ForeignKey","abstract":"

A ForeignKey helps building associations when GRDB can’t infer a foreign"},"Structs/AssociationAggregate.html":{"name":"AssociationAggregate","abstract":"

An AssociationAggregate is able to compute aggregated values from a"},"Structs.html#/s:4GRDB20BelongsToAssociationV":{"name":"BelongsToAssociation","abstract":"

The BelongsTo association sets up a one-to-one connection from a record"},"Structs.html#/s:4GRDB18HasManyAssociationV":{"name":"HasManyAssociation","abstract":"

The HasMany association indicates a one-to-many connection between two"},"Structs.html#/s:4GRDB25HasManyThroughAssociationV":{"name":"HasManyThroughAssociation","abstract":"

The HasManyThrough association is often used to set up a many-to-many"},"Structs.html#/s:4GRDB17HasOneAssociationV":{"name":"HasOneAssociation","abstract":"

The HasOne association indicates a one-to-one connection between two"},"Structs.html#/s:4GRDB24HasOneThroughAssociationV":{"name":"HasOneThroughAssociation","abstract":"

A HasOneThrough association sets up a one-to-one connection with"},"Structs.html#/s:4GRDB15JoinAssociationV":{"name":"JoinAssociation","abstract":"

The Join association is used to join common table expression to regular"},"Structs/CommonTableExpression.html":{"name":"CommonTableExpression","abstract":"

A common table expression that can be"},"Structs/QueryInterfaceRequest.html":{"name":"QueryInterfaceRequest","abstract":"

QueryInterfaceRequest is a request that generates SQL for you.

"},"Structs.html#/s:4GRDB16ColumnAssignmentV":{"name":"ColumnAssignment","abstract":"

A ColumnAssignment can update rows in the database.

"},"Structs/Column.html":{"name":"Column","abstract":"

A column in a database table.

"},"Structs/SQLExpression.html":{"name":"SQLExpression","abstract":"

SQLExpression is the type that represents an SQL expression, as"},"Structs/SQLOrdering.html":{"name":"SQLOrdering","abstract":"

The type that can be used as an SQL ordering term, as described at"},"Structs/PersistenceContainer.html":{"name":"PersistenceContainer","abstract":"

Use persistence containers in the encode(to:) method of your"},"Structs/SQLSelection.html":{"name":"SQLSelection","abstract":"

The type that can be selected, as described at"},"Structs/AllColumns.html":{"name":"AllColumns","abstract":"

AllColumns is the * in SELECT *.

"},"Structs/SQLSubquery.html":{"name":"SQLSubquery","abstract":"

The type that can be embedded as a subquery.

"},"Structs/Table.html":{"name":"Table","abstract":"

Table can build query interface requests.

"},"Structs.html#/s:4GRDB25VirtualTableConfigurationV":{"name":"VirtualTableConfiguration","abstract":"

Undocumented

"},"Structs/PersistenceConflictPolicy.html":{"name":"PersistenceConflictPolicy","abstract":"

The MutablePersistableRecord protocol uses this type in order to handle"},"Structs/Inflections.html":{"name":"Inflections","abstract":"

Experimental

"},"Structs/ValueObservation.html":{"name":"ValueObservation","abstract":"

ValueObservation tracks changes in the results of database requests, and"},"Protocols/DatabaseCancellable.html#/s:4GRDB19DatabaseCancellableP6cancelyyF":{"name":"cancel()","abstract":"

Cancel the activity.

","parent_name":"DatabaseCancellable"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordP9didInsert4with3forys5Int64V_SSSgtF":{"name":"didInsert(with:for:)","abstract":"

Notifies the record that it was successfully inserted.

","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordP6insertyyAA8DatabaseCKF":{"name":"insert(_:)","abstract":"

Executes an INSERT statement.

","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordP4saveyyAA8DatabaseCKF":{"name":"save(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordPAAE13performInsertyyAA8DatabaseCKF":{"name":"performInsert(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordPAAE11performSaveyyAA8DatabaseCKF":{"name":"performSave(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"PersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP25persistenceConflictPolicyAA011PersistencefG0VvpZ":{"name":"persistenceConflictPolicy","abstract":"

The policy that handles SQLite conflicts when records are inserted","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP9didInsert4with3forys5Int64V_SSSgtF":{"name":"didInsert(with:for:)","abstract":"

Notifies the record that it was successfully inserted.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6insertyyAA8DatabaseCKF":{"name":"insert(_:)","abstract":"

Executes an INSERT statement.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6update_7columnsyAA8DatabaseC_ShySSGtKF":{"name":"update(_:columns:)","abstract":"

Executes an UPDATE statement.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP4saveyyAA8DatabaseCKF":{"name":"save(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6deleteySbAA8DatabaseCKF":{"name":"delete(_:)","abstract":"

Executes a DELETE statement.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6existsySbAA8DatabaseCKF":{"name":"exists(_:)","abstract":"

Returns true if and only if the primary key matches a row in","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE8insertedyxAA8DatabaseCKF":{"name":"inserted(_:)","abstract":"

Executes an INSERT statement so that self is saved in the database,","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE6updateyyAA8DatabaseCKF":{"name":"update(_:)","abstract":"

Executes an UPDATE statement that updates all table columns.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13updateChanges_4fromSbAA8DatabaseC_qd__tKAaBRd__lF":{"name":"updateChanges(_:from:)","abstract":"

If the record has any difference from the other record, executes an","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13updateChanges_4withSbAA8DatabaseC_yxzKXEtKF":{"name":"updateChanges(_:with:)","abstract":"

Mutates the record according to the provided closure, and then, if the","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE5savedyxAA8DatabaseCKF":{"name":"saved(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performInsertyyAA8DatabaseCKF":{"name":"performInsert(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performUpdate_7columnsyAA8DatabaseC_ShySSGtKF":{"name":"performUpdate(_:columns:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE11performSaveyyAA8DatabaseCKF":{"name":"performSave(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performDeleteySbAA8DatabaseCKF":{"name":"performDelete(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performExistsySbAA8DatabaseCKF":{"name":"performExists(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAARlzCrlE13updateChanges_4withSbAA8DatabaseC_yxKXEtKF":{"name":"updateChanges(_:with:)","abstract":"

Mutates the record according to the provided closure, and then, if the","parent_name":"MutablePersistableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP3rowxAA3RowC_tcfc":{"name":"init(row:)","abstract":"

Creates a record from row.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP24databaseDecodingUserInfoSDys06CodingfG3KeyVypGvpZ":{"name":"databaseDecodingUserInfo","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP19databaseJSONDecoder3for10Foundation0E0CSS_tFZ":{"name":"databaseJSONDecoder(for:)","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP28databaseDateDecodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseDateDecodingStrategy","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP30databaseColumnDecodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseColumnDecodingStrategy","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE11fetchCursor_9arguments7adapterAA0cE0CyxGAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

A cursor over records fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchAll_9arguments7adapterSayxGAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of records fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchOne_9arguments7adapterxSgAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single record fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE11fetchCursor_3sql9arguments7adapterAA0cE0CyxGAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over records fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchAll_3sql9arguments7adapterSayxGAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of records fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchOne_3sql9arguments7adapterxSgAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single record fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE11fetchCursoryAA0cE0CyxGAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over records fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchAllySayxGAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of records fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchOneyxSgAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single record fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE11fetchCursoryAA0cF0CyxGAA8DatabaseCKFZ":{"name":"fetchCursor(_:)","abstract":"

A cursor over all records fetched from the database.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchAllySayxGAA8DatabaseCKFZ":{"name":"fetchAll(_:)","abstract":"

An array of all records fetched from the database.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchOneyxSgAA8DatabaseCKFZ":{"name":"fetchOne(_:)","abstract":"

The first found record.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzrlE8fetchSetyShyxGAA8DatabaseCKFZ":{"name":"fetchSet(_:)","abstract":"

A set of all records fetched from the database.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE11fetchCursor_4keysAA0cF0CyxGAA8DatabaseC_qd__tKSTRd__AA0H16ValueConvertible7ElementRpd__lFZ":{"name":"fetchCursor(_:keys:)","abstract":"

Returns a cursor over records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchAll_4keysSayxGAA8DatabaseC_qd__tKSTRd__AA0H16ValueConvertible7ElementRpd__lFZ":{"name":"fetchAll(_:keys:)","abstract":"

Returns an array of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchOne_3keyxSgAA8DatabaseC_qd__SgtKAA0H16ValueConvertibleRd__lFZ":{"name":"fetchOne(_:key:)","abstract":"

Returns a single record given its primary key.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE11fetchCursor_3idsAA0cK0CyxGAA0F0C_qd__tKSlRd__7ElementQyd__AIRSlFZ":{"name":"fetchCursor(_:ids:)","abstract":"

Returns a cursor over records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE8fetchAll_3idsSayxGAA0F0C_qd__tKSlRd__7ElementQyd__AIRSlFZ":{"name":"fetchAll(_:ids:)","abstract":"

Returns an array of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE8fetchOne_2idxSgAA0F0C_AItKFZ":{"name":"fetchOne(_:id:)","abstract":"

Returns a single record given its primary key.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE11fetchCursor_3idsAA0cN0CyxGAA0I0C_qd__tKSlRd__AaJ7ElementRpd__AmVRSlFZ":{"name":"fetchCursor(_:ids:)","abstract":"

Returns a cursor over records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE8fetchAll_3idsSayxGAA0I0C_qd__tKSlRd__AaJ7ElementRpd__AmTRSlFZ":{"name":"fetchAll(_:ids:)","abstract":"

Returns an array of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE8fetchOne_2idxSgAA0I0C_AMtKFZ":{"name":"fetchOne(_:id:)","abstract":"

Returns a single record given its primary key.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzrlE8fetchSet_4keysShyxGAA8DatabaseC_qd__tKSTRd__AA0H16ValueConvertible7ElementRpd__lFZ":{"name":"fetchSet(_:keys:)","abstract":"

Returns a set of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE8fetchSet_3idsShyxGAA0F0C_qd__tKSlRd__7ElementQyd__AIRSlFZ":{"name":"fetchSet(_:ids:)","abstract":"

Returns a set of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE8fetchSet_3idsShyxGAA0I0C_qd__tKSlRd__AaJ7ElementRpd__AmTRSlFZ":{"name":"fetchSet(_:ids:)","abstract":"

Returns a set of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE11fetchCursor_4keysAA0cF0CyxGAA8DatabaseC_SaySDySSAA0H16ValueConvertible_pSgGGtKFZ":{"name":"fetchCursor(_:keys:)","abstract":"

Returns a cursor over records identified by the provided unique keys","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchAll_4keysSayxGAA8DatabaseC_SaySDySSAA0H16ValueConvertible_pSgGGtKFZ":{"name":"fetchAll(_:keys:)","abstract":"

Returns an array of records identified by the provided unique keys","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchOne_3keyxSgAA8DatabaseC_SDySSAA0H16ValueConvertible_pSgGSgtKFZ":{"name":"fetchOne(_:key:)","abstract":"

Returns a single record identified by a unique key (the primary key or","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzrlE8fetchSet_4keysShyxGAA8DatabaseC_SaySDySSAA0H16ValueConvertible_pSgGGtKFZ":{"name":"fetchSet(_:keys:)","abstract":"

Returns a set of records identified by the provided unique keys","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAASHRzrlE8fetchSet_9arguments7adapterShyxGAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of records fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAASHRzrlE8fetchSet_3sql9arguments7adapterShyxGAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of records fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAASHRzrlE8fetchSetyShyxGAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of records fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP6encode2toyAA20PersistenceContainerVz_tF":{"name":"encode(to:)","abstract":"

Encodes the record into database values.

","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP24databaseEncodingUserInfoSDys06CodingfG3KeyVypGvpZ":{"name":"databaseEncodingUserInfo","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP19databaseJSONEncoder3for10Foundation0E0CSS_tFZ":{"name":"databaseJSONEncoder(for:)","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP28databaseDateEncodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseDateEncodingStrategy","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP28databaseUUIDEncodingStrategyAA08DatabaseeF0OvpZ":{"name":"databaseUUIDEncodingStrategy","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP30databaseColumnEncodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseColumnEncodingStrategy","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordPAAE18databaseDictionarySDySSAA13DatabaseValueVGvp":{"name":"databaseDictionary","abstract":"

A dictionary whose keys are the columns encoded in the encode(to:) method.

","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordPAAE14databaseEqualsySbxF":{"name":"databaseEquals(_:)","abstract":"

Returns a boolean indicating whether this record and the other record","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordPAAE15databaseChanges4fromSDySSAA13DatabaseValueVGqd___tAaBRd__lF":{"name":"databaseChanges(from:)","abstract":"

A dictionary of values changed from the other record.

","parent_name":"EncodableRecord"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP0C10DefinitionQa":{"name":"TableDefinition","abstract":"

The type of the closure argument in the","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP10moduleNameSSvp":{"name":"moduleName","abstract":"

The name of the module.

","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP04makeC10Definition0cF0QzyF":{"name":"makeTableDefinition()","abstract":"

Returns a table definition that is passed as the closure argument in the","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP04makeC10Definition13configuration0cF0QzAA0bC13ConfigurationV_tF":{"name":"makeTableDefinition(configuration:)","abstract":"

Returns a table definition that is passed as the closure argument in the","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP15moduleArguments3for2inSaySSG0C10DefinitionQz_AA8DatabaseCtKF":{"name":"moduleArguments(for:in:)","abstract":"

Returns the module arguments for the CREATE VIRTUAL TABLE query.

","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP8database_9didCreate5usingyAA8DatabaseC_SS0C10DefinitionQztKF":{"name":"database(_:didCreate:using:)","abstract":"

Execute any relevant database statement after the virtual table has","parent_name":"VirtualTableModule"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryableP11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"SQLSubqueryable"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryablePAAE13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","abstract":"

Returns a subquery expression.

","parent_name":"SQLSubqueryable"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryablePAAE8containsyAA13SQLExpressionVAA14SQLExpressible_pF":{"name":"contains(_:)","abstract":"

Returns an expression that checks the inclusion of the expression in","parent_name":"SQLSubqueryable"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryablePAAE6existsAA13SQLExpressionVyF":{"name":"exists()","abstract":"

Returns an expression that is true if and only if the subquery would","parent_name":"SQLSubqueryable"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE3ascAA11SQLOrderingVvp":{"name":"asc","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE4descAA11SQLOrderingVvp":{"name":"desc","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/ascNullsLast":{"name":"ascNullsLast","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/descNullsFirst":{"name":"descNullsFirst","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE12ascNullsLastAA11SQLOrderingVvp":{"name":"ascNullsLast","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE14descNullsFirstAA11SQLOrderingVvp":{"name":"descNullsFirst","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE9collatingyAA13SQLExpressionVAA8DatabaseC13CollationNameVF":{"name":"collating(_:)","abstract":"

Returns a collated expression.

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE9collatingyAA13SQLExpressionVAA17DatabaseCollationCF":{"name":"collating(_:)","abstract":"

Returns a collated expression.

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE4like_6escapeAA13SQLExpressionVAA14SQLExpressible_p_AaH_pSgtF":{"name":"like(_:escape:)","abstract":"

An SQL expression with the LIKE SQL operator.

","parent_name":"SQLSpecificExpressible"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestP8distinctxyF":{"name":"distinct()","abstract":"

Creates a request which returns distinct rows.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestP4withyxAA21CommonTableExpressionVyqd__GlF":{"name":"with(_:)","abstract":"

Returns a request which embeds the common table expression.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestPAAE9annotated4withxAA20AssociationAggregateVy10RowDecoderQzGd_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends aggregates to the current selection.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestPAAE9annotated4withxSayAA20AssociationAggregateVy10RowDecoderQzGG_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends aggregates to the current selection.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestPAAE6havingyxAA20AssociationAggregateVy10RowDecoderQzGF":{"name":"having(_:)","abstract":"

Creates a request which appends the provided aggregate predicate to","parent_name":"DerivableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE9including3allxqd___tAA17AssociationToManyRd__16OriginRowDecoderQyd__0jK0RtzlF":{"name":"including(all:)","abstract":"

Creates a request that prefetches an association.

","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE9including8optionalxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"including(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE9including8requiredxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"including(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE7joining8optionalxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"joining(optional:)","abstract":"

Creates a request that joins an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE7joining8requiredxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"joining(required:)","abstract":"

Creates a request that joins an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPA2A09SelectionC0RzrlE9annotated12withOptionalxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0jK0AA05TypedC0PRtzlF":{"name":"annotated(withOptional:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPA2A09SelectionC0RzrlE9annotated12withRequiredxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0jK0AA05TypedC0PRtzlF":{"name":"annotated(withRequired:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"JoinableRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestP5orderyxSayAA15SQLOrderingTerm_pGAA8DatabaseCKcF":{"name":"order(_:)","abstract":"

Creates a request with the provided orderings promise.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestP8reversedxyF":{"name":"reversed()","abstract":"

Creates a request that reverses applied orderings.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestP9unorderedxyF":{"name":"unordered()","abstract":"

Creates a request without any ordering.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestPAAE5order3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"order(sql:arguments:)","abstract":"

Creates a request sorted according to sql.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestPAAE5order7literalxAA3SQLV_tF":{"name":"order(literal:)","abstract":"

Creates a request sorted according to an SQL literal.

","parent_name":"OrderedRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestP5groupyxSayAA14SQLExpressible_pGAA8DatabaseCKcF":{"name":"group(_:)","abstract":"

Creates a request grouped according to expressions promise.

","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestP6havingyxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"having(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE5group3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"group(sql:arguments:)","abstract":"

Creates a request with a new grouping.

","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE5group7literalxAA3SQLV_tF":{"name":"group(literal:)","abstract":"

Creates a request with a new grouping.

","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE6having3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"having(sql:arguments:)","abstract":"

Creates a request with the provided sql added to the","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE6having7literalxAA3SQLV_tF":{"name":"having(literal:)","abstract":"

Creates a request with the provided SQL literal added to the","parent_name":"AggregatingRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestP6filteryxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"FilteredRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestPAAE6filter3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"filter(sql:arguments:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"FilteredRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestPAAE6filter7literalxAA3SQLV_tF":{"name":"filter(literal:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"FilteredRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestPAAE4nonexyF":{"name":"none()","abstract":"

Creates a request that matches nothing.

","parent_name":"FilteredRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestP6selectyxSayAA13SQLSelectable_pGAA8DatabaseCKcF":{"name":"select(_:)","abstract":"

Creates a request which selects selection promise.

","parent_name":"SelectionRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestP9annotated4withxSayAA13SQLSelectable_pGAA8DatabaseCKc_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection promise.

","parent_name":"SelectionRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestPAAE6select3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"select(sql:arguments:)","abstract":"

Creates a request which selects sql.

","parent_name":"SelectionRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestPAAE6select7literalxAA3SQLV_tF":{"name":"select(literal:)","abstract":"

Creates a request which selects an SQL literal.

","parent_name":"SelectionRequest"},"Protocols/TypedRequest.html#/s:4GRDB12TypedRequestP10RowDecoderQa":{"name":"RowDecoder","abstract":"

The type that can decode database rows.

","parent_name":"TypedRequest"},"Protocols/AssociationToMany.html#/s:4GRDB11AssociationP6forKeyyxSSF":{"name":"forKey(_:)","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE5countAA0B9AggregateVy16OriginRowDecoderQzGvp":{"name":"count","abstract":"

The number of associated records.

","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE7isEmptyAA0B9AggregateVy16OriginRowDecoderQzGvp":{"name":"isEmpty","abstract":"

Creates an aggregate that is true if there exists no associated records.

","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE7averageyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"average(_:)","abstract":"

Creates an aggregate which evaluate to the average value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE7averageyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"average(_:)","abstract":"

Creates an aggregate which evaluate to the average value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3maxyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aggregate which evaluate to the maximum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3maxyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aggregate which evaluate to the maximum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3minyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"min(_:)","abstract":"

Creates an aggregate which evaluate to the minimum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3minyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"min(_:)","abstract":"

Creates an aggregate which evaluate to the minimum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3sumyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"sum(_:)","abstract":"

Creates an aggregate which evaluate to the sum of the given expression","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3sumyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"sum(_:)","abstract":"

Creates an aggregate which evaluate to the sum of the given expression","parent_name":"AssociationToMany"},"Protocols/AssociationToOne.html#/s:4GRDB11AssociationP6forKeyyxSSF":{"name":"forKey(_:)","parent_name":"AssociationToOne"},"Protocols/Association.html#/s:4GRDB11AssociationP16OriginRowDecoderQa":{"name":"OriginRowDecoder","abstract":"

The record type at the origin of the association.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationP6forKeyyxSSF":{"name":"forKey(_:)","abstract":"

Creates an association with the given key.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE7aliasedyxAA10TableAliasCF":{"name":"aliased(_:)","abstract":"

Creates an association that allows you to define expressions that target","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE6selectyxSayAA13SQLSelectable_pGAA8DatabaseCKcF":{"name":"select(_:)","abstract":"

Creates an association which selects selection.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE9annotated4withxSayAA13SQLSelectable_pGAA8DatabaseCKc_tF":{"name":"annotated(with:)","abstract":"

Creates an association which appends selection.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE6filteryxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"filter(_:)","abstract":"

Creates an association with the provided predicate promise added to","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE5orderyxSayAA15SQLOrderingTerm_pGAA8DatabaseCKcF":{"name":"order(_:)","abstract":"

Creates an association with the provided orderings promise.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE8reversedxyF":{"name":"reversed()","abstract":"

Creates an association that reverses applied orderings.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE9unorderedxyF":{"name":"unordered()","abstract":"

Creates an association without any ordering.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB12TableRequestP08databaseB4NameSSvp":{"name":"databaseTableName","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE5groupyxSayAA14SQLExpressible_pGAA8DatabaseCKcF":{"name":"group(_:)","abstract":"

Creates an association grouped according to expressions promise.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE6havingyxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"having(_:)","abstract":"

Creates an association with the provided predicate promise added to","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE8distinctxyF":{"name":"distinct()","abstract":"

Creates an association for returns distinct rows.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE4withyxAA21CommonTableExpressionVyqd__GlF":{"name":"with(_:)","abstract":"

Returns an association that embeds the common table expression.

","parent_name":"Association"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionP4nameSSvp":{"name":"name","abstract":"

The unqualified name of a database column.

","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionPAAE5matchyAA13SQLExpressionVAA11FTS3PatternVSgF":{"name":"match(_:)","abstract":"

A matching SQL expression with the MATCH SQL operator.

","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionPAAE3set2toAA0B10AssignmentVAA14SQLExpressible_pSg_tF":{"name":"set(to:)","abstract":"

Creates an assignment to a value.

","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionPA2A0B0VRszrlE5rowIDAEvpZ":{"name":"rowID","abstract":"

The hidden rowID column

","parent_name":"ColumnExpression"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordP08databaseB4NameSSvpZ":{"name":"databaseTableName","abstract":"

The name of the database table used to build requests.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordP17databaseSelectionSayAA13SQLSelectable_pGvpZ":{"name":"databaseSelection","abstract":"

The default request selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE8matchingyAA21QueryInterfaceRequestVyxGAA11FTS3PatternVSgFZ":{"name":"matching(_:)","abstract":"

Returns a QueryInterfaceRequest with a matching predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9belongsTo_3key5usingAA07BelongsE11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAaBRd__lFZ":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7hasMany_3key5usingAA03HasE11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAaBRd__lFZ":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination type,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6hasOne_3key5usingAA03HasE11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAaBRd__lFZ":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination type,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9belongsTo_3key5usingAA07BelongsE11AssociationVyxqd__GAA0B0Vyqd__G_SSSgAA10ForeignKeyVSgtlFZ":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7hasMany_3key5usingAA03HasE11AssociationVyxqd__GAA0B0Vyqd__G_SSSgAA10ForeignKeyVSgtlFZ":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination table,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6hasOne_3key5usingAA03HasE11AssociationVyxqd__GAA0B0Vyqd__G_SSSgAA10ForeignKeyVSgtlFZ":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination table,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE11association2to2onAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_AA14SQLExpressible_pAA0B5AliasC_AOtctlFZ":{"name":"association(to:on:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE11association2toAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_tlFZ":{"name":"association(to:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7hasMany_7through5using3keyAA03HasE18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginlM0Qyd__RszAA0K0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lFZ":{"name":"hasMany(_:through:using:key:)","abstract":"

Creates a “Has Many Through” association between Self and the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6hasOne_7through5using3keyAA03HasE18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginlM0Qyd__RszAA0k2ToE0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lFZ":{"name":"hasOne(_:through:using:key:)","abstract":"

Creates a “Has One Through” association between Self and the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9including3allAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA17AssociationToManyRd__lFZ":{"name":"including(all:)","abstract":"

Creates a request that prefetches an association.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9including8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"including(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9including8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"including(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7joining8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"joining(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7joining8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"joining(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated12withOptionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"annotated(withOptional:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated12withRequiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"annotated(withRequired:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGd_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGSayAA20AssociationAggregateVyxGG_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6havingyAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGFZ":{"name":"having(_:)","abstract":"

Creates a request with the provided aggregate predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE3allAA21QueryInterfaceRequestVyxGyFZ":{"name":"all()","abstract":"

Creates a request which fetches all records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE4noneAA21QueryInterfaceRequestVyxGyFZ":{"name":"none()","abstract":"

Creates a request which fetches no record.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6selectyAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tFZ":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6selectyAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pGFZ":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtFZ":{"name":"select(sql:arguments:)","abstract":"

Creates a request which selects sql.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tFZ":{"name":"select(literal:)","abstract":"

Creates a request which selects an SQL literal.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select_2asAA21QueryInterfaceRequestVyqd__GSayAA13SQLSelectable_pG_qd__mtlFZ":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select_2asAA21QueryInterfaceRequestVyqd__GAA13SQLSelectable_pd_qd__mtlFZ":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select3sql9arguments2asAA21QueryInterfaceRequestVyqd__GSS_AA18StatementArgumentsVqd__mtlFZ":{"name":"select(sql:arguments:as:)","abstract":"

Creates a request which selects sql, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select7literal2asAA21QueryInterfaceRequestVyqd__GAA3SQLV_qd__mtlFZ":{"name":"select(literal:as:)","abstract":"

Creates a request which selects an SQL literal, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pG_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filteryAA21QueryInterfaceRequestVyxGAA14SQLExpressible_pFZ":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filteryAA21QueryInterfaceRequestVyxGAA22SQLSpecificExpressible_pFZ":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter3keyAA21QueryInterfaceRequestVyxGqd__Sg_tAA24DatabaseValueConvertibleRd__lFZ":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter4keysAA21QueryInterfaceRequestVyxGqd___tSTRd__AA24DatabaseValueConvertible7ElementRpd__lFZ":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter3keyAA21QueryInterfaceRequestVyxGSDySSAA24DatabaseValueConvertible_pSgGSg_tFZ":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter4keysAA21QueryInterfaceRequestVyxGSaySDySSAA24DatabaseValueConvertible_pSgGG_tFZ":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtFZ":{"name":"filter(sql:arguments:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tFZ":{"name":"filter(literal:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5orderyAA21QueryInterfaceRequestVyxGAA15SQLOrderingTerm_pd_tFZ":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5orderyAA21QueryInterfaceRequestVyxGSayAA15SQLOrderingTerm_pGFZ":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE17orderByPrimaryKeyAA21QueryInterfaceRequestVyxGyFZ":{"name":"orderByPrimaryKey()","abstract":"

Creates a request sorted by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5order3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtFZ":{"name":"order(sql:arguments:)","abstract":"

Creates a request sorted according to sql.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5order7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tFZ":{"name":"order(literal:)","abstract":"

Creates a request sorted according to an SQL literal.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5limit_6offsetAA21QueryInterfaceRequestVyxGSi_SiSgtFZ":{"name":"limit(_:offset:)","abstract":"

Creates a request which fetches limit rows, starting at","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7aliasedyAA21QueryInterfaceRequestVyxGAA0B5AliasCFZ":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE4withyAA21QueryInterfaceRequestVyxGAA06CommonB10ExpressionVyqd__GlFZ":{"name":"with(_:)","abstract":"

Returns a request which embeds the common table expression.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE10fetchCountySiAA8DatabaseCKFZ":{"name":"fetchCount(_:)","abstract":"

The number of records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE23numberOfSelectedColumnsySiAA8DatabaseCKFZ":{"name":"numberOfSelectedColumns(_:)","abstract":"

Returns the number of selected columns.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteAllySiAA8DatabaseCKFZ":{"name":"deleteAll(_:)","abstract":"

Deletes all records; returns the number of deleted rows.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6exists_3keySbAA8DatabaseC_qd__tKAA0F16ValueConvertibleRd__lFZ":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6exists_3keySbAA8DatabaseC_SDySSAA0F16ValueConvertible_pSgGtKFZ":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this unique key (primary key or any key","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteAll_4keysSiAA8DatabaseC_qd__tKSTRd__AA0G16ValueConvertible7ElementRpd__lFZ":{"name":"deleteAll(_:keys:)","abstract":"

Delete records identified by their primary keys; returns the number of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteOne_3keySbAA8DatabaseC_qd__SgtKAA0G16ValueConvertibleRd__lFZ":{"name":"deleteOne(_:key:)","abstract":"

Delete a record, identified by its primary key; returns whether a","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteAll_4keysSiAA8DatabaseC_SaySDySSAA0G16ValueConvertible_pSgGGtKFZ":{"name":"deleteAll(_:keys:)","abstract":"

Delete records identified by the provided unique keys (primary key or","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteOne_3keySbAA8DatabaseC_SDySSAA0G16ValueConvertible_pSgGtKFZ":{"name":"deleteOne(_:key:)","abstract":"

Delete a record, identified by a unique key (the primary key or any key","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9updateAll_10onConflict_SiAA8DatabaseC_AG0G10ResolutionOSgSayAA16ColumnAssignmentVGtKFZ":{"name":"updateAll(_:onConflict:_:)","abstract":"

Updates all records; returns the number of updated records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9updateAll_10onConflict__SiAA8DatabaseC_AG0G10ResolutionOSgAA16ColumnAssignmentVALdtKFZ":{"name":"updateAll(_:onConflict:_:_:)","abstract":"

Updates all records; returns the number of updated records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPA2A09EncodableC0RzrlE7request3forAA21QueryInterfaceRequestVy10RowDecoderQyd__Gqd___t06OriginjK0Qyd__RszAA11AssociationRd__lF":{"name":"request(for:)","abstract":"

Creates a request that fetches the associated record(s).

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE6filter2idAA21QueryInterfaceRequestVyxGAH_tFZ":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__7ElementQyd__AHRSlFZ":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE06selectH0AA21QueryInterfaceRequestVyAHGyFZ":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE6filter2idAA21QueryInterfaceRequestVyxGAL_tFZ":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__AaI7ElementRpd__AlSRSlFZ":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE06selectG0AA21QueryInterfaceRequestVyALGyFZ":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE6exists_2idSbAA0E0C_AHtKFZ":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE6exists_2idSbAA0H0C_ALtKFZ":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE9deleteAll_3idsSiAA0E0C_qd__tKSlRd__7ElementQyd__AHRSlFZ":{"name":"deleteAll(_:ids:)","abstract":"

Delete records identified by their primary keys; returns the number of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE9deleteOne_2idSbAA0E0C_AHtKFZ":{"name":"deleteOne(_:id:)","abstract":"

Delete a record, identified by its primary key; returns whether a","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE9deleteAll_3idsSiAA0H0C_qd__tKSlRd__AaI7ElementRpd__AlRRSlFZ":{"name":"deleteAll(_:ids:)","abstract":"

Delete records identified by their primary keys; returns the number of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE9deleteOne_2idSbAA0H0C_ALtKFZ":{"name":"deleteOne(_:id:)","abstract":"

Delete a record, identified by its primary key; returns whether a","parent_name":"TableRecord"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestP08databaseB4NameSSvp":{"name":"databaseTableName","abstract":"

The name of the database table

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestP7aliasedyxAA0B5AliasCF":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzrlE8matchingyxAA11FTS3PatternVSgF":{"name":"matching(_:)","abstract":"

Creates a request with a full-text predicate added to the eventual","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter3keyxqd__Sg_tAA24DatabaseValueConvertibleRd__lF":{"name":"filter(key:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter4keysxqd___tSTRd__AA24DatabaseValueConvertible7ElementRpd__lF":{"name":"filter(keys:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter3keyxSDySSAA24DatabaseValueConvertible_pSgGSg_tF":{"name":"filter(key:)","abstract":"

Creates a request filtered by unique key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter4keysxSaySDySSAA24DatabaseValueConvertible_pSgGG_tF":{"name":"filter(keys:)","abstract":"

Creates a request filtered by unique key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA24DatabaseValueConvertibleAgH_2IDRPzrlE6filter2idxAL_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA24DatabaseValueConvertibleAgH_2IDRPzrlE6filter3idsxqd___tSlRd__AaJ7ElementRpd__AlPRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA17_OptionalProtocolAgH_2IDRPzAA24DatabaseValueConvertibleAgH_AK7WrappedAaJPRPzrlE6filter2idxAP_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA17_OptionalProtocolAgH_2IDRPzAA24DatabaseValueConvertibleAgH_AK7WrappedAaJPRPzrlE6filter3idsxqd___tSlRd__AaM7ElementRpd__ApTRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A07OrderedC0RzrlE17orderByPrimaryKeyxyF":{"name":"orderByPrimaryKey()","abstract":"

Creates a request ordered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A011AggregatingC0RzrlE17groupByPrimaryKeyxyF":{"name":"groupByPrimaryKey()","abstract":"

Creates a request grouped by primary key.

","parent_name":"TableRequest"},"Protocols/FTS5WrapperTokenizer.html#/wrappedTokenizer":{"name":"wrappedTokenizer","abstract":"

The wrapped tokenizer

","parent_name":"FTS5WrapperTokenizer"},"Protocols/FTS5WrapperTokenizer.html#/accept(token:flags:for:tokenCallback:)":{"name":"accept(token:flags:for:tokenCallback:)","abstract":"

Given a token produced by the wrapped tokenizer, notifies customized","parent_name":"FTS5WrapperTokenizer"},"Protocols/FTS5WrapperTokenizer.html#/tokenize(context:tokenization:pText:nText:tokenCallback:)":{"name":"tokenize(context:tokenization:pText:nText:tokenCallback:)","abstract":"

Default implementation

","parent_name":"FTS5WrapperTokenizer"},"Protocols/FTS5Tokenizer.html#/tokenize(context:tokenization:pText:nText:tokenCallback:)":{"name":"tokenize(context:tokenization:pText:nText:tokenCallback:)","abstract":"

Tokenizes the text described by pText and nText, and","parent_name":"FTS5Tokenizer"},"Protocols/FTS5Tokenizer.html#/tokenize(document:)":{"name":"tokenize(document:)","abstract":"

Tokenizes the string argument as a document that would be inserted into","parent_name":"FTS5Tokenizer"},"Protocols/FTS5Tokenizer.html#/tokenize(query:)":{"name":"tokenize(query:)","abstract":"

Tokenizes the string argument as an FTS5 query.

","parent_name":"FTS5Tokenizer"},"Protocols/FTS5CustomTokenizer.html#/name":{"name":"name","abstract":"

The name of the tokenizer; should uniquely identify your custom","parent_name":"FTS5CustomTokenizer"},"Protocols/FTS5CustomTokenizer.html#/init(db:arguments:)":{"name":"init(db:arguments:)","abstract":"

Creates a custom tokenizer.

","parent_name":"FTS5CustomTokenizer"},"Protocols/FTS5CustomTokenizer.html#/tokenizerDescriptor(arguments:)":{"name":"tokenizerDescriptor(arguments:)","abstract":"

Creates an FTS5 tokenizer descriptor.

","parent_name":"FTS5CustomTokenizer"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP8observes12eventsOfKindSbAA013DatabaseEventG0O_tF":{"name":"observes(eventsOfKind:)","abstract":"

Filters database changes that should be notified the the","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP17databaseDidChange4withyAA13DatabaseEventV_tF":{"name":"databaseDidChange(with:)","abstract":"

Notifies a database change (insert, update, or delete).

","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP18databaseWillCommityyKF":{"name":"databaseWillCommit()","abstract":"

When a transaction is about to be committed, the transaction observer","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP17databaseDidCommityyAA8DatabaseCF":{"name":"databaseDidCommit(_:)","abstract":"

Database changes have been committed.

","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP19databaseDidRollbackyyAA8DatabaseCF":{"name":"databaseDidRollback(_:)","abstract":"

Database changes have been rollbacked.

","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/databaseWillChange(with:)":{"name":"databaseWillChange(with:)","abstract":"

Notifies before a database change (insert, update, or delete)","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverPAAE037stopObservingDatabaseChangesUntilNextB0yyF":{"name":"stopObservingDatabaseChangesUntilNextTransaction()","abstract":"

After this method has been called, the databaseDidChange(with:)","parent_name":"TransactionObserver"},"Protocols/SQLExpressible.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","abstract":"

Returns an SQL expression.

","parent_name":"SQLExpressible"},"Protocols/SQLExpressible.html#/s:4GRDB14SQLExpressiblePAASYRzAaB8RawValueSYRpzrlE13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"SQLExpressible"},"Protocols/SQLExpressible.html#/s:4GRDB14SQLExpressiblePA2A6ColumnVRszrlE5rowIDAEvpZ":{"name":"rowID","abstract":"

The hidden rowID column

","parent_name":"SQLExpressible"},"Protocols/SQLOrderingTerm.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","abstract":"

Returns an SQL ordering.

","parent_name":"SQLOrderingTerm"},"Protocols/SQLSelectable.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","abstract":"

Returns an SQL selection.

","parent_name":"SQLSelectable"},"Protocols/StatementColumnConvertible.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Initializes a value from a raw SQLite statement pointer, if possible.

","parent_name":"StatementColumnConvertible"},"Protocols/StatementBinding.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","abstract":"

Binds a statement argument.

","parent_name":"StatementBinding"},"Protocols/RowAdapter.html#/s:4GRDB10RowAdapterPAAE12addingScopesyAaB_pSDySSAaB_pGF":{"name":"addingScopes(_:)","abstract":"

Returns an adapter based on self, with added scopes.

","parent_name":"RowAdapter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP5writeyqd__qd__AA0B0CKXEKlF":{"name":"write(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP10asyncWrite_10completionyqd__AA0B0CKc_yAG_s6ResultOyqd__s5Error_pGtctlF":{"name":"asyncWrite(_:completion:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","abstract":"

Concurrently executes a read-only block in a protected dispatch queue.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE3add19transactionObserver6extentyAA011TransactionF0_p_AA0B0C0H17ObservationExtentOtF":{"name":"add(transactionObserver:extent:)","abstract":"

Add a transaction observer, so that it gets notified of","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE6remove19transactionObserveryAA011TransactionF0_p_tF":{"name":"remove(transactionObserver:)","abstract":"

Undocumented

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE5eraseyyKF":{"name":"erase()","abstract":"

Erases the content of the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE6vacuumyyKF":{"name":"vacuum()","abstract":"

Rebuilds the database file, repacking it into a minimal amount of","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/vacuum(into:)":{"name":"vacuum(into:)","abstract":"

Creates a new database file at the specified path with a minimum","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE6vacuum4intoySS_tKF":{"name":"vacuum(into:)","abstract":"

Creates a new database file at the specified path with a minimum","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher7updatesAA0B10PublishersO5WriteVy_qd__Gqd__AA0B0CKc_tlF":{"name":"writePublisher(updates:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher9receiveOn7updatesAA0B10PublishersO5WriteVy_qd_0_Gqd___qd_0_AA0B0CKct7Combine9SchedulerRd__r0_lF":{"name":"writePublisher(receiveOn:updates:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher7updates8thenReadAA0B10PublishersO5WriteVy_qd_0_Gqd__AA0B0CKc_qd_0_AM_qd__tKctr0_lF":{"name":"writePublisher(updates:thenRead:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher9receiveOn7updates8thenReadAA0B10PublishersO5WriteVy_qd_1_Gqd___qd_0_AA0B0CKcqd_1_AN_qd_0_tKct7Combine9SchedulerRd__r1_lF":{"name":"writePublisher(receiveOn:updates:thenRead:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestP10RowDecoderQa":{"name":"RowDecoder","abstract":"

The type that tells how fetched database rows should be interpreted.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","abstract":"

Returns a PreparedRequest that is ready to be executed.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","abstract":"

Returns the number of rows fetched by the request.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPAAE14databaseRegionyAA08DatabaseE0VAA0F0CKF":{"name":"databaseRegion(_:)","abstract":"

Returns the database region that the request feeds from.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPAAE7adaptedyAA07AdaptedbC0VyxGAA10RowAdapter_pAA8DatabaseCKcF":{"name":"adapted(_:)","abstract":"

Returns an adapted request.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzrlE11fetchCursoryAA0deJ0CyAFGAA0D0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzrlE8fetchAllySayAFGAA0D0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzrlE8fetchOneyAFSgAA0D0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzSHAFRQrlE8fetchSetyShyAFGAA0D0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzrlE11fetchCursoryAA08NullablehiM0CyAIGAA0H0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzrlE8fetchAllySayAISgGAA0H0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzrlE8fetchOneyAISgAA0H0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzSHAIRQrlE8fetchSetyShyAISgGAA0H0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE11fetchCursoryAA0dG0CAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched rows.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE8fetchAllySayAEGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched rows.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE8fetchSetyShyAEGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched rows.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE8fetchOneyAESgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first fetched row.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQrlE11fetchCursoryAA04FastdeL0CyAFGAA0D0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQrlE8fetchAllySayAFGAA0D0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQrlE8fetchOneyAFSgAA0D0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQSHAFRQrlE8fetchSetyShyAFGAA0D0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQrlE11fetchCursoryAA012FastNullablehiO0CyAIGAA0H0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQrlE8fetchAllySayAISgGAA0H0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQrlE8fetchOneyAISgAA0H0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQSHAIRQrlE8fetchSetyShyAISgGAA0H0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzrlE11fetchCursoryAA0eI0CyAFGAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched records.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzrlE8fetchAllySayAFGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched records.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzrlE8fetchOneyAFSgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first fetched record.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzSHAFRQrlE8fetchSetyShyAFGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched records.

","parent_name":"FetchRequest"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a value initialized from dbValue, if possible.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE11fetchCursor_9arguments7adapterAA0bcF0CyxGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchAll_9arguments7adapterSayxGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchOne_9arguments7adapterxSgAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single value fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE11fetchCursor_3sql9arguments7adapterAA0bcF0CyxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchAll_3sql9arguments7adapterSayxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchOne_3sql9arguments7adapterxSgAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single value fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE11fetchCursoryAA0bcF0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchAllySayxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchOneyxSgAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single value fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAASHRzrlE8fetchSet_9arguments7adapterShyxGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAASHRzrlE8fetchSet_3sql9arguments7adapterShyxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAASHRzrlE8fetchSetyShyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE11fetchCursor_9arguments7adapterAA04FastbcH0CyxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchAll_9arguments7adapterSayxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchOne_9arguments7adapterxSgAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single value fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzSHRzrlE8fetchSet_9arguments7adapterShyxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE11fetchCursor_3sql9arguments7adapterAA04FastbcH0CyxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchAll_3sql9arguments7adapterSayxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchOne_3sql9arguments7adapterxSgAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single value fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzSHRzrlE8fetchSet_3sql9arguments7adapterShyxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE11fetchCursoryAA04FastbcH0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchAllySayxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchOneyxSgAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single value fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzSHRzrlE8fetchSetyShyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAA10Foundation09ReferenceD0RzAaB0F4TypeAdEPRpzrlE08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAA10Foundation09ReferenceD0RzAaB0F4TypeAdEPRpzrlE04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseRegionConvertible.html#/s:4GRDB25DatabaseRegionConvertibleP08databaseC0yAA0bC0VAA0B0CKF":{"name":"databaseRegion(_:)","abstract":"

Returns a database region.

","parent_name":"DatabaseRegionConvertible"},"Protocols/DatabaseRegionConvertible.html#/s:4GRDB25DatabaseRegionConvertiblePA2A0bC0VRszrlE04fullB0AEvpZ":{"name":"fullDatabase","abstract":"

The region that covers the full database: all columns and all rows","parent_name":"DatabaseRegionConvertible"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","abstract":"

Closes the database connection with the sqlite3_close() function.

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","abstract":"

This method causes any pending database operation to abort and return at","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","abstract":"

Synchronously executes a read-only function that accepts a database","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","abstract":"

Asynchronously executes a read-only function that accepts a","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","abstract":"

Synchronously executes a function that accepts a database","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","abstract":"

Synchronously executes a function that accepts a database","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderPAAE6backup2toyAA0B6Writer_p_tKF":{"name":"backup(to:)","abstract":"

Copies the database contents into another database.

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderPAAE13readPublisher5valueAA0B10PublishersO4ReadVy_qd__Gqd__AA0B0CKc_tlF":{"name":"readPublisher(value:)","abstract":"

Returns a Publisher that asynchronously completes with a fetched value.

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderPAAE13readPublisher9receiveOn5valueAA0B10PublishersO4ReadVy_qd_0_Gqd___qd_0_AA0B0CKct7Combine9SchedulerRd__r0_lF":{"name":"readPublisher(receiveOn:value:)","abstract":"

Returns a Publisher that asynchronously completes with a fetched value.

","parent_name":"DatabaseReader"},"Protocols/DatabaseAggregate.html#/s:4GRDB17DatabaseAggregatePxycfc":{"name":"init()","abstract":"

Creates an aggregate.

","parent_name":"DatabaseAggregate"},"Protocols/DatabaseAggregate.html#/s:4GRDB17DatabaseAggregateP4stepyySayAA0B5ValueVGKF":{"name":"step(_:)","abstract":"

This method is called at each step of the aggregation.

","parent_name":"DatabaseAggregate"},"Protocols/DatabaseAggregate.html#/s:4GRDB17DatabaseAggregateP8finalizeAA0B16ValueConvertible_pSgyKF":{"name":"finalize()","abstract":"

Returns the final result

","parent_name":"DatabaseAggregate"},"Protocols/Cursor.html#/s:4GRDB6CursorP7ElementQa":{"name":"Element","abstract":"

The type of element traversed by the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","abstract":"

Advances to the next element and returns it, or nil if no next element","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7isEmptySbyKF":{"name":"isEmpty()","abstract":"

Returns a Boolean value indicating whether the cursor contains","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE8contains5whereS2b7ElementQzKXE_tKF":{"name":"contains(where:)","abstract":"

Returns a Boolean value indicating whether the cursor contains an","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE10enumeratedAA010EnumeratedB0CyxGyF":{"name":"enumerated()","abstract":"

Returns a cursor of pairs (n, x), where n represents a consecutive","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6filteryAA06FilterB0CyxGSb7ElementQzKcF":{"name":"filter(_:)","abstract":"

Returns the elements of the cursor that satisfy the given predicate.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE5first5where7ElementQzSgSbAGKXE_tKF":{"name":"first(where:)","abstract":"

Returns the first element of the cursor that satisfies the given","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE10compactMapyAA0dB0CyAA06FilterB0CyAFyxqd__SgGGqd__GAI7ElementQzKclF":{"name":"compactMap(_:)","abstract":"

Returns a cursor over the concatenated non-nil results of mapping","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE4drop5whileAA09DropWhileB0CyxGSb7ElementQzKc_tF":{"name":"drop(while:)","abstract":"

Returns a cursor that skips any initial elements that satisfy","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE9dropFirstyAA04DropdB0CyxGSiF":{"name":"dropFirst(_:)","abstract":"

Returns a cursor containing all but the given number of initial","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE9dropFirstAA04DropdB0CyxGyF":{"name":"dropFirst()","abstract":"

Returns a cursor containing all but the first element of the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE8dropLastySay7ElementQzGSiKF":{"name":"dropLast(_:)","abstract":"

Returns an array containing all but the given number of final","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE8dropLastSay7ElementQzGyKF":{"name":"dropLast()","abstract":"

Returns an array containing all but the last element of the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7flatMapyAA07FlattenB0CyAA0dB0CyxAA03AnyB0Cy7ElementQyd__GGGqd__AKQzKcSTRd__lF":{"name":"flatMap(_:)","abstract":"

Returns a cursor over the concatenated results of mapping transform","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7flatMapyAA07FlattenB0CyAA0dB0Cyxqd__GGqd__7ElementQzKcAaBRd__lF":{"name":"flatMap(_:)","abstract":"

Returns a cursor over the concatenated results of mapping transform","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7forEachyyy7ElementQzKXEKF":{"name":"forEach(_:)","abstract":"

Calls the given closure on each element in the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE3mapyAA03MapB0Cyxqd__Gqd__7ElementQzKclF":{"name":"map(_:)","abstract":"

Returns a cursor over the results of the transform function applied to","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE3max2by7ElementQzSgSbAG_AGtKXE_tKF":{"name":"max(by:)","abstract":"

Returns the maximum element in the cursor, using the given predicate as","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE3min2by7ElementQzSgSbAG_AGtKXE_tKF":{"name":"min(by:)","abstract":"

Returns the minimum element in the cursor, using the given predicate as","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6prefixyAA06PrefixB0CyxGSiF":{"name":"prefix(_:)","abstract":"

Returns a cursor, up to the specified maximum length, containing the","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6prefix5whileAA011PrefixWhileB0CyxGSb7ElementQzKc_tF":{"name":"prefix(while:)","abstract":"

Returns a cursor of the initial consecutive elements that satisfy","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6reduceyqd__qd___qd__qd___7ElementQztKXEtKlF":{"name":"reduce(_:_:)","abstract":"

Returns the result of calling the given combining closure with each","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6reduce4into_qd__qd___yqd__z_7ElementQztKXEtKlF":{"name":"reduce(into:_:)","abstract":"

Returns the result of calling the given combining closure with each","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6suffixySay7ElementQzGSiKF":{"name":"suffix(_:)","abstract":"

Returns an array, up to the given maximum length, containing the","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASQ7ElementRpzrlE8containsySbAEKF":{"name":"contains(_:)","abstract":"

Returns a Boolean value indicating whether the cursor contains the","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASL7ElementRpzrlE3maxAESgyKF":{"name":"max()","abstract":"

Returns the maximum element in the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASL7ElementRpzrlE3minAESgyKF":{"name":"min()","abstract":"

Returns the minimum element in the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPA2aB7ElementRpzrlE6joinedAA07FlattenB0CyxGyF":{"name":"joined()","abstract":"

Returns the elements of this cursor of cursors, concatenated.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAST7ElementRpzrlE6joinedAA07FlattenB0CyAA03MapB0CyxAA03AnyB0CyAD_ADQZGGGyF":{"name":"joined()","abstract":"

Returns the elements of this cursor of sequences, concatenated.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASy7ElementRpzrlE6joined9separatorS2S_tKF":{"name":"joined(separator:)","abstract":"

Returns the elements of this cursor of sequences, concatenated.

","parent_name":"Cursor"},"Protocols/Cursor.html":{"name":"Cursor","abstract":"

A type that supplies the values of some external resource, one at a time.

"},"Protocols/DatabaseAggregate.html":{"name":"DatabaseAggregate","abstract":"

The protocol for custom SQLite aggregates.

"},"Protocols/DatabaseReader.html":{"name":"DatabaseReader","abstract":"

DatabaseReader is the protocol for all types that can fetch values from"},"Protocols/DatabaseRegionConvertible.html":{"name":"DatabaseRegionConvertible","abstract":"

DatabaseRegionConvertible is the protocol for values that can be turned"},"Protocols/DatabaseValueConvertible.html":{"name":"DatabaseValueConvertible","abstract":"

Types that adopt DatabaseValueConvertible can be initialized from"},"Protocols/FetchRequest.html":{"name":"FetchRequest","abstract":"

The protocol for all requests that fetch database rows, and tell how those"},"Protocols/DatabaseWriter.html":{"name":"DatabaseWriter","abstract":"

DatabaseWriter is the protocol for all types that can write into an"},"Protocols/RowAdapter.html":{"name":"RowAdapter","abstract":"

RowAdapter is a protocol that helps two incompatible row interfaces"},"Protocols/StatementBinding.html":{"name":"StatementBinding","abstract":"

Undocumented

"},"Protocols/StatementColumnConvertible.html":{"name":"StatementColumnConvertible","abstract":"

The StatementColumnConvertible protocol grants access to the low-level C"},"Protocols/SQLSelectable.html":{"name":"SQLSelectable","abstract":"

SQLSelectable is the protocol for types that can be selected, as"},"Protocols/SQLOrderingTerm.html":{"name":"SQLOrderingTerm","abstract":"

The protocol for all types that can be used as an SQL ordering term, as"},"Protocols/SQLExpressible.html":{"name":"SQLExpressible","abstract":"

SQLExpressible is the protocol for all types that can be used as an"},"Protocols/TransactionObserver.html":{"name":"TransactionObserver","abstract":"

A transaction observer is notified of all changes and transactions committed"},"Protocols/FTS5CustomTokenizer.html":{"name":"FTS5CustomTokenizer","abstract":"

The protocol for custom FTS5 tokenizers.

"},"Protocols/FTS5Tokenizer.html":{"name":"FTS5Tokenizer","abstract":"

The protocol for FTS5 tokenizers

"},"Protocols/FTS5WrapperTokenizer.html":{"name":"FTS5WrapperTokenizer","abstract":"

The protocol for custom FTS5 tokenizers that wrap another tokenizer.

"},"Protocols/TableRequest.html":{"name":"TableRequest","abstract":"

The protocol for all requests that feed from a database table

"},"Protocols/TableRecord.html":{"name":"TableRecord","abstract":"

Types that adopt TableRecord declare a particular relationship with"},"Protocols/ColumnExpression.html":{"name":"ColumnExpression","abstract":"

Adopt the ColumnExpression protocol when you define a column type.

"},"Protocols/Association.html":{"name":"Association","abstract":"

The base protocol for all associations that define a connection between two"},"Protocols/AssociationToOne.html":{"name":"AssociationToOne","abstract":"

The base protocol for all associations that define a one-to-one connection.

"},"Protocols/AssociationToMany.html":{"name":"AssociationToMany","abstract":"

The base protocol for all associations that define a one-to-many connection.

"},"Protocols/TypedRequest.html":{"name":"TypedRequest","abstract":"

The protocol for all requests that know how database rows should"},"Protocols/SelectionRequest.html":{"name":"SelectionRequest","abstract":"

The protocol for all requests that can refine their selection.

"},"Protocols/FilteredRequest.html":{"name":"FilteredRequest","abstract":"

The protocol for all requests that can be filtered.

"},"Protocols/AggregatingRequest.html":{"name":"AggregatingRequest","abstract":"

The protocol for all requests that can aggregate.

"},"Protocols/OrderedRequest.html":{"name":"OrderedRequest","abstract":"

The protocol for all requests that can be ordered.

"},"Protocols/JoinableRequest.html":{"name":"JoinableRequest","abstract":"

The protocol for all requests that can be associated.

"},"Protocols/DerivableRequest.html":{"name":"DerivableRequest","abstract":"

The base protocol for all requests that can be refined.

"},"Protocols/SQLSpecificExpressible.html":{"name":"SQLSpecificExpressible","abstract":"

SQLSpecificExpressible is a protocol for all database-specific types that"},"Protocols/SQLSubqueryable.html":{"name":"SQLSubqueryable","abstract":"

The protocol for types that can be embedded as a subquery.

"},"Protocols/VirtualTableModule.html":{"name":"VirtualTableModule","abstract":"

The protocol for SQLite virtual table modules. It lets you define a DSL for"},"Protocols/EncodableRecord.html":{"name":"EncodableRecord","abstract":"

Types that adopt EncodableRecord can be encoded into the database.

"},"Protocols/FetchableRecord.html":{"name":"FetchableRecord","abstract":"

Types that adopt FetchableRecord can be initialized from a database Row.

"},"Protocols/MutablePersistableRecord.html":{"name":"MutablePersistableRecord","abstract":"

Types that adopt MutablePersistableRecord can be inserted, updated,"},"Protocols/PersistableRecord.html":{"name":"PersistableRecord","abstract":"

Types that adopt PersistableRecord can be inserted, updated, and deleted.

"},"Protocols/DatabaseCancellable.html":{"name":"DatabaseCancellable","abstract":"

A protocol indicating that an activity or action supports cancellation.

"},"Protocols.html#/s:4GRDB12ValueReducerP":{"name":"ValueReducer","abstract":"

The ValueReducer protocol supports ValueObservation.

"},"Functions.html#/s:4GRDB20splittingRowAdapters12columnCountsSayAA0C7Adapter_pGSaySiG_tF":{"name":"splittingRowAdapters(columnCounts:)","abstract":"

Returns an array of row adapters that split a row according to the input"},"Functions.html#/s:4GRDB1nopyAA20AssociationAggregateVyxGAElF":{"name":"!(_:)","abstract":"

Returns a logically negated aggregate.

"},"Functions.html#/s:4GRDB2aaoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"&&(_:_:)","abstract":"

Groups two aggregates with the AND SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"||(_:_:)","abstract":"

Groups two aggregates with the OR SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAE_SbtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGSb_AEtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAE_SbtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGSb_AEtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB3eeeoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"===(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"===(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"===(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"!==(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"!==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"!==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"<=(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"<=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"<=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <= SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"<(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"<(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"<(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the < SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":">(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":">(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":">(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the > SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":">=(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":">=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":">=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the >= SQL operator.

"},"Functions.html#/s:4GRDB1sopyAA20AssociationAggregateVyxGAElF":{"name":"-(_:)","abstract":"

Returns an arithmetically negated aggregate.

"},"Functions.html#/s:4GRDB1poiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"+(_:_:)","abstract":"

Returns an aggregate that sums two aggregates with the + SQL operator.

"},"Functions.html#/s:4GRDB1poiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"+(_:_:)","abstract":"

Returns an aggregate that sums an aggregate with the + SQL operator.

"},"Functions.html#/s:4GRDB1poiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"+(_:_:)","abstract":"

Returns an aggregate that sums an aggregate with the + SQL operator.

"},"Functions.html#/s:4GRDB1soiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"-(_:_:)","abstract":"

Returns an aggregate that substracts two aggregates with the - SQL operator.

"},"Functions.html#/s:4GRDB1soiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"-(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the - SQL operator.

"},"Functions.html#/s:4GRDB1soiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"-(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the - SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"*(_:_:)","abstract":"

Returns an aggregate that multiplies two aggregates with the * SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"*(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the * SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"*(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the * SQL operator.

"},"Functions.html#/s:4GRDB1doiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"/(_:_:)","abstract":"

Returns an aggregate that multiplies two aggregates with the / SQL operator.

"},"Functions.html#/s:4GRDB1doiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"/(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the / SQL operator.

"},"Functions.html#/s:4GRDB1doiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"/(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the / SQL operator.

"},"Functions.html#/s:4GRDB2qqoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"??(_:_:)","abstract":"

Returns an aggregate that evaluates the IFNULL SQL function.

"},"Functions.html#/s:4GRDB2peoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"+=(_:_:)","abstract":"

Creates an assignment that adds a value

"},"Functions.html#/s:4GRDB2seoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"-=(_:_:)","abstract":"

Creates an assignment that subtracts a value

"},"Functions.html#/s:4GRDB2meoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"*=(_:_:)","abstract":"

Creates an assignment that multiplies by a value

"},"Functions.html#/s:4GRDB2deoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"/=(_:_:)","abstract":"

Creates an assignment that divides by a value

"},"Functions.html#/s:4GRDB3absyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"abs(_:)","abstract":"

Returns an expression that evaluates the ABS SQL function.

"},"Functions.html#/s:4GRDB7averageyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"average(_:)","abstract":"

Returns an expression that evaluates the AVG SQL function.

"},"Functions.html#/s:4GRDB5countyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"count(_:)","abstract":"

Returns an expression that evaluates the COUNT SQL function.

"},"Functions.html#/s:4GRDB5count8distinctAA13SQLExpressionVAA22SQLSpecificExpressible_p_tF":{"name":"count(distinct:)","abstract":"

Returns an expression that evaluates the COUNT(DISTINCT) SQL function.

"},"Functions.html#/s:4GRDB2qqoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"??(_:_:)","abstract":"

Returns an expression that evaluates the IFNULL SQL function.

"},"Functions.html#/s:4GRDB6lengthyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"length(_:)","abstract":"

Returns an expression that evaluates the LENGTH SQL function.

"},"Functions.html#/s:4GRDB3maxyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"max(_:)","abstract":"

Returns an expression that evaluates the MAX SQL function.

"},"Functions.html#/s:4GRDB3minyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"min(_:)","abstract":"

Returns an expression that evaluates the MIN SQL function.

"},"Functions.html#/s:4GRDB3sumyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"sum(_:)","abstract":"

Returns an expression that evaluates the SUM SQL function.

"},"Functions.html#/s:4GRDB9julianDayyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA15SQLDateModifierOdtF":{"name":"julianDay(_:_:)","abstract":"

Returns an expression that evaluates the JULIANDAY SQL function.

"},"Functions.html#/s:4GRDB8dateTimeyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA15SQLDateModifierOdtF":{"name":"dateTime(_:_:)","abstract":"

Returns an expression that evaluates the DATETIME SQL function.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"==(_:_:)","abstract":"

An SQL expression that compares two expressions with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_SbtF":{"name":"==(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"==(_:_:)","abstract":"

An SQL expression that compares two expressions with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVSb_AA22SQLSpecificExpressible_ptF":{"name":"==(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"==(_:_:)","abstract":"

An SQL expression that compares two expressions with the = SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"!=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_SbtF":{"name":"!=(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"!=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVSb_AA22SQLSpecificExpressible_ptF":{"name":"!=(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"!=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <> SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"===(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"===(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"===(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"!==(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"!==(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"!==(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"<(_:_:)","abstract":"

An SQL expression that compares two expressions with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"<(_:_:)","abstract":"

An SQL expression that compares two expressions with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"<(_:_:)","abstract":"

An SQL expression that compares two expressions with the < SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"<=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"<=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"<=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <= SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":">(_:_:)","abstract":"

An SQL expression that compares two expressions with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":">(_:_:)","abstract":"

An SQL expression that compares two expressions with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":">(_:_:)","abstract":"

An SQL expression that compares two expressions with the > SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":">=(_:_:)","abstract":"

An SQL expression that compares two expressions with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":">=(_:_:)","abstract":"

An SQL expression that compares two expressions with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":">=(_:_:)","abstract":"

An SQL expression that compares two expressions with the >= SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"*(_:_:)","abstract":"

An SQL arithmetic multiplication.

"},"Functions.html#/s:4GRDB1moiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"*(_:_:)","abstract":"

An SQL arithmetic multiplication.

"},"Functions.html#/s:4GRDB1moiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"*(_:_:)","abstract":"

An SQL arithmetic multiplication.

"},"Functions.html#/s:4GRDB1doiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"/(_:_:)","abstract":"

An SQL arithmetic division.

"},"Functions.html#/s:4GRDB1doiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"/(_:_:)","abstract":"

An SQL arithmetic division.

"},"Functions.html#/s:4GRDB1doiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"/(_:_:)","abstract":"

An SQL arithmetic division.

"},"Functions.html#/s:4GRDB1poiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"+(_:_:)","abstract":"

An SQL arithmetic addition.

"},"Functions.html#/s:4GRDB1poiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"+(_:_:)","abstract":"

An SQL arithmetic addition.

"},"Functions.html#/s:4GRDB1poiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"+(_:_:)","abstract":"

An SQL arithmetic addition.

"},"Functions.html#/s:4GRDB1sopyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"-(_:)","abstract":"

A negated SQL arithmetic expression.

"},"Functions.html#/s:4GRDB1soiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"-(_:_:)","abstract":"

An SQL arithmetic substraction.

"},"Functions.html#/s:4GRDB1soiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"-(_:_:)","abstract":"

An SQL arithmetic substraction.

"},"Functions.html#/s:4GRDB1soiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"-(_:_:)","abstract":"

An SQL arithmetic substraction.

"},"Functions.html#/s:4GRDB2aaoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"&&(_:_:)","abstract":"

A logical SQL expression with the AND SQL operator.

"},"Functions.html#/s:4GRDB2aaoiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"&&(_:_:)","abstract":"

A logical SQL expression with the AND SQL operator.

"},"Functions.html#/s:4GRDB2aaoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"&&(_:_:)","abstract":"

A logical SQL expression with the AND SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"||(_:_:)","abstract":"

A logical SQL expression with the OR SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"||(_:_:)","abstract":"

A logical SQL expression with the OR SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"||(_:_:)","abstract":"

A logical SQL expression with the OR SQL operator.

"},"Functions.html#/s:4GRDB1nopyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"!(_:)","abstract":"

A negated logical SQL expression with the NOT SQL operator.

"},"Functions.html#/s:4GRDB21databaseQuestionMarks5countSSSi_tF":{"name":"databaseQuestionMarks(count:)","abstract":"

Return as many question marks separated with commas as the count argument.

"},"Extensions/CountableClosedRange.html#/s:SN4GRDBAA14SQLExpressibleRzSxRzSZ6StrideSxRpzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"CountableClosedRange"},"Extensions/CountableRange.html#/s:Sn4GRDBAA14SQLExpressibleRzSxRzSZ6StrideSxRpzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"CountableRange"},"Extensions/ClosedRange.html#/s:SN4GRDBAA14SQLExpressibleRzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"ClosedRange"},"Extensions/Range.html#/s:Sn4GRDBAA14SQLExpressibleRzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"Range"},"Extensions/ColumnExpression.html#/match(_:)":{"name":"match(_:)","abstract":"

A matching SQL expression with the MATCH SQL operator.

","parent_name":"ColumnExpression"},"Extensions/TableRecord.html#/matching(_:)":{"name":"matching(_:)","abstract":"

Returns a QueryInterfaceRequest with a matching predicate.

","parent_name":"TableRecord"},"Extensions/TableRequest.html#/matching(_:)":{"name":"matching(_:)","abstract":"

Creates a request with a full-text predicate added to the eventual","parent_name":"TableRequest"},"Extensions/Column.html#/rank":{"name":"rank","abstract":"

The FTS5 rank column

","parent_name":"Column"},"Extensions/String.html#/s:SS4GRDBE15sqliteStatement5indexSSs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"String"},"Extensions/String.html#/s:SS4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"String"},"Extensions/String.html#/s:SS4GRDBE17fromDatabaseValueySSSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a String initialized from dbValue, if possible.

","parent_name":"String"},"Extensions/String.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"String"},"Extensions/String.html#/s:SS4GRDBE24quotedDatabaseIdentifierSSvp":{"name":"quotedDatabaseIdentifier","abstract":"

Returns the receiver, quoted for safe insertion as an identifier in an","parent_name":"String"},"Extensions/Float.html#/s:Sf4GRDBE15sqliteStatement5indexSfs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Float"},"Extensions/Float.html#/s:Sf4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Float"},"Extensions/Float.html#/s:Sf4GRDBE17fromDatabaseValueySfSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Float initialized from dbValue, if possible.

","parent_name":"Float"},"Extensions/Float.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Float"},"Extensions/Double.html#/s:Sd4GRDBE15sqliteStatement5indexSds13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Double"},"Extensions/Double.html#/s:Sd4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Double"},"Extensions/Double.html#/s:Sd4GRDBE17fromDatabaseValueySdSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Double initialized from dbValue, if possible.

","parent_name":"Double"},"Extensions/Double.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Double"},"Extensions/UInt64.html#/s:s6UInt64V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt64"},"Extensions/UInt64.html#/s:s6UInt64V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt64"},"Extensions/UInt64.html#/s:s6UInt64V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt64 initialized from dbValue, if possible.

","parent_name":"UInt64"},"Extensions/UInt64.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt64"},"Extensions/UInt32.html#/s:s6UInt32V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt32"},"Extensions/UInt32.html#/s:s6UInt32V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt32"},"Extensions/UInt32.html#/s:s6UInt32V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt32 initialized from dbValue, if possible.

","parent_name":"UInt32"},"Extensions/UInt32.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt32"},"Extensions/UInt16.html#/s:s6UInt16V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt16"},"Extensions/UInt16.html#/s:s6UInt16V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt16"},"Extensions/UInt16.html#/s:s6UInt16V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt16 initialized from dbValue, if possible.

","parent_name":"UInt16"},"Extensions/UInt16.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt16"},"Extensions/UInt8.html#/s:s5UInt8V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt8"},"Extensions/UInt8.html#/s:s5UInt8V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt8"},"Extensions/UInt8.html#/s:s5UInt8V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt8 initialized from dbValue, if possible.

","parent_name":"UInt8"},"Extensions/UInt8.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt8"},"Extensions/UInt.html#/s:Su4GRDBE15sqliteStatement5indexSuSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt"},"Extensions/UInt.html#/s:Su4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt"},"Extensions/UInt.html#/s:Su4GRDBE17fromDatabaseValueySuSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int initialized from dbValue, if possible.

","parent_name":"UInt"},"Extensions/UInt.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt"},"Extensions/Int64.html#/s:s5Int64V4GRDBE15sqliteStatement5indexABs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int64"},"Extensions/Int64.html#/s:s5Int64V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int64"},"Extensions/Int64.html#/s:s5Int64V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int64 initialized from dbValue, if possible.

","parent_name":"Int64"},"Extensions/Int64.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int64"},"Extensions/Int32.html#/s:s5Int32V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_ABtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int32"},"Extensions/Int32.html#/s:s5Int32V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int32"},"Extensions/Int32.html#/s:s5Int32V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int32 initialized from dbValue, if possible.

","parent_name":"Int32"},"Extensions/Int32.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int32"},"Extensions/Int16.html#/s:s5Int16V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int16"},"Extensions/Int16.html#/s:s5Int16V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int16"},"Extensions/Int16.html#/s:s5Int16V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int16 initialized from dbValue, if possible.

","parent_name":"Int16"},"Extensions/Int16.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int16"},"Extensions/Int8.html#/s:s4Int8V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int8"},"Extensions/Int8.html#/s:s4Int8V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int8"},"Extensions/Int8.html#/s:s4Int8V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int8 initialized from dbValue, if possible.

","parent_name":"Int8"},"Extensions/Int8.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int8"},"Extensions/Int.html#/s:Si4GRDBE15sqliteStatement5indexSiSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int"},"Extensions/Int.html#/s:Si4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int"},"Extensions/Int.html#/s:Si4GRDBE17fromDatabaseValueySiSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int initialized from dbValue, if possible.

","parent_name":"Int"},"Extensions/Int.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int"},"Extensions/Bool.html#/s:Sb4GRDBE15sqliteStatement5indexSbs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Bool"},"Extensions/Bool.html#/s:Sb4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Bool"},"Extensions/Bool.html#/s:Sb4GRDBE17fromDatabaseValueySbSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Bool initialized from dbValue, if possible.

","parent_name":"Bool"},"Extensions/Bool.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Bool"},"Extensions/UUID.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"UUID"},"Extensions/UUID.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"UUID"},"Extensions/UUID.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","parent_name":"UUID"},"Extensions/NSUUID.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"NSUUID"},"Extensions/NSUUID.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"NSUUID"},"Extensions/NSURL.html#/s:So5NSURLC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.","parent_name":"NSURL"},"Extensions/NSURL.html#/s:So5NSURLC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSURL initialized from dbValue, if possible.

","parent_name":"NSURL"},"Extensions/NSString.html#/s:So8NSStringC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"NSString"},"Extensions/NSString.html#/s:So8NSStringC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSString initialized from dbValue, if possible.

","parent_name":"NSString"},"Extensions/NSNumber.html#/s:So8NSNumberC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"NSNumber"},"Extensions/NSNumber.html#/s:So8NSNumberC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSNumber initialized from dbValue, if possible.

","parent_name":"NSNumber"},"Extensions/NSNull.html#/s:So6NSNullC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns DatabaseValue.null.

","parent_name":"NSNull"},"Extensions/NSNull.html#/s:So6NSNullC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns nil.

","parent_name":"NSNull"},"Extensions/NSData.html#/s:So6NSDataC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"NSData"},"Extensions/NSData.html#/s:So6NSDataC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSData initialized from dbValue, if it contains","parent_name":"NSData"},"Extensions/Decimal.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"Decimal"},"Extensions/Decimal.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"Decimal"},"Extensions/Decimal.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","parent_name":"Decimal"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE13databaseValueAD08DatabaseE0Vvp":{"name":"databaseValue","abstract":"

Returns a database value that contains the date encoded as","parent_name":"Date"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE17fromDatabaseValueyACSgAD0eF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a date initialized from dbValue, if possible.

","parent_name":"Date"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE9julianDayACSgSd_tcfc":{"name":"init(julianDay:)","abstract":"

Creates a date from a Julian Day.

","parent_name":"Date"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE15sqliteStatement5indexACSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Date"},"Extensions/NSDate.html#/s:So6NSDateC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a database value that contains the date encoded as","parent_name":"NSDate"},"Extensions/NSDate.html#/s:So6NSDateC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a date initialized from dbValue, if possible.

","parent_name":"NSDate"},"Extensions/Data.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","parent_name":"Data"},"Extensions/Data.html#/s:10Foundation4DataV4GRDBE13databaseValueAD08DatabaseE0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Data"},"Extensions/Data.html#/s:10Foundation4DataV4GRDBE17fromDatabaseValueyACSgAD0eF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Data initialized from dbValue, if it contains","parent_name":"Data"},"Extensions/Data.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Data"},"Extensions/CGFloat.html#/s:12CoreGraphics7CGFloatV4GRDBE13databaseValueAD08DatabaseF0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"CGFloat"},"Extensions/CGFloat.html#/s:12CoreGraphics7CGFloatV4GRDBE17fromDatabaseValueyACSgAD0fG0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a CGFloat initialized from dbValue, if possible.

","parent_name":"CGFloat"},"Extensions/Collection.html#/s:Sl4GRDBAA3SQLV7ElementRtzrlE6joined9separatorACSS_tF":{"name":"joined(separator:)","abstract":"

Returns the concatenated SQL literal of this collection of literals,","parent_name":"Collection"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE11fetchCursor_9arguments7adapterAA08NullablebcF0CyxGAA9StatementC_AA0J9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE8fetchAll_9arguments7adapterSayxSgGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzSHRzlE8fetchSet_9arguments7adapterShyxSgGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE11fetchCursor_3sql9arguments7adapterAA08NullablebcF0CyxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE8fetchAll_3sql9arguments7adapterSayxSgGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzSHRzlE8fetchSet_3sql9arguments7adapterShyxSgGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE11fetchCursoryAA08NullablebcF0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE8fetchAllySayxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzSHRzlE8fetchSetyShyxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE11fetchCursor_9arguments7adapterAA012FastNullablebcH0CyxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE8fetchAll_9arguments7adapterSayxSgGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzSHRzlE8fetchSet_9arguments7adapterShyxSgGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE11fetchCursor_3sql9arguments7adapterAA012FastNullablebcH0CyxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE8fetchAll_3sql9arguments7adapterSayxSgGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzSHRzlE8fetchSet_3sql9arguments7adapterShyxSgGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE11fetchCursoryAA012FastNullablebcH0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE8fetchAllySayxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzSHRzlE8fetchSetyShyxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Database.html#/usePassphrase(_:)":{"name":"usePassphrase(_:)","abstract":"

Sets the passphrase used to crypt and decrypt an SQLCipher database.

","parent_name":"Database"},"Extensions/Database.html#/changePassphrase(_:)":{"name":"changePassphrase(_:)","abstract":"

Changes the passphrase used by an SQLCipher encrypted database.

","parent_name":"Database"},"Extensions/Database.html#/dropFTS5SynchronizationTriggers(forTable:)":{"name":"dropFTS5SynchronizationTriggers(forTable:)","abstract":"

Deletes the synchronization triggers for a synchronized FTS5 table

","parent_name":"Database"},"Extensions/Database.html#/add(tokenizer:)":{"name":"add(tokenizer:)","abstract":"

Add a custom FTS5 tokenizer.

","parent_name":"Database"},"Extensions/Database.html#/makeFTS5Pattern(rawPattern:forTable:)":{"name":"makeFTS5Pattern(rawPattern:forTable:)","abstract":"

Creates a pattern from a raw pattern string; throws DatabaseError on","parent_name":"Database"},"Extensions/Database.html#/makeTokenizer(_:)":{"name":"makeTokenizer(_:)","abstract":"

Creates an FTS5 tokenizer, given its descriptor.

","parent_name":"Database"},"Extensions/Sequence.html#/s:ST4GRDBE7flatMapyAA13FlattenCursorCyAA0cE0CyAA03AnyE0Cy7ElementQzGqd__GGqd__AJKcAA0E0Rd__lF":{"name":"flatMap(_:)","abstract":"

Returns a cursor over the concatenated results of mapping transform","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA3SQLV7ElementRtzrlE6joined9separatorACSS_tF":{"name":"joined(separator:)","abstract":"

Returns the concatenated SQL literal of this sequence of literals,","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA22SQLSpecificExpressible7ElementRpzrlE6joined8operatorAA13SQLExpressionVAH25AssociativeBinaryOperatorV_tF":{"name":"joined(operator:)","abstract":"

Returns an expression by joining all elements with an associative SQL","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA22SQLSpecificExpressible_p7ElementRtzrlE6joined8operatorAA13SQLExpressionVAH25AssociativeBinaryOperatorV_tF":{"name":"joined(operator:)","abstract":"

Returns an expression by joining all elements with an associative SQL","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA14SQLExpressible7ElementRpzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA14SQLExpressible_p7ElementRtzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in","parent_name":"Sequence"},"Extensions/Set.html#/s:Sh4GRDBEyShyxGqd__Kc7ElementQyd__RszAA6CursorRd__lufc":{"name":"init(_:)","abstract":"

Creates a set containing the elements of a cursor.

","parent_name":"Set"},"Extensions/Set.html#/s:Sh4GRDBE_15minimumCapacityShyxGqd___SitKc7ElementQyd__RszAA6CursorRd__lufc":{"name":"init(_:minimumCapacity:)","abstract":"

Creates a set containing the elements of a cursor.

","parent_name":"Set"},"Extensions/Dictionary.html#/s:SD4GRDBE8grouping2bySDyxSay7ElementQyd__GGqd___xAEKXEtKcAFRs_AA6CursorRd__lufc":{"name":"init(grouping:by:)","abstract":"

Creates a new dictionary whose keys are the groupings returned by the","parent_name":"Dictionary"},"Extensions/Dictionary.html#/s:SD4GRDBE15minimumCapacity8grouping2bySDyxSay7ElementQyd__GGSi_qd__xAFKXEtKcAGRs_AA6CursorRd__lufc":{"name":"init(minimumCapacity:grouping:by:)","abstract":"

Creates a new dictionary whose keys are the groupings returned by the","parent_name":"Dictionary"},"Extensions/Dictionary.html#/s:SD4GRDBE20uniqueKeysWithValuesSDyxq_Gqd___tKcAA6CursorRd__x_q_t7ElementRtd__lufc":{"name":"init(uniqueKeysWithValues:)","abstract":"

Creates a new dictionary from the key-value pairs in the given cursor.

","parent_name":"Dictionary"},"Extensions/Dictionary.html#/s:SD4GRDBE15minimumCapacity20uniqueKeysWithValuesSDyxq_GSi_qd__tKcAA6CursorRd__x_q_t7ElementRtd__lufc":{"name":"init(minimumCapacity:uniqueKeysWithValues:)","abstract":"

Creates a new dictionary from the key-value pairs in the given cursor.

","parent_name":"Dictionary"},"Extensions/RangeReplaceableCollection.html#/s:Sm4GRDBEyxqd__KcAA6CursorRd__7ElementQyd__ACRtzlufc":{"name":"init(_:)","abstract":"

Creates a collection containing the elements of a cursor.

","parent_name":"RangeReplaceableCollection"},"Extensions/RangeReplaceableCollection.html#/s:Sm4GRDBE_15minimumCapacityxqd___SitKcAA6CursorRd__7ElementQyd__ADRtzlufc":{"name":"init(_:minimumCapacity:)","abstract":"

Creates a collection containing the elements of a cursor.

","parent_name":"RangeReplaceableCollection"},"Extensions/RangeReplaceableCollection.html":{"name":"RangeReplaceableCollection"},"Extensions/Dictionary.html":{"name":"Dictionary"},"Extensions/Set.html":{"name":"Set"},"Extensions/Sequence.html":{"name":"Sequence"},"Extensions/Database.html":{"name":"Database"},"Extensions/Optional.html":{"name":"Optional","abstract":"

Swift’s Optional comes with built-in methods that allow to fetch cursors"},"Extensions/Collection.html":{"name":"Collection"},"Extensions/CGFloat.html":{"name":"CGFloat","abstract":"

CGFloat adopts DatabaseValueConvertible

"},"Extensions/Data.html":{"name":"Data","abstract":"

Data is convertible to and from DatabaseValue.

"},"Extensions/NSDate.html":{"name":"NSDate","abstract":"

NSDate is stored in the database using the format"},"Extensions/Date.html":{"name":"Date","abstract":"

Date is stored in the database using the format"},"Extensions/Decimal.html":{"name":"Decimal","abstract":"

Decimal adopts DatabaseValueConvertible

"},"Extensions/NSData.html":{"name":"NSData","abstract":"

NSData is convertible to and from DatabaseValue.

"},"Extensions/NSNull.html":{"name":"NSNull","abstract":"

NSNull adopts DatabaseValueConvertible

"},"Extensions/NSNumber.html":{"name":"NSNumber","abstract":"

NSNumber adopts DatabaseValueConvertible

"},"Extensions/NSString.html":{"name":"NSString","abstract":"

NSString adopts DatabaseValueConvertible

"},"Extensions/NSURL.html":{"name":"NSURL","abstract":"

NSURL stores its absoluteString in the database.

"},"Extensions.html#/s:10Foundation3URLV":{"name":"URL","abstract":"

URL stores its absoluteString in the database.

"},"Extensions/NSUUID.html":{"name":"NSUUID","abstract":"

NSUUID adopts DatabaseValueConvertible

"},"Extensions/UUID.html":{"name":"UUID","abstract":"

UUID adopts DatabaseValueConvertible

"},"Extensions/Bool.html":{"name":"Bool","abstract":"

Bool adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int.html":{"name":"Int","abstract":"

Int adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int8.html":{"name":"Int8","abstract":"

Int8 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int16.html":{"name":"Int16","abstract":"

Int16 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int32.html":{"name":"Int32","abstract":"

Int32 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int64.html":{"name":"Int64","abstract":"

Int64 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt.html":{"name":"UInt","abstract":"

UInt adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt8.html":{"name":"UInt8","abstract":"

UInt8 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt16.html":{"name":"UInt16","abstract":"

UInt16 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt32.html":{"name":"UInt32","abstract":"

UInt32 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt64.html":{"name":"UInt64","abstract":"

UInt64 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Double.html":{"name":"Double","abstract":"

Double adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Float.html":{"name":"Float","abstract":"

Float adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/String.html":{"name":"String","abstract":"

String adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Column.html":{"name":"Column"},"Extensions/TableRequest.html":{"name":"TableRequest"},"Extensions/TableRecord.html":{"name":"TableRecord"},"Extensions/ColumnExpression.html":{"name":"ColumnExpression"},"Extensions/Range.html":{"name":"Range"},"Extensions/ClosedRange.html":{"name":"ClosedRange"},"Extensions/CountableRange.html":{"name":"CountableRange"},"Extensions/CountableClosedRange.html":{"name":"CountableClosedRange"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO5FetchV":{"name":"Fetch","abstract":"

A reducer which passes raw fetched values through.

","parent_name":"ValueReducers"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO3MapV":{"name":"Map","abstract":"

A reducer whose values consist of those in a Base reducer","parent_name":"ValueReducers"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO16RemoveDuplicatesV":{"name":"RemoveDuplicates","abstract":"

See ValueObservation.removeDuplicates()

","parent_name":"ValueReducers"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO5TraceV":{"name":"Trace","abstract":"

See ValueObservation.handleEvents()

","parent_name":"ValueReducers"},"Enums/SharedValueObservationExtent.html#/s:4GRDB28SharedValueObservationExtentO19observationLifetimeyA2CmF":{"name":"observationLifetime","abstract":"

The SharedValueObservation starts a single database observation, which","parent_name":"SharedValueObservationExtent"},"Enums/SharedValueObservationExtent.html#/s:4GRDB28SharedValueObservationExtentO13whileObservedyA2CmF":{"name":"whileObserved","abstract":"

The SharedValueObservation ends database observation when the number","parent_name":"SharedValueObservationExtent"},"Enums/PersistenceError.html#/s:4GRDB16PersistenceErrorO14recordNotFoundyACSS_SDySSAA13DatabaseValueVGtcACmF":{"name":"recordNotFound(databaseTableName:key:)","abstract":"

Thrown by MutablePersistableRecord.update(_:) methods when no matching","parent_name":"PersistenceError"},"Enums/DatabaseColumnDecodingStrategy.html#/s:4GRDB30DatabaseColumnDecodingStrategyO14useDefaultKeysyA2CmF":{"name":"useDefaultKeys","abstract":"

A key decoding strategy that doesn’t change key names during decoding.

","parent_name":"DatabaseColumnDecodingStrategy"},"Enums/DatabaseColumnDecodingStrategy.html#/s:4GRDB30DatabaseColumnDecodingStrategyO20convertFromSnakeCaseyA2CmF":{"name":"convertFromSnakeCase","abstract":"

A key decoding strategy that converts snake-case keys to camel-case keys.

","parent_name":"DatabaseColumnDecodingStrategy"},"Enums/DatabaseColumnDecodingStrategy.html#/s:4GRDB30DatabaseColumnDecodingStrategyO6customyACs9CodingKey_pSSccACmF":{"name":"custom(_:)","abstract":"

A key decoding strategy defined by the closure you supply.

","parent_name":"DatabaseColumnDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO010deferredToC0yA2CmF":{"name":"deferredToDate","abstract":"

The strategy that uses formatting from the Date structure.

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO026timeIntervalSinceReferenceC0yA2CmF":{"name":"timeIntervalSinceReferenceDate","abstract":"

Decodes numeric values as a number of seconds between the date and","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO21timeIntervalSince1970yA2CmF":{"name":"timeIntervalSince1970","abstract":"

Decodes numeric values as a number of seconds between the date and","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO21millisecondsSince1970yA2CmF":{"name":"millisecondsSince1970","abstract":"

Decodes numeric values as a number of milliseconds between the date and","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO7iso8601yA2CmF":{"name":"iso8601","abstract":"

Decodes dates according to the ISO 8601 standards

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO9formattedyACSo15NSDateFormatterCcACmF":{"name":"formatted(_:)","abstract":"

Decodes a String, according to the provided formatter

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO6customyAC10Foundation0C0VSgAA0B5ValueVccACmF":{"name":"custom(_:)","abstract":"

Decodes according to the user-provided function.

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseColumnEncodingStrategy.html#/s:4GRDB30DatabaseColumnEncodingStrategyO14useDefaultKeysyA2CmF":{"name":"useDefaultKeys","abstract":"

A key encoding strategy that doesn’t change key names during encoding.

","parent_name":"DatabaseColumnEncodingStrategy"},"Enums/DatabaseColumnEncodingStrategy.html#/s:4GRDB30DatabaseColumnEncodingStrategyO18convertToSnakeCaseyA2CmF":{"name":"convertToSnakeCase","abstract":"

A key encoding strategy that converts camel-case keys to snake-case keys.

","parent_name":"DatabaseColumnEncodingStrategy"},"Enums/DatabaseColumnEncodingStrategy.html#/s:4GRDB30DatabaseColumnEncodingStrategyO6customyACSSs9CodingKey_pccACmF":{"name":"custom(_:)","abstract":"

A key encoding strategy defined by the closure you supply.

","parent_name":"DatabaseColumnEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO14deferredToUUIDyA2CmF":{"name":"deferredToUUID","abstract":"

The strategy that uses formatting from the UUID type.

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO15uppercaseStringyA2CmF":{"name":"uppercaseString","abstract":"

Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO15lowercaseStringyA2CmF":{"name":"lowercaseString","abstract":"

Encodes UUIDs as lowercased strings such as “e621e1f8-c36c-495a-93fc-0c247a3e6e5f”

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO6stringACvpZ":{"name":"string","abstract":"

Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO010deferredToC0yA2CmF":{"name":"deferredToDate","abstract":"

The strategy that uses formatting from the Date structure.

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO026timeIntervalSinceReferenceC0yA2CmF":{"name":"timeIntervalSinceReferenceDate","abstract":"

Encodes a Double: the number of seconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO21timeIntervalSince1970yA2CmF":{"name":"timeIntervalSince1970","abstract":"

Encodes a Double: the number of seconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO16secondsSince1970yA2CmF":{"name":"secondsSince1970","abstract":"

Encodes an Int64: the number of seconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO21millisecondsSince1970yA2CmF":{"name":"millisecondsSince1970","abstract":"

Encodes an Int64: the number of milliseconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO7iso8601yA2CmF":{"name":"iso8601","abstract":"

Encodes dates according to the ISO 8601 and RFC 3339 standards

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO9formattedyACSo15NSDateFormatterCcACmF":{"name":"formatted(_:)","abstract":"

Encodes a String, according to the provided formatter

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO6customyAcA0B16ValueConvertible_pSg10Foundation0C0VccACmF":{"name":"custom(_:)","abstract":"

Encodes the result of the user-provided function

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO6secondyACSdcACmF":{"name":"second(_:)","abstract":"

Adds the specified amount of seconds

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO6minuteyACSicACmF":{"name":"minute(_:)","abstract":"

Adds the specified amount of minutes

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO4houryACSicACmF":{"name":"hour(_:)","abstract":"

Adds the specified amount of hours

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO3dayyACSicACmF":{"name":"day(_:)","abstract":"

Adds the specified amount of days

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO5monthyACSicACmF":{"name":"month(_:)","abstract":"

Adds the specified amount of months

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO4yearyACSicACmF":{"name":"year(_:)","abstract":"

Adds the specified amount of years

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO10startOfDayyA2CmF":{"name":"startOfDay","abstract":"

Shifts the date backwards to the beginning of the current day

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO12startOfMonthyA2CmF":{"name":"startOfMonth","abstract":"

Shifts the date backwards to the beginning of the current month

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO11startOfYearyA2CmF":{"name":"startOfYear","abstract":"

Shifts the date backwards to the beginning of the current year

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO7weekdayyACSicACmF":{"name":"weekday(_:)","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO9unixEpochyA2CmF":{"name":"unixEpoch","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO9localTimeyA2CmF":{"name":"localTime","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO3utcyA2CmF":{"name":"utc","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"SQLDateModifier"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO6insertyACSS_tcACmF":{"name":"insert(tableName:)","abstract":"

The insertion of a row in a database table

","parent_name":"DatabaseEventKind"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO6deleteyACSS_tcACmF":{"name":"delete(tableName:)","abstract":"

The deletion of a row in a database table

","parent_name":"DatabaseEventKind"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO6updateyACSS_ShySSGtcACmF":{"name":"update(tableName:columnNames:)","abstract":"

The update of a set of columns in a database table

","parent_name":"DatabaseEventKind"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO9tableNameSSvp":{"name":"tableName","abstract":"

The impacted database table

","parent_name":"DatabaseEventKind"},"Enums/DatabasePublishers/Value.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Value"},"Enums/DatabasePublishers/Value.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Value"},"Enums/DatabasePublishers/Migrate.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"Migrate"},"Enums/DatabasePublishers/Migrate.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Migrate"},"Enums/DatabasePublishers/Migrate.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Migrate"},"Enums/DatabasePublishers/Write.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"Write"},"Enums/DatabasePublishers/Write.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Write"},"Enums/DatabasePublishers/Write.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Write"},"Enums/DatabasePublishers/DatabaseRegion.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"DatabaseRegion"},"Enums/DatabasePublishers/DatabaseRegion.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"DatabaseRegion"},"Enums/DatabasePublishers/Read.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"Read"},"Enums/DatabasePublishers/Read.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Read"},"Enums/DatabasePublishers/Read.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Read"},"Enums/DatabasePublishers/Read.html":{"name":"Read","abstract":"

A publisher that reads a value from the database. It publishes exactly","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/DatabaseRegion.html":{"name":"DatabaseRegion","abstract":"

A publisher that tracks changes in a database region.

","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/Write.html":{"name":"Write","abstract":"

A publisher that writes into the database. It publishes exactly","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/Migrate.html":{"name":"Migrate","abstract":"

A publisher that migrates a database. It publishes exactly","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/Value.html":{"name":"Value","abstract":"

A publisher that tracks changes in the database.

","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers.html":{"name":"DatabasePublishers","abstract":"

A namespace for database Combine publishers.

"},"Enums/DatabaseEventKind.html":{"name":"DatabaseEventKind","abstract":"

A kind of database event. See the TransactionObserver protocol for"},"Enums/SQLDateModifier.html":{"name":"SQLDateModifier","abstract":"

A date modifier for SQLite date functions such as julianDay(_:_:) and"},"Enums/DatabaseDateEncodingStrategy.html":{"name":"DatabaseDateEncodingStrategy","abstract":"

DatabaseDateEncodingStrategy specifies how EncodableRecord types that"},"Enums/DatabaseUUIDEncodingStrategy.html":{"name":"DatabaseUUIDEncodingStrategy","abstract":"

DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that"},"Enums/DatabaseColumnEncodingStrategy.html":{"name":"DatabaseColumnEncodingStrategy","abstract":"

DatabaseColumnEncodingStrategy specifies how EncodableRecord types that"},"Enums/DatabaseDateDecodingStrategy.html":{"name":"DatabaseDateDecodingStrategy","abstract":"

DatabaseDateDecodingStrategy specifies how FetchableRecord types that"},"Enums/DatabaseColumnDecodingStrategy.html":{"name":"DatabaseColumnDecodingStrategy","abstract":"

DatabaseColumnDecodingStrategy specifies how FetchableRecord types that"},"Enums/PersistenceError.html":{"name":"PersistenceError","abstract":"

An error thrown by a type that adopts MutablePersistableRecord.

"},"Enums/SharedValueObservationExtent.html":{"name":"SharedValueObservationExtent","abstract":"

Controls the extent of the shared database observation"},"Enums/ValueReducers.html":{"name":"ValueReducers","abstract":"

A namespace for types related to the ValueReducer protocol.

"},"Classes/ValueObservationScheduler.html#/s:4GRDB25ValueObservationSchedulerC5async7onQueueACSo17OS_dispatch_queueC_tFZ":{"name":"async(onQueue:)","abstract":"

A scheduler which asynchronously notifies fresh value of the","parent_name":"ValueObservationScheduler"},"Classes/ValueObservationScheduler.html#/s:4GRDB25ValueObservationSchedulerC9immediateACvpZ":{"name":"immediate","abstract":"

A scheduler which notifies all values on the main queue. The first one","parent_name":"ValueObservationScheduler"},"Classes/SharedValueObservation.html#/s:4GRDB22SharedValueObservationC5start7onError0F6ChangeAA19DatabaseCancellable_pys0G0_pc_yxctF":{"name":"start(onError:onChange:)","abstract":"

Starts observing the database.

","parent_name":"SharedValueObservation"},"Classes/SharedValueObservation.html#/s:4GRDB22SharedValueObservationC9publisherAA18DatabasePublishersO0C0Vy_xGyF":{"name":"publisher()","abstract":"

Creates a publisher which tracks changes in database values.

","parent_name":"SharedValueObservation"},"Classes/AnyDatabaseCancellable.html#/s:4GRDB22AnyDatabaseCancellableC6cancelACyyc_tcfc":{"name":"init(cancel:)","abstract":"

Initializes the cancellable object with the given cancel-time closure.

","parent_name":"AnyDatabaseCancellable"},"Classes/AnyDatabaseCancellable.html#/s:4GRDB22AnyDatabaseCancellableCyAcA0cD0_pcfc":{"name":"init(_:)","abstract":"

Initializes a cancellable object that forwards cancellation to the","parent_name":"AnyDatabaseCancellable"},"Classes/AnyDatabaseCancellable.html#/s:4GRDB19DatabaseCancellableP6cancelyyF":{"name":"cancel()","parent_name":"AnyDatabaseCancellable"},"Classes/Record.html#/s:4GRDB6RecordCACycfc":{"name":"init()","abstract":"

Creates a Record.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC3rowAcA3RowC_tcfc":{"name":"init(row:)","abstract":"

Creates a Record from a row.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC17databaseTableNameSSvpZ":{"name":"databaseTableName","abstract":"

The name of a database table.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC25persistenceConflictPolicyAA011PersistencedE0VvpZ":{"name":"persistenceConflictPolicy","abstract":"

The policy that handles SQLite conflicts when records are inserted","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC17databaseSelectionSayAA13SQLSelectable_pGvpZ":{"name":"databaseSelection","abstract":"

The default request selection.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6encode2toyAA20PersistenceContainerVz_tF":{"name":"encode(to:)","abstract":"

Defines the values persisted in the database.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC9didInsert4with3forys5Int64V_SSSgtF":{"name":"didInsert(with:for:)","abstract":"

Notifies the record that it was successfully inserted.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC4copyACXDyF":{"name":"copy()","abstract":"

Returns a copy of self, initialized from all values encoded in the","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC18hasDatabaseChangesSbvp":{"name":"hasDatabaseChanges","abstract":"

A boolean that indicates whether the record has changes that have not","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC15databaseChangesSDySSAA13DatabaseValueVSgGvp":{"name":"databaseChanges","abstract":"

A dictionary of changes that have not been saved.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6insertyyAA8DatabaseCKF":{"name":"insert(_:)","abstract":"

Executes an INSERT statement.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6update_7columnsyAA8DatabaseC_ShySSGtKF":{"name":"update(_:columns:)","abstract":"

Executes an UPDATE statement.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC13updateChangesySbAA8DatabaseCKF":{"name":"updateChanges(_:)","abstract":"

If the record has been changed, executes an UPDATE statement so that","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC4saveyyAA8DatabaseCKF":{"name":"save(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6deleteySbAA8DatabaseCKF":{"name":"delete(_:)","abstract":"

Executes a DELETE statement.

","parent_name":"Record"},"Classes/RecordCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"RecordCursor"},"Classes/ColumnDefinition/GeneratedColumnQualification.html#/s:4GRDB16ColumnDefinitionC09GeneratedB13QualificationO7virtualyA2EmF":{"name":"virtual","abstract":"

Undocumented

","parent_name":"GeneratedColumnQualification"},"Classes/ColumnDefinition/GeneratedColumnQualification.html#/s:4GRDB16ColumnDefinitionC09GeneratedB13QualificationO6storedyA2EmF":{"name":"stored","abstract":"

Undocumented

","parent_name":"GeneratedColumnQualification"},"Classes/ColumnDefinition/GeneratedColumnQualification.html":{"name":"GeneratedColumnQualification","abstract":"

The GeneratedColumnQualification enum defines whether a generated","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC10primaryKey10onConflict13autoincrementACXDAA8DatabaseC0G10ResolutionOSg_SbtF":{"name":"primaryKey(onConflict:autoincrement:)","abstract":"

Adds a primary key constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7notNull10onConflictACXDAA8DatabaseC0G10ResolutionOSg_tF":{"name":"notNull(onConflict:)","abstract":"

Adds a NOT NULL constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC6unique10onConflictACXDAA8DatabaseC0F10ResolutionOSg_tF":{"name":"unique(onConflict:)","abstract":"

Adds a UNIQUE constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7indexedACXDyF":{"name":"indexed()","abstract":"

Adds an index of the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC5checkyACXDAA14SQLExpressible_pAA0B0VXEF":{"name":"check(_:)","abstract":"

Adds a CHECK constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC5check3sqlACXDSS_tF":{"name":"check(sql:)","abstract":"

Adds a CHECK constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC8defaults2toACXDAA24DatabaseValueConvertible_p_tF":{"name":"defaults(to:)","abstract":"

Defines the default column value.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC8defaults3sqlACXDSS_tF":{"name":"defaults(sql:)","abstract":"

Defines the default column value.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7collateyACXDAA8DatabaseC13CollationNameVF":{"name":"collate(_:)","abstract":"

Defines the default column collation.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7collateyACXDAA17DatabaseCollationCF":{"name":"collate(_:)","abstract":"

Defines the default column collation.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/generatedAs(sql:_:)":{"name":"generatedAs(sql:_:)","abstract":"

Defines the column as a generated column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/generatedAs(_:_:)":{"name":"generatedAs(_:_:)","abstract":"

Defines the column as a generated column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC10references_6column8onDelete0F6Update8deferredACXDSS_SSSgAA8DatabaseC16ForeignKeyActionOSgANSbtF":{"name":"references(_:column:onDelete:onUpdate:deferred:)","abstract":"

Defines a foreign key.

","parent_name":"ColumnDefinition"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC3add6column_AA16ColumnDefinitionCSS_AA8DatabaseC0F4TypeVSgtF":{"name":"add(column:_:)","abstract":"

Appends a column to the table.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC9addColumn3sqlySS_tF":{"name":"addColumn(sql:)","abstract":"

Appends a table column defined with raw SQL.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC9addColumn7literalyAA3SQLV_tF":{"name":"addColumn(literal:)","abstract":"

Appends a table column defined with an SQL literal.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/rename(column:to:)":{"name":"rename(column:to:)","abstract":"

Renames a column in a table.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC6rename6column2toySS_SStF":{"name":"rename(column:to:)","abstract":"

Renames a column in a table.

","parent_name":"TableAlteration"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC25autoIncrementedPrimaryKey_10onConflictAA06ColumnC0CSS_AA8DatabaseC0I10ResolutionOSgtF":{"name":"autoIncrementedPrimaryKey(_:onConflict:)","abstract":"

Defines the auto-incremented primary key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC6columnyAA06ColumnC0CSS_AA8DatabaseC0E4TypeVSgtF":{"name":"column(_:_:)","abstract":"

Appends a table column.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC6column3sqlySS_tF":{"name":"column(sql:)","abstract":"

Appends a table column defined with raw SQL.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC6column7literalyAA3SQLV_tF":{"name":"column(literal:)","abstract":"

Appends a table column defined with an SQL literal.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10primaryKey_10onConflictySaySSG_AA8DatabaseC0G10ResolutionOSgtF":{"name":"primaryKey(_:onConflict:)","abstract":"

Defines the table primary key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC9uniqueKey_10onConflictySaySSG_AA8DatabaseC0G10ResolutionOSgtF":{"name":"uniqueKey(_:onConflict:)","abstract":"

Adds a unique key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10foreignKey_10references7columns8onDelete0H6Update8deferredySaySSG_SSAJSgAA8DatabaseC07ForeignE6ActionOSgAPSbtF":{"name":"foreignKey(_:references:columns:onDelete:onUpdate:deferred:)","abstract":"

Adds a foreign key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC5checkyyAA14SQLExpressible_pF":{"name":"check(_:)","abstract":"

Adds a CHECK constraint.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC5check3sqlySS_tF":{"name":"check(sql:)","abstract":"

Adds a CHECK constraint.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10constraint3sqlySS_tF":{"name":"constraint(sql:)","abstract":"

Appends a table constraint defined with raw SQL.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10constraint7literalyAA3SQLV_tF":{"name":"constraint(literal:)","abstract":"

Appends a table constraint defined with an SQL literal.

","parent_name":"TableDefinition"},"Classes/TableAlias.html#/s:4GRDB10TableAliasC4nameACSSSg_tcfc":{"name":"init(name:)","abstract":"

Creates a TableAlias, suitable for qualifying requests or associations.

","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA12SQLSelectionVAA13SQLSelectable_pcip":{"name":"subscript(_:)","abstract":"

Returns a qualified value that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA13SQLExpressionVAA22SQLSpecificExpressible_pcip":{"name":"subscript(_:)","abstract":"

Returns a qualified expression that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA11SQLOrderingVAA0D4Term_pcip":{"name":"subscript(_:)","abstract":"

Returns a qualified ordering that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA13SQLExpressionVSScip":{"name":"subscript(_:)","abstract":"

Returns a qualified columnn that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasC6existsAA13SQLExpressionVvp":{"name":"exists","abstract":"

Experimental

","parent_name":"TableAlias"},"Classes/FTS5ColumnDefinition.html#/notIndexed()":{"name":"notIndexed()","abstract":"

Excludes the column from the full-text index.

","parent_name":"FTS5ColumnDefinition"},"Classes/FTS5TableDefinition.html#/tokenizer":{"name":"tokenizer","abstract":"

The virtual table tokenizer

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/content":{"name":"content","abstract":"

The FTS5 content option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/contentRowID":{"name":"contentRowID","abstract":"

The FTS5 content_rowid option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/prefixes":{"name":"prefixes","abstract":"

Support for the FTS5 prefix option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/columnSize":{"name":"columnSize","abstract":"

Support for the FTS5 columnsize option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/detail":{"name":"detail","abstract":"

Support for the FTS5 detail option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/column(_:)":{"name":"column(_:)","abstract":"

Appends a table column.

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/synchronize(withTable:)":{"name":"synchronize(withTable:)","abstract":"

Synchronizes the full-text table with the content of an external","parent_name":"FTS5TableDefinition"},"Classes/FTS4ColumnDefinition.html#/s:4GRDB20FTS4ColumnDefinitionC10notIndexedACXDyF":{"name":"notIndexed()","abstract":"

Excludes the column from the full-text index.

","parent_name":"FTS4ColumnDefinition"},"Classes/FTS4ColumnDefinition.html#/s:4GRDB20FTS4ColumnDefinitionC12asLanguageIdACXDyF":{"name":"asLanguageId()","abstract":"

Uses the column as the Int32 language id hidden column.

","parent_name":"FTS4ColumnDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC9tokenizerAA23FTS3TokenizerDescriptorVSgvp":{"name":"tokenizer","abstract":"

The virtual table tokenizer

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC7contentSSSgvp":{"name":"content","abstract":"

The FTS4 content option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC8compressSSSgvp":{"name":"compress","abstract":"

The FTS4 compress option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC10uncompressSSSgvp":{"name":"uncompress","abstract":"

The FTS4 uncompress option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC9matchinfoSSSgvp":{"name":"matchinfo","abstract":"

The FTS4 matchinfo option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC8prefixesShySiGSgvp":{"name":"prefixes","abstract":"

Support for the FTS5 prefix option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC6columnyAA0b6ColumnD0CSSF":{"name":"column(_:)","abstract":"

Appends a table column.

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC11synchronize04withC0ySS_tF":{"name":"synchronize(withTable:)","abstract":"

Synchronizes the full-text table with the content of an external","parent_name":"FTS4TableDefinition"},"Classes/FTS3TableDefinition.html#/s:4GRDB19FTS3TableDefinitionC9tokenizerAA0B19TokenizerDescriptorVSgvp":{"name":"tokenizer","abstract":"

The virtual table tokenizer

","parent_name":"FTS3TableDefinition"},"Classes/FTS3TableDefinition.html#/s:4GRDB19FTS3TableDefinitionC6columnyySSF":{"name":"column(_:)","abstract":"

Appends a table column.

","parent_name":"FTS3TableDefinition"},"Classes/FastNullableDatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"FastNullableDatabaseValueCursor"},"Classes/FastDatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"FastDatabaseValueCursor"},"Classes/Statement.html#/s:4GRDB9StatementC06sqliteB0s13OpaquePointerVvp":{"name":"sqliteStatement","abstract":"

The raw SQLite statement, suitable for the SQLite C API.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC3sqlSSvp":{"name":"sql","abstract":"

The SQL query

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC11columnNamesSaySSGvp":{"name":"columnNames","abstract":"

The column names, ordered from left to right.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC14databaseRegionAA08DatabaseD0Vvp":{"name":"databaseRegion","abstract":"

The database region that the statement looks into.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC10isReadonlySbvp":{"name":"isReadonly","abstract":"

Returns true if and only if the prepared statement makes no direct","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC9argumentsAA0B9ArgumentsVvp":{"name":"arguments","abstract":"

The statement arguments.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC17validateArgumentsyyAA0bD0VKF":{"name":"validateArguments(_:)","abstract":"

Throws a DatabaseError of code SQLITE_ERROR if arguments don’t fill all","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC21setUncheckedArgumentsyyAA0bE0VF":{"name":"setUncheckedArguments(_:)","abstract":"

Set arguments without any validation. Trades safety for performance.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC12setArgumentsyyAA0bD0VKF":{"name":"setArguments(_:)","abstract":"

Set the statement arguments, or throws a DatabaseError of code","parent_name":"Statement"},"Classes/Statement.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC11columnCountSivp":{"name":"columnCount","abstract":"

The number of columns in the resulting rows.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC5index8ofColumnSiSgSS_tF":{"name":"index(ofColumn:)","abstract":"

Returns the index of the leftmost column named name, in a","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC7execute9argumentsyAA0B9ArgumentsVSg_tKF":{"name":"execute(arguments:)","abstract":"

Executes the prepared statement.

","parent_name":"Statement"},"Classes/RowCursor.html#/s:4GRDB9RowCursorC9statementAA9StatementCvp":{"name":"statement","abstract":"

The statement iterated by this cursor

","parent_name":"RowCursor"},"Classes/RowCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"RowCursor"},"Classes/Row/PrefetchedRowsView.html#/s:4GRDB3RowC18PrefetchedRowsViewV7isEmptySbvp":{"name":"isEmpty","abstract":"

True if there is no prefetched associated rows.

","parent_name":"PrefetchedRowsView"},"Classes/Row/PrefetchedRowsView.html#/s:4GRDB3RowC18PrefetchedRowsViewV4keysShySSGvp":{"name":"keys","abstract":"

The keys for available prefetched rows

","parent_name":"PrefetchedRowsView"},"Classes/Row/PrefetchedRowsView.html#/s:4GRDB3RowC18PrefetchedRowsViewVySayACGSgSScip":{"name":"subscript(_:)","abstract":"

Returns the prefetched rows associated with the given key.

","parent_name":"PrefetchedRowsView"},"Classes/Row/ScopesTreeView.html#/s:4GRDB3RowC14ScopesTreeViewV5namesShySSGvp":{"name":"names","abstract":"

The scopes defined on this row, recursively.

","parent_name":"ScopesTreeView"},"Classes/Row/ScopesTreeView.html#/s:4GRDB3RowC14ScopesTreeViewVyACSgSScip":{"name":"subscript(_:)","abstract":"

Returns the row associated with the given scope.

","parent_name":"ScopesTreeView"},"Classes/Row/ScopesView.html#/s:Sl5IndexQa":{"name":"Index","parent_name":"ScopesView"},"Classes/Row/ScopesView.html#/s:4GRDB3RowC10ScopesViewV5namesSD4KeysVySSAA09_LayoutedB7Adapter_p_Gvp":{"name":"names","abstract":"

The scopes defined on this row.

","parent_name":"ScopesView"},"Classes/Row/ScopesView.html#/s:4GRDB3RowC10ScopesViewVyACSgSScip":{"name":"subscript(_:)","abstract":"

Returns the row associated with the given scope, or nil if the","parent_name":"ScopesView"},"Classes/Row.html#/s:4GRDB3RowC5countSivp":{"name":"count","abstract":"

The number of columns in the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC14prefetchedRowsAC010PrefetchedD4ViewVvp":{"name":"prefetchedRows","abstract":"

A view on the prefetched associated rows.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCACycfc":{"name":"init()","abstract":"

Creates an empty row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyACSDySSAA24DatabaseValueConvertible_pSgGcfc":{"name":"init(_:)","abstract":"

Creates a row from a dictionary of values.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyACSgSDys11AnyHashableVypGcfc":{"name":"init(_:)","abstract":"

Creates a row from [AnyHashable: Any].

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC17dictionaryLiteralACSS_AA24DatabaseValueConvertible_pSgtd_tcfc":{"name":"init(dictionaryLiteral:)","abstract":"

Creates a row initialized with elements. Column order is preserved, and","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC4copyACyF":{"name":"copy()","abstract":"

Returns an immutable copy of the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11columnNamess15LazyMapSequenceVyACSSGvp":{"name":"columnNames","abstract":"

The names of columns in the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC9hasColumnySbSSF":{"name":"hasColumn(_:)","abstract":"

Returns true if and only if the row has that column.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC20containsNonNullValueSbvp":{"name":"containsNonNullValue","abstract":"

Returns true if and only if one column contains a non-null value, or if","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC7hasNull7atIndexSbSi_tF":{"name":"hasNull(atIndex:)","abstract":"

Returns true if the row contains null at given index.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyAA24DatabaseValueConvertible_pSgSicip":{"name":"subscript(_:)","abstract":"

Returns Int64, Double, String, Data or nil, depending on the value","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSicAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSicAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSicAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSicAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyAA24DatabaseValueConvertible_pSgSScip":{"name":"subscript(_:)","abstract":"

Returns Int64, Double, String, Data or nil, depending on the value","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSScAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSScAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyAA24DatabaseValueConvertible_pSgxcAA16ColumnExpressionRzluip":{"name":"subscript(_:)","abstract":"

Returns Int64, Double, String, NSData or nil, depending on the value","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgq_cAA24DatabaseValueConvertibleRzAA16ColumnExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgq_cAA24DatabaseValueConvertibleRzAA015StatementColumnE0RzAA0G10ExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxq_cAA24DatabaseValueConvertibleRzAA16ColumnExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxq_cAA24DatabaseValueConvertibleRzAA015StatementColumnE0RzAA0G10ExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10dataNoCopy7atIndex10Foundation4DataVSgSi_tF":{"name":"dataNoCopy(atIndex:)","abstract":"

Returns the optional Data at given index.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10dataNoCopy5named10Foundation4DataVSgSS_tF":{"name":"dataNoCopy(named:)","abstract":"

Returns the optional Data at given column.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10dataNoCopyy10Foundation4DataVSgxAA16ColumnExpressionRzlF":{"name":"dataNoCopy(_:)","abstract":"

Returns the optional NSData at given column.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC14databaseValuess15LazyMapSequenceVyAcA13DatabaseValueVGvp":{"name":"databaseValues","abstract":"

The database values in the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScAA15FetchableRecordRzluip":{"name":"subscript(_:)","abstract":"

Returns the record associated with the given scope.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSScAA15FetchableRecordRzluip":{"name":"subscript(_:)","abstract":"

Returns the eventual record associated with the given scope.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScSmRzAA15FetchableRecord7ElementRpzluip":{"name":"subscript(_:)","abstract":"

Returns the records encoded in the given prefetched rows.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyShyxGSScAA15FetchableRecordRzSHRzluip":{"name":"subscript(_:)","abstract":"

Returns the set of records encoded in the given prefetched rows.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC6scopesAC10ScopesViewVvp":{"name":"scopes","abstract":"

Returns a view on the scopes defined by row adapters.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10scopesTreeAC06ScopesD4ViewVvp":{"name":"scopesTree","abstract":"

Returns a view on the scopes tree defined by row adapters.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8unscopedACvp":{"name":"unscoped","abstract":"

Returns a copy of the row, without any scopes.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC9unadaptedACvp":{"name":"unadapted","abstract":"

Return the raw row fetched from the database.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11fetchCursor_9arguments7adapterAA0bD0CAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over rows fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchAll_9arguments7adapterSayACGAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of rows fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchSet_9arguments7adapterShyACGAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of rows fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchOne_9arguments7adapterACSgAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single row fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11fetchCursor_3sql9arguments7adapterAA0bD0CAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over rows fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchAll_3sql9arguments7adapterSayACGAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of rows fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchSet_3sql9arguments7adapterShyACGAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of rows fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchOne_3sql9arguments7adapterACSgAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single row fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11fetchCursoryAA0bD0CAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over rows fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchAllySayACGAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of rows fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchSetyShyACGAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of rows fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchOneyACSgAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single row fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCySS_AA13DatabaseValueVtAA0B5IndexVcip":{"name":"subscript(_:)","abstract":"

Accesses the (ColumnName, DatabaseValue) pair at given index.

","parent_name":"Row"},"Classes/Row/ScopesView.html":{"name":"ScopesView","abstract":"

A view of the scopes defined by row adapters. It is a collection of","parent_name":"Row"},"Classes/Row/ScopesTreeView.html":{"name":"ScopesTreeView","abstract":"

A view on the scopes tree defined by row adapters.

","parent_name":"Row"},"Classes/Row/PrefetchedRowsView.html":{"name":"PrefetchedRowsView","abstract":"

A view on the prefetched associated rows.

","parent_name":"Row"},"Classes/AnyDatabaseWriter.html#/s:4GRDB17AnyDatabaseWriterCyAcA0cD0_pcfc":{"name":"init(_:)","abstract":"

Creates a database writer that wraps a base database writer.

","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP13configurationAA13ConfigurationVvp":{"name":"configuration","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP5writeyqd__qd__AA0B0CKXEKlF":{"name":"write(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP10asyncWrite_10completionyqd__AA0B0CKc_yAG_s6ResultOyqd__s5Error_pGtctlF":{"name":"asyncWrite(_:completion:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","parent_name":"AnyDatabaseWriter"},"Classes/DatabaseFuture.html#/s:4GRDB14DatabaseFutureC4waitxyKF":{"name":"wait()","abstract":"

Blocks the current thread until the value is available, and returns it.

","parent_name":"DatabaseFuture"},"Classes/NullableDatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"NullableDatabaseValueCursor"},"Classes/DatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"DatabaseValueCursor"},"Classes/DatabaseSnapshot.html#/s:4GRDB16DatabaseSnapshotC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"DatabaseSnapshot"},"Classes/AnyDatabaseReader.html#/s:4GRDB17AnyDatabaseReaderCyAcA0cD0_pcfc":{"name":"init(_:)","abstract":"

Creates a database reader that wraps a base database reader.

","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP13configurationAA13ConfigurationVvp":{"name":"configuration","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"AnyDatabaseReader"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC4pathSSvp":{"name":"path","abstract":"

The path to the database file; it is “:memory:” for in-memory databases.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC4path13configurationACSS_AA13ConfigurationVtKcfc":{"name":"init(path:configuration:)","abstract":"

Opens the SQLite database at path path.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13configurationAcA13ConfigurationV_tcfc":{"name":"init(configuration:)","abstract":"

Opens an in-memory SQLite database.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13releaseMemoryyyF":{"name":"releaseMemory()","abstract":"

Free as much memory as possible.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13inTransactionyyAA0B0C0E4KindOSg_AF0E10CompletionOAFKXEtKF":{"name":"inTransaction(_:_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC02inB0yxxAA0B0CKXEKlF":{"name":"inDatabase(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC4pathSSvp":{"name":"path","abstract":"

The path to the database.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC4path13configurationACSS_AA13ConfigurationVtKcfc":{"name":"init(path:configuration:)","abstract":"

Opens the SQLite database at path path.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC13releaseMemoryyyF":{"name":"releaseMemory()","abstract":"

Free as much memory as possible.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC19asyncConcurrentReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncConcurrentRead(_:)","abstract":"

Asynchronously executes a read-only function in a protected","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC29invalidateReadOnlyConnectionsyyF":{"name":"invalidateReadOnlyConnections()","abstract":"

Invalidates open read-only SQLite connections.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC18writeInTransactionyyAA0B0C0F4KindOSg_AF0F10CompletionOAFKXEtKF":{"name":"writeInTransaction(_:_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC12makeSnapshotAA0bE0CyKF":{"name":"makeSnapshot()","abstract":"

Creates a database snapshot.

","parent_name":"DatabasePool"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC4nameSSvp":{"name":"name","abstract":"

The name of the SQL function

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC_13argumentCount4pure8functionACSS_s5Int32VSgSbAA0B16ValueConvertible_pSgSayAA0bI0VGKctcfc":{"name":"init(_:argumentCount:pure:function:)","abstract":"

Creates an SQL function.

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC_13argumentCount4pure9aggregateACSS_s5Int32VSgSbxmtcAA0B9AggregateRzlufc":{"name":"init(_:argumentCount:pure:aggregate:)","abstract":"

Creates an SQL aggregate function.

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC06callAsC0yAA13SQLExpressionVAA14SQLExpressible_pd_tF":{"name":"callAsFunction(_:)","abstract":"

Returns an SQL expression that applies the function.

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC10capitalizeACvpZ":{"name":"capitalize","abstract":"

An SQL function that returns the Swift built-in capitalized","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC9lowercaseACvpZ":{"name":"lowercase","abstract":"

An SQL function that returns the Swift built-in lowercased","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC9uppercaseACvpZ":{"name":"uppercase","abstract":"

An SQL function that returns the Swift built-in uppercased","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC19localizedCapitalizeACvpZ":{"name":"localizedCapitalize","abstract":"

An SQL function that returns the Swift built-in","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC18localizedLowercaseACvpZ":{"name":"localizedLowercase","abstract":"

An SQL function that returns the Swift built-in","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC18localizedUppercaseACvpZ":{"name":"localizedUppercase","abstract":"

An SQL function that returns the Swift built-in","parent_name":"DatabaseFunction"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC4nameSSvp":{"name":"name","abstract":"

The name of the collation

","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC_8functionACSS_So18NSComparisonResultVSS_SStctcfc":{"name":"init(_:function:)","abstract":"

Creates a collation.

","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC14unicodeCompareACvpZ":{"name":"unicodeCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC22caseInsensitiveCompareACvpZ":{"name":"caseInsensitiveCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC31localizedCaseInsensitiveCompareACvpZ":{"name":"localizedCaseInsensitiveCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC16localizedCompareACvpZ":{"name":"localizedCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC24localizedStandardCompareACvpZ":{"name":"localizedStandardCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/SQLStatementCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"SQLStatementCursor"},"Classes/Database/TransactionObservationExtent.html#/s:4GRDB8DatabaseC28TransactionObservationExtentO16observerLifetimeyA2EmF":{"name":"observerLifetime","abstract":"

Observation lasts until observer is deallocated

","parent_name":"TransactionObservationExtent"},"Classes/Database/TransactionObservationExtent.html#/s:4GRDB8DatabaseC28TransactionObservationExtentO04nextC0yA2EmF":{"name":"nextTransaction","abstract":"

Observation lasts until the next transaction

","parent_name":"TransactionObservationExtent"},"Classes/Database/TransactionObservationExtent.html#/s:4GRDB8DatabaseC28TransactionObservationExtentO16databaseLifetimeyA2EmF":{"name":"databaseLifetime","abstract":"

Observation lasts until the database is closed

","parent_name":"TransactionObservationExtent"},"Classes/Database/TransactionKind.html#/s:4GRDB8DatabaseC15TransactionKindO8deferredyA2EmF":{"name":"deferred","abstract":"

The DEFERRED transaction kind

","parent_name":"TransactionKind"},"Classes/Database/TransactionKind.html#/s:4GRDB8DatabaseC15TransactionKindO9immediateyA2EmF":{"name":"immediate","abstract":"

The IMMEDIATE transaction kind

","parent_name":"TransactionKind"},"Classes/Database/TransactionKind.html#/s:4GRDB8DatabaseC15TransactionKindO9exclusiveyA2EmF":{"name":"exclusive","abstract":"

The EXCLUSIVE transaction kind

","parent_name":"TransactionKind"},"Classes/Database/TransactionCompletion.html#/s:4GRDB8DatabaseC21TransactionCompletionO6commityA2EmF":{"name":"commit","abstract":"

Confirms changes

","parent_name":"TransactionCompletion"},"Classes/Database/TransactionCompletion.html#/s:4GRDB8DatabaseC21TransactionCompletionO8rollbackyA2EmF":{"name":"rollback","abstract":"

Cancel changes

","parent_name":"TransactionCompletion"},"Classes/Database/TraceEvent/Statement.html#/s:4GRDB8DatabaseC10TraceEventO9StatementV3sqlSSvp":{"name":"sql","abstract":"

The executed SQL, where bound parameters are not expanded.

","parent_name":"Statement"},"Classes/Database/TraceEvent/Statement.html#/s:4GRDB8DatabaseC10TraceEventO9StatementV11expandedSQLSSvp":{"name":"expandedSQL","abstract":"

The executed SQL, where bound parameters are expanded.

","parent_name":"Statement"},"Classes/Database/TraceEvent/Statement.html":{"name":"Statement","abstract":"

Information about a statement reported by Database.trace(options:_:)

","parent_name":"TraceEvent"},"Classes/Database/TraceEvent.html#/s:4GRDB8DatabaseC10TraceEventO9statementyA2E9StatementVcAEmF":{"name":"statement(_:)","abstract":"

An event reported by TracingOptions.statement.

","parent_name":"TraceEvent"},"Classes/Database/TraceEvent.html#/s:4GRDB8DatabaseC10TraceEventO7profileyA2E9StatementV_SdtcAEmF":{"name":"profile(statement:duration:)","abstract":"

An event reported by TracingOptions.profile.

","parent_name":"TraceEvent"},"Classes/Database/TraceEvent.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"TraceEvent"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV8rawValues5Int32Vvp":{"name":"rawValue","abstract":"

The raw “Trace Event Code”.

","parent_name":"TracingOptions"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV8rawValueAEs5Int32V_tcfc":{"name":"init(rawValue:)","abstract":"

Creates a TracingOptions from a raw “Trace Event Code”.

","parent_name":"TracingOptions"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV9statementAEvpZ":{"name":"statement","abstract":"

Reports executed statements.

","parent_name":"TracingOptions"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV7profileAEvpZ":{"name":"profile","abstract":"

Reports executed statements and the estimated duration that the","parent_name":"TracingOptions"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO7cascadeyA2EmF":{"name":"cascade","abstract":"

The CASCADE foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO8restrictyA2EmF":{"name":"restrict","abstract":"

The RESTRICT foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO7setNullyA2EmF":{"name":"setNull","abstract":"

The SET NULL foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO10setDefaultyA2EmF":{"name":"setDefault","abstract":"

The SET DEFAULT foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO8rollbackyA2EmF":{"name":"rollback","abstract":"

The ROLLBACK conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO5abortyA2EmF":{"name":"abort","abstract":"

The ABORT conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO4failyA2EmF":{"name":"fail","abstract":"

The FAIL conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO6ignoreyA2EmF":{"name":"ignore","abstract":"

The IGNORE conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO7replaceyA2EmF":{"name":"replace","abstract":"

The REPLACE conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV8rawValueAESS_tcfc":{"name":"init(rawValue:)","abstract":"

Creates an SQL column type.

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV4textAEvpZ":{"name":"text","abstract":"

The TEXT SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV7integerAEvpZ":{"name":"integer","abstract":"

The INTEGER SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV6doubleAEvpZ":{"name":"double","abstract":"

The DOUBLE SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV7numericAEvpZ":{"name":"numeric","abstract":"

The NUMERIC SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV7booleanAEvpZ":{"name":"boolean","abstract":"

The BOOLEAN SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV4blobAEvpZ":{"name":"blob","abstract":"

The BLOB SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV4dateAEvpZ":{"name":"date","abstract":"

The DATE SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV8datetimeAEvpZ":{"name":"datetime","abstract":"

The DATETIME SQL column type

","parent_name":"ColumnType"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV8rawValueAESS_tcfc":{"name":"init(rawValue:)","abstract":"

Creates a built-in collation name.

","parent_name":"CollationName"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV6binaryAEvpZ":{"name":"binary","abstract":"

The BINARY built-in SQL collation

","parent_name":"CollationName"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV6nocaseAEvpZ":{"name":"nocase","abstract":"

The NOCASE built-in SQL collation

","parent_name":"CollationName"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV5rtrimAEvpZ":{"name":"rtrim","abstract":"

The RTRIM built-in SQL collation

","parent_name":"CollationName"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO7passiveyA2EmF":{"name":"passive","abstract":"

The SQLITE_CHECKPOINT_PASSIVE mode

","parent_name":"CheckpointMode"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO4fullyA2EmF":{"name":"full","abstract":"

The SQLITE_CHECKPOINT_FULL mode

","parent_name":"CheckpointMode"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO7restartyA2EmF":{"name":"restart","abstract":"

The SQLITE_CHECKPOINT_RESTART mode

","parent_name":"CheckpointMode"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO8truncateyA2EmF":{"name":"truncate","abstract":"

The SQLITE_CHECKPOINT_TRUNCATE mode

","parent_name":"CheckpointMode"},"Classes/Database/BusyMode.html#/s:4GRDB8DatabaseC8BusyModeO14immediateErroryA2EmF":{"name":"immediateError","abstract":"

The SQLITE_BUSY error is immediately returned to the connection that","parent_name":"BusyMode"},"Classes/Database/BusyMode.html#/s:4GRDB8DatabaseC8BusyModeO7timeoutyAESdcAEmF":{"name":"timeout(_:)","abstract":"

The SQLITE_BUSY error will be returned only if the database remains","parent_name":"BusyMode"},"Classes/Database/BusyMode.html#/s:4GRDB8DatabaseC8BusyModeO8callbackyAESbSiccAEmF":{"name":"callback(_:)","abstract":"

A custom callback that is called when a database is locked.","parent_name":"BusyMode"},"Classes/Database.html#/s:4GRDB8DatabaseC16sqliteConnections13OpaquePointerVSgvp":{"name":"sqliteConnection","abstract":"

The raw SQLite connection, suitable for the SQLite C API.","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC8logErroryAA10ResultCodeV_SStcSgvpZ":{"name":"logError","abstract":"

The error logging function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11descriptionSSvp":{"name":"description","abstract":"

See Configuration.label

","parent_name":"Database"},"Classes/Database.html#/s:s28CustomDebugStringConvertibleP16debugDescriptionSSvp":{"name":"debugDescription","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC17lastInsertedRowIDs5Int64Vvp":{"name":"lastInsertedRowID","abstract":"

The rowID of the most recently inserted row.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC12changesCountSivp":{"name":"changesCount","abstract":"

The number of rows modified, inserted or deleted by the most recent","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC17totalChangesCountSivp":{"name":"totalChangesCount","abstract":"

The total number of rows modified, inserted or deleted by all successful","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19isInsideTransactionSbvp":{"name":"isInsideTransaction","abstract":"

True if the database connection is currently in a transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13lastErrorCodeAA06ResultE0Vvp":{"name":"lastErrorCode","abstract":"

The last error code

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16lastErrorMessageSSSgvp":{"name":"lastErrorMessage","abstract":"

The last error message

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC29maximumStatementArgumentCountSivp":{"name":"maximumStatementArgumentCount","abstract":"

The maximum number of arguments accepted by an SQLite statement.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC3add8functionyAA0B8FunctionC_tF":{"name":"add(function:)","abstract":"

Add or redefine an SQL function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6remove8functionyAA0B8FunctionC_tF":{"name":"remove(function:)","abstract":"

Remove an SQL function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC3add9collationyAA0B9CollationC_tF":{"name":"add(collation:)","abstract":"

Add or redefine a collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6remove9collationyAA0B9CollationC_tF":{"name":"remove(collation:)","abstract":"

Remove a collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC5trace7options_yAC14TracingOptionsV_yAC10TraceEventOcSgtF":{"name":"trace(options:_:)","abstract":"

Registers a tracing function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC10checkpoint_2onSi13walFrameCount_Si012checkpointedfG0tAC14CheckpointModeO_SSSgtKF":{"name":"checkpoint(_:on:)","abstract":"

Runs a WAL checkpoint.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19suspendNotificationSo18NSNotificationNameavpZ":{"name":"suspendNotification","abstract":"

When this notification is posted, databases which were opened with the","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC18resumeNotificationSo18NSNotificationNameavpZ":{"name":"resumeNotification","abstract":"

When this notification is posted, databases which were opened with the","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13inTransactionyyAC0D4KindOSg_AC0D10CompletionOyKXEtKF":{"name":"inTransaction(_:_:)","abstract":"

Executes a block inside a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11inSavepointyyAC21TransactionCompletionOyKXEKF":{"name":"inSavepoint(_:)","abstract":"

Executes a block inside a savepoint.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16beginTransactionyyAC0D4KindOSgKF":{"name":"beginTransaction(_:)","abstract":"

Begins a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC8rollbackyyKF":{"name":"rollback()","abstract":"

Rollbacks a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6commityyKF":{"name":"commit()","abstract":"

Commits a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16clearSchemaCacheyyF":{"name":"clearSchemaCache()","abstract":"

Clears the database schema cache.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11tableExistsySbSSKF":{"name":"tableExists(_:)","abstract":"

Returns whether a table exists in the main or temp schema.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21isSQLiteInternalTableySbSSFZ":{"name":"isSQLiteInternalTable(_:)","abstract":"

Returns whether a table is an internal SQLite table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21isSQLiteInternalTableySbSSF":{"name":"isSQLiteInternalTable(_:)","abstract":"

Returns whether a table is an internal SQLite table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19isGRDBInternalTableySbSSFZ":{"name":"isGRDBInternalTable(_:)","abstract":"

Returns whether a table is an internal GRDB table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19isGRDBInternalTableySbSSF":{"name":"isGRDBInternalTable(_:)","abstract":"

Returns whether a table is an internal GRDB table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC10viewExistsySbSSKF":{"name":"viewExists(_:)","abstract":"

Returns whether a view exists in the main or temp schema.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13triggerExistsySbSSKF":{"name":"triggerExists(_:)","abstract":"

Returns whether a trigger exists in the main or temp schema.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC10primaryKeyyAA07PrimaryD4InfoVSSKF":{"name":"primaryKey(_:)","abstract":"

The primary key for table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7indexes2onSayAA9IndexInfoVGSS_tKF":{"name":"indexes(on:)","abstract":"

The indexes on table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC5table_12hasUniqueKeySbSS_xtKSTRzSS7ElementRtzlF":{"name":"table(_:hasUniqueKey:)","abstract":"

True if a sequence of columns uniquely identifies a row, that is to say","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11foreignKeys2onSayAA14ForeignKeyInfoVGSS_tKF":{"name":"foreignKeys(on:)","abstract":"

The foreign keys defined on table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC20foreignKeyViolationsAA12RecordCursorCyAA07ForeignD9ViolationVGyKF":{"name":"foreignKeyViolations()","abstract":"

Returns a cursor over foreign key violations in the database.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC20foreignKeyViolations2inAA12RecordCursorCyAA07ForeignD9ViolationVGSS_tKF":{"name":"foreignKeyViolations(in:)","abstract":"

Returns a cursor over foreign key violations in the table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16checkForeignKeysyyKF":{"name":"checkForeignKeys()","abstract":"

Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16checkForeignKeys2inySS_tKF":{"name":"checkForeignKeys(in:)","abstract":"

Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7columns2inSayAA10ColumnInfoVGSS_tKF":{"name":"columns(in:)","abstract":"

The columns in the table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13makeStatement3sqlAA0D0CSS_tKF":{"name":"makeStatement(sql:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13makeStatement7literalAA0D0CAA3SQLV_tKF":{"name":"makeStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeSelectStatement3sqlAA0E0CSS_tKF":{"name":"makeSelectStatement(sql:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeSelectStatement7literalAA0E0CAA3SQLV_tKF":{"name":"makeSelectStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC15cachedStatement3sqlAA0D0CSS_tKF":{"name":"cachedStatement(sql:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC15cachedStatement7literalAA0D0CAA3SQLV_tKF":{"name":"cachedStatement(literal:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedSelectStatement3sqlAA0E0CSS_tKF":{"name":"cachedSelectStatement(sql:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedSelectStatement7literalAA0E0CAA3SQLV_tKF":{"name":"cachedSelectStatement(literal:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeUpdateStatement3sqlAA0E0CSS_tKF":{"name":"makeUpdateStatement(sql:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeUpdateStatement7literalAA0E0CAA3SQLV_tKF":{"name":"makeUpdateStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedUpdateStatement3sqlAA0E0CSS_tKF":{"name":"cachedUpdateStatement(sql:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedUpdateStatement7literalAA0E0CAA3SQLV_tKF":{"name":"cachedUpdateStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13allStatements3sql9argumentsAA18SQLStatementCursorCSS_AA18StatementArgumentsVSgtKF":{"name":"allStatements(sql:arguments:)","abstract":"

Returns a cursor of all SQL statements separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13allStatements7literalAA18SQLStatementCursorCAA3SQLV_tKF":{"name":"allStatements(literal:)","abstract":"

Returns a cursor of all SQL statements separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7execute3sql9argumentsySS_AA18StatementArgumentsVtKF":{"name":"execute(sql:arguments:)","abstract":"

Executes one or several SQL statements, separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7execute7literalyAA3SQLV_tKF":{"name":"execute(literal:)","abstract":"

Executes one or several SQL statements, separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC12BusyCallbacka":{"name":"BusyCallback","abstract":"

See BusyMode and https://www.sqlite.org/c3ref/busy_handler.html

","parent_name":"Database"},"Classes/Database/BusyMode.html":{"name":"BusyMode","abstract":"

When there are several connections to a database, a connection may try","parent_name":"Database"},"Classes/Database/CheckpointMode.html":{"name":"CheckpointMode","abstract":"

The available checkpoint modes.

","parent_name":"Database"},"Classes/Database/CollationName.html":{"name":"CollationName","abstract":"

A built-in SQLite collation.

","parent_name":"Database"},"Classes/Database/ColumnType.html":{"name":"ColumnType","abstract":"

An SQL column type.

","parent_name":"Database"},"Classes/Database/ConflictResolution.html":{"name":"ConflictResolution","abstract":"

An SQLite conflict resolution.

","parent_name":"Database"},"Classes/Database/ForeignKeyAction.html":{"name":"ForeignKeyAction","abstract":"

A foreign key action.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16LogErrorFunctiona":{"name":"LogErrorFunction","abstract":"

An error log function that takes an error code and message.

","parent_name":"Database"},"Classes/Database/TracingOptions.html":{"name":"TracingOptions","abstract":"

An option for Database.trace(options:_:)

","parent_name":"Database"},"Classes/Database/TraceEvent.html":{"name":"TraceEvent","abstract":"

An event reported by Database.trace(options:_:)

","parent_name":"Database"},"Classes/Database/TransactionCompletion.html":{"name":"TransactionCompletion","abstract":"

Confirms or cancels the changes performed by a transaction or savepoint.

","parent_name":"Database"},"Classes/Database/TransactionKind.html":{"name":"TransactionKind","abstract":"

An SQLite transaction kind. See https://www.sqlite.org/lang_transaction.html

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC3add19transactionObserver6extentyAA011TransactionE0_p_AC0G17ObservationExtentOtF":{"name":"add(transactionObserver:extent:)","abstract":"

Add a transaction observer, so that it gets notified of","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6remove19transactionObserveryAA011TransactionE0_p_tF":{"name":"remove(transactionObserver:)","abstract":"

Remove a transaction observer.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC26afterNextTransactionCommityyyACcF":{"name":"afterNextTransactionCommit(_:)","abstract":"

Registers a closure to be executed after the next or current","parent_name":"Database"},"Classes/Database/TransactionObservationExtent.html":{"name":"TransactionObservationExtent","abstract":"

The extent of a transaction observation

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC31dropFTS4SynchronizationTriggers8forTableySS_tKF":{"name":"dropFTS4SynchronizationTriggers(forTable:)","abstract":"

Deletes the synchronization triggers for a synchronized FTS4 table

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create5table9temporary11ifNotExists12withoutRowID4bodyySS_S3byAA15TableDefinitionCXEtKF":{"name":"create(table:temporary:ifNotExists:withoutRowID:body:)","abstract":"

Creates a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6rename5table2toySS_SStKF":{"name":"rename(table:to:)","abstract":"

Renames a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC5alter5table4bodyySS_yAA15TableAlterationCXEtKF":{"name":"alter(table:body:)","abstract":"

Modifies a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC4drop5tableySS_tKF":{"name":"drop(table:)","abstract":"

Deletes a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create5index2on7columns6unique11ifNotExists9conditionySS_SSSaySSGS2bAA14SQLExpressible_pSgtKF":{"name":"create(index:on:columns:unique:ifNotExists:condition:)","abstract":"

Creates an index.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC4drop5indexySS_tKF":{"name":"drop(index:)","abstract":"

Deletes a database index.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7reindex9collationyAC13CollationNameV_tKF":{"name":"reindex(collation:)","abstract":"

Delete and recreate from scratch all indices that use this collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7reindex9collationyAA0B9CollationC_tKF":{"name":"reindex(collation:)","abstract":"

Delete and recreate from scratch all indices that use this collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create12virtualTable11ifNotExists5usingySS_SbSStKF":{"name":"create(virtualTable:ifNotExists:using:)","abstract":"

Creates a virtual database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create12virtualTable11ifNotExists5using_ySS_Sbxy0E10DefinitionQzcSgtKAA07VirtualE6ModuleRzlF":{"name":"create(virtualTable:ifNotExists:using:_:)","abstract":"

Creates a virtual database table.

","parent_name":"Database"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorCyACyxGqd__c7ElementQyd__RszAA0C0Rd__lufc":{"name":"init(_:)","abstract":"

Creates a cursor that wraps a base cursor but whose type depends only on","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorC8iteratorACyxGqd___tc7ElementQyd__RszStRd__lufc":{"name":"init(iterator:)","abstract":"

Creates a cursor that wraps a base iterator but whose type depends only","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorCyACyxGqd__c7ElementQyd__RszSTRd__lufc":{"name":"init(_:)","abstract":"

Creates a cursor that wraps a base sequence but whose type depends only","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorCyACyxGxSgyKccfc":{"name":"init(_:)","abstract":"

Creates a cursor that wraps the given closure in its next() method

","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"AnyCursor"},"Classes/AnyCursor.html":{"name":"AnyCursor","abstract":"

A type-erased cursor of Element.

"},"Classes/Database.html":{"name":"Database","abstract":"

A Database connection.

"},"Classes/SQLStatementCursor.html":{"name":"SQLStatementCursor","abstract":"

Undocumented

"},"Classes/DatabaseCollation.html":{"name":"DatabaseCollation","abstract":"

A Collation is a string comparison function used by SQLite.

"},"Classes/DatabaseFunction.html":{"name":"DatabaseFunction","abstract":"

An SQL function or aggregate.

"},"Classes/DatabasePool.html":{"name":"DatabasePool","abstract":"

A DatabasePool grants concurrent accesses to an SQLite database.

"},"Classes/DatabaseQueue.html":{"name":"DatabaseQueue","abstract":"

A DatabaseQueue serializes access to an SQLite database.

"},"Classes/AnyDatabaseReader.html":{"name":"AnyDatabaseReader","abstract":"

A type-erased DatabaseReader

"},"Classes/DatabaseSnapshot.html":{"name":"DatabaseSnapshot","abstract":"

A DatabaseSnapshot sees an unchanging database content, as it existed at the"},"Classes/DatabaseValueCursor.html":{"name":"DatabaseValueCursor","abstract":"

A cursor of database values extracted from a single column."},"Classes/NullableDatabaseValueCursor.html":{"name":"NullableDatabaseValueCursor","abstract":"

A cursor of optional database values extracted from a single column."},"Classes/DatabaseFuture.html":{"name":"DatabaseFuture","abstract":"

A future database value, returned by the DatabaseWriter.concurrentRead(_:)"},"Classes/AnyDatabaseWriter.html":{"name":"AnyDatabaseWriter","abstract":"

A type-erased DatabaseWriter

"},"Classes/Row.html":{"name":"Row","abstract":"

A database row.

"},"Classes/RowCursor.html":{"name":"RowCursor","abstract":"

A cursor of database rows. For example:

"},"Classes/Statement.html":{"name":"Statement","abstract":"

A statement represents an SQL query.

"},"Classes/FastDatabaseValueCursor.html":{"name":"FastDatabaseValueCursor","abstract":"

A cursor of database values extracted from a single column."},"Classes/FastNullableDatabaseValueCursor.html":{"name":"FastNullableDatabaseValueCursor","abstract":"

A cursor of optional database values extracted from a single column."},"Classes/FTS3TableDefinition.html":{"name":"FTS3TableDefinition","abstract":"

The FTS3TableDefinition class lets you define columns of a FTS3 virtual table.

"},"Classes/FTS4TableDefinition.html":{"name":"FTS4TableDefinition","abstract":"

The FTS4TableDefinition class lets you define columns of a FTS4 virtual table.

"},"Classes/FTS4ColumnDefinition.html":{"name":"FTS4ColumnDefinition","abstract":"

The FTS4ColumnDefinition class lets you refine a column of an FTS4"},"Classes/FTS5TableDefinition.html":{"name":"FTS5TableDefinition","abstract":"

The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.

"},"Classes/FTS5ColumnDefinition.html":{"name":"FTS5ColumnDefinition","abstract":"

The FTS5ColumnDefinition class lets you refine a column of an FTS5"},"Classes/TableAlias.html":{"name":"TableAlias","abstract":"

Experimental

"},"Classes/TableDefinition.html":{"name":"TableDefinition","abstract":"

The TableDefinition class lets you define table columns and constraints.

"},"Classes/TableAlteration.html":{"name":"TableAlteration","abstract":"

The TableAlteration class lets you alter database tables.

"},"Classes/ColumnDefinition.html":{"name":"ColumnDefinition","abstract":"

The ColumnDefinition class lets you refine a table column.

"},"Classes/RecordCursor.html":{"name":"RecordCursor","abstract":"

A cursor of records. For example:

"},"Classes/Record.html":{"name":"Record","abstract":"

Record is a class that wraps a table row, or the result of any query. It is"},"Classes/AnyDatabaseCancellable.html":{"name":"AnyDatabaseCancellable","abstract":"

A type-erasing cancellable object that executes a provided closure"},"Classes/SharedValueObservation.html":{"name":"SharedValueObservation","abstract":"

Experimental

"},"Classes/ValueObservationScheduler.html":{"name":"ValueObservationScheduler","abstract":"

ValueObservationScheduler determines how ValueObservation notifies its"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Enums.html":{"name":"Enumerations","abstract":"

The following enumerations are available globally.

"},"Extensions.html":{"name":"Extensions","abstract":"

The following extensions are available globally.

"},"Functions.html":{"name":"Functions","abstract":"

The following functions are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"},"Structs.html":{"name":"Structures","abstract":"

The following structures are available globally.

"},"Typealiases.html":{"name":"Type Aliases","abstract":"

The following type aliases are available globally.

"}} \ No newline at end of file diff --git a/docs/5.16/docsets/GRDB.docset/Contents/Resources/docSet.dsidx b/docs/5.16/docsets/GRDB.docset/Contents/Resources/docSet.dsidx new file mode 100644 index 000000000..3ceea454c Binary files /dev/null and b/docs/5.16/docsets/GRDB.docset/Contents/Resources/docSet.dsidx differ diff --git a/docs/5.16/docsets/GRDB.tgz b/docs/5.16/docsets/GRDB.tgz new file mode 100644 index 000000000..4c53daf8a Binary files /dev/null and b/docs/5.16/docsets/GRDB.tgz differ diff --git a/docs/5.16/docsets/GRDB.xml b/docs/5.16/docsets/GRDB.xml new file mode 100644 index 000000000..99295410d --- /dev/null +++ b/docs/5.16/docsets/GRDB.xml @@ -0,0 +1 @@ +5.16.0http://groue.github.io/GRDB.swift/docs/5.16/docsets/GRDB.tgz diff --git a/docs/5.16/img/carat.png b/docs/5.16/img/carat.png new file mode 100755 index 000000000..29d2f7fd4 Binary files /dev/null and b/docs/5.16/img/carat.png differ diff --git a/docs/5.16/img/dash.png b/docs/5.16/img/dash.png new file mode 100755 index 000000000..6f694c7a0 Binary files /dev/null and b/docs/5.16/img/dash.png differ diff --git a/docs/5.16/img/gh.png b/docs/5.16/img/gh.png new file mode 100755 index 000000000..628da97c7 Binary files /dev/null and b/docs/5.16/img/gh.png differ diff --git a/docs/5.16/img/spinner.gif b/docs/5.16/img/spinner.gif new file mode 100644 index 000000000..e3038d0a4 Binary files /dev/null and b/docs/5.16/img/spinner.gif differ diff --git a/docs/5.16/index.html b/docs/5.16/index.html new file mode 100644 index 000000000..4ff725ea4 --- /dev/null +++ b/docs/5.16/index.html @@ -0,0 +1,8761 @@ + + + + GRDB Reference + + + + + + + + + + + + +
+
+

GRDB 5.16.0 Docs (89% documented)

+

GitHubView on GitHub

+

DashInstall in Dash

+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+ +

GRDB: A toolkit for SQLite databases, with a focus on application development

+ +

A toolkit for SQLite databases, with a focus on application development

+ +

+ Swift 5.3 + Platforms + License + CI Status +

+ +
+ +

Latest release: December 5, 2021 • version 5.16.0 • CHANGELOG • Migrating From GRDB 4 to GRDB 5

+ +

Requirements: iOS 11.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ • SQLite 3.8.5+ • Swift 5.3+ / Xcode 12+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Swift versionGRDB version
Swift 5.3+v5.16.0
Swift 5.2v5.12.0
Swift 5.1v4.14.0
Swift 5v4.14.0
Swift 4.2v4.14.0
Swift 4.1v3.7.0
Swift 4v2.10.0
Swift 3.2v1.3.0
Swift 3.1v1.3.0
Swift 3v1.0
Swift 2.3v0.81.2
Swift 2.2v0.80.2
+ +

Contact:

+ + +

What is this?

+ +

GRDB provides raw access to SQL and advanced SQLite features, because one sometimes enjoys a sharp tool. It has robust concurrency primitives, so that multi-threaded applications can efficiently use their databases. It grants your application models with persistence and fetching methods, so that you don’t have to deal with SQL and raw database rows when you don’t want to.

+ +

Compared to SQLite.swift or FMDB, GRDB can spare you a lot of glue code. Compared to Core Data or Realm, it can simplify your multi-threaded applications.

+ +

It comes with up-to-date documentation, general guides, and it is fast.

+ +

See Why Adopt GRDB? if you are looking for your favorite database library.

+ +
+ +

+ Features • + Usage • + Installation • + Documentation • + FAQ +

+ +
+

Features

+ +

GRDB ships with:

+ + +

Usage

+ +
+ Start using the database in four easy steps + +“`swift +import GRDB + +// 1. Open a database connection +let dbQueue = try DatabaseQueue(path: ”/path/to/database.sqlite") + +// 2. Define the database schema +try dbQueue.write { db in + try db.create(table: “player”) { t in + t.autoIncrementedPrimaryKey(“id”) + t.column(“name”, .text).notNull() + t.column(“score”, .integer).notNull() + } +} + +// 3. Define a record type +struct Player: Codable, FetchableRecord, PersistableRecord { + var id: Int64 + var name: String + var score: Int +} + +// 4. Access the database +try dbQueue.write { db in + try Player(id: 1, name: “Arthur”, score: 100).insert(db) + try Player(id: 2, name: “Barbara”, score: 1000).insert(db) +} + +let players: [Player] = try dbQueue.read { db in + try Player.fetchAll(db) +} +“` + +
+ +
+ Activate the WAL mode + +”`swift +import GRDB + +// Simple database connection +let dbQueue = try DatabaseQueue(path: “/path/to/database.sqlite”) + +// Enhanced multithreading based on SQLite’s WAL mode +let dbPool = try DatabasePool(path: “/path/to/database.sqlite”) +“` + +See [Database Connections](#database-connections) + +
+ +
+ Access to raw SQL + +”`swift +try dbQueue.write { db in + try db.execute(sql: “”“ + CREATE TABLE place ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + favorite BOOLEAN NOT NULL DEFAULT 0, + latitude DOUBLE NOT NULL, + longitude DOUBLE NOT NULL) + ”“”) + + try db.execute(sql: “”“ + INSERT INTO place (title, favorite, latitude, longitude) + VALUES (?, ?, ?, ?) + ”“”, arguments: [“Paris”, true, 48.85341, 2.3488]) + + let parisId = db.lastInsertedRowID + + // Avoid SQL injection with SQL interpolation + try db.execute(literal: “”“ + INSERT INTO place (title, favorite, latitude, longitude) + VALUES (\("King’s Cross”), \(true), \(51.52151), \(-0.12763)) + “”“) +} +”` + +See [Executing Updates](#executing-updates) + +
+ +
+ Access to raw database rows and values + +“`swift +try dbQueue.read { db in + // Fetch database rows + let rows = try Row.fetchCursor(db, sql: "SELECT * FROM place”) + while let row = try rows.next() { + let title: String = row[“title”] + let isFavorite: Bool = row[“favorite”] + let coordinate = CLLocationCoordinate2D( + latitude: row[“latitude”], + longitude: row[“longitude”]) + } + + // Fetch values + let placeCount = try Int.fetchOne(db, sql: “SELECT COUNT(*) FROM place”)! // Int + let placeTitles = try String.fetchAll(db, sql: “SELECT title FROM place”) // [String] +} + +let placeCount = try dbQueue.read { db in + try Int.fetchOne(db, sql: “SELECT COUNT(*) FROM place”)! +} +“` + +See [Fetch Queries](#fetch-queries) + +
+ +
+ Database model types aka "records” + +“`swift +struct Place { + var id: Int64? + var title: String + var isFavorite: Bool + var coordinate: CLLocationCoordinate2D +} + +// snip: turn Place into a "record” by adopting the protocols that +// provide fetching and persistence methods. + +try dbQueue.write { db in + // Create database table + try db.create(table: “place”) { t in + t.autoIncrementedPrimaryKey(“id”) + t.column(“title”, .text).notNull() + t.column(“favorite”, .boolean).notNull().defaults(to: false) + t.column(“longitude”, .double).notNull() + t.column(“latitude”, .double).notNull() + } + + var berlin = Place( + id: nil, + title: “Berlin”, + isFavorite: false, + coordinate: CLLocationCoordinate2D(latitude: 52.52437, longitude: 13.41053)) + + try berlin.insert(db) + berlin.id // some value + + berlin.isFavorite = true + try berlin.update(db) +} +“` + +See [Records](#records) + +
+ +
+ Query the database with the Swift query interface + +”`swift +try dbQueue.read { db in + // Place? + let paris = try Place.fetchOne(db, id: 1) + + // Place? + let berlin = try Place.filter(Column(“title”) == “Berlin”).fetchOne(db) + + // [Place] + let favoritePlaces = try Place + .filter(Column(“favorite”) == true) + .order(Column(“title”)) + .fetchAll(db) + + // Int + let favoriteCount = try Place.filter(Column(“favorite”)).fetchCount(db) + + // SQL is always welcome + let places = try Place.fetchAll(db, sql: “SELECT * FROM place”) +} +“` + +See the [Query Interface](#the-query-interface) + +
+ +
+ Database changes notifications + +”`swift +// Define the observed value +let observation = ValueObservation.tracking { db in + try Place.fetchAll(db) +} + +// Start observation +let cancellable = observation.start( + in: dbQueue, + onError: { error in … } + onChange: { (places: [Place]) in print(“Fresh places: \(places)”) }) +“` + +Ready-made support for Combine and RxSwift: + +”`swift +// Combine +let cancellable = observation.publisher(in: dbQueue).sink( + receiveCompletion: { completion in … }, + receiveValue: { (places: [Place]) in print(“Fresh places: \(places)”) }) + +// RxSwift +let disposable = observation.rx.observe(in: dbQueue).subscribe( + onNext: { (places: [Place]) in print(“Fresh places: \(places)”) }, + onError: { error in … }) +“` + +See [Database Observation], [Combine Support], [RxGRDB]. + +
+

Documentation

+ +

GRDB runs on top of SQLite: you should get familiar with the SQLite FAQ. For general and detailed information, jump to the SQLite Documentation.

+

Demo Applications & Frequently Asked Questions

+ + +

Reference

+ + +

Getting Started

+ + +

SQLite and SQL

+ + +

Records and the Query Interface

+ + +

Application Tools

+ + +

Good to Know

+ + +

General Guides & Good Practices

+ + + +

FAQ

+ +

Sample Code

+

Installation

+ +

The installation procedures below have GRDB use the version of SQLite that ships with the target operating system.

+ +

See Encryption for the installation procedure of GRDB with SQLCipher.

+ +

See Custom SQLite builds for the installation procedure of GRDB with a customized build of SQLite.

+ +

See Enabling FTS5 Support for the installation procedure of GRDB with support for the FTS5 full-text engine.

+

CocoaPods

+ +

CocoaPods is a dependency manager for Xcode projects. To use GRDB with CocoaPods (version 1.2 or higher), specify in your Podfile:

+
pod 'GRDB.swift'
+
+ +

GRDB can be installed as a framework, or a static library.

+

Swift Package Manager

+ +

The Swift Package Manager automates the distribution of Swift code. To use GRDB with SPM, add a dependency to https://github.com/groue/GRDB.swift.git

+ +
+

:point_up: Note: Linux is not currently supported.

+ +

:warning: Warning: Due to an Xcode bug, you will get “No such module ‘CSQLite’” errors when you want to embed the GRDB package in other targets than the main application (watch extensions, for example). UI and Unit testing targets are OK, though. See #642 for more information.

+
+

Carthage

+ +

Carthage is unsupported. For some context about this decision, see #433.

+

Manually

+ +
    +
  1. Download a copy of GRDB, or clone its repository and make sure you checkout the latest tagged version.

  2. +
  3. Embed the GRDB.xcodeproj project in your own project.

  4. +
  5. Add the GRDBOSX, GRDBiOS, GRDBtvOS, or GRDBWatchOS target in the Target Dependencies section of the Build Phases tab of your application target (extension target for WatchOS).

  6. +
  7. Add the GRDB.framework from the targeted platform to the Embedded Binaries section of the General tab of your application target (extension target for WatchOS).

  8. +
+ +
+

:bulb: Tip: see the Demo Applications for examples of such integration.

+
+

Database Connections

+ +

GRDB provides two classes for accessing SQLite databases: DatabaseQueue and DatabasePool:

+
import GRDB
+
+// Pick one:
+let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
+let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
+
+ +

The differences are:

+ +
    +
  • Database pools allow concurrent database accesses (this can improve the performance of multithreaded applications).
  • +
  • Database pools open your SQLite database in the WAL mode (unless read-only).
  • +
  • Database queues support in-memory databases.
  • +
+ +

If you are not sure, choose DatabaseQueue. You will always be able to switch to DatabasePool later.

+ + +

Database Queues

+ +

Open a database queue with the path to a database file:

+
import GRDB
+
+let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
+let inMemoryDBQueue = DatabaseQueue()
+
+ +

SQLite creates the database file if it does not already exist. The connection is closed when the database queue gets deinitialized.

+ +

A database queue can be used from any thread. The write and read methods are synchronous, and block the current thread until your database statements are executed in a protected dispatch queue:

+
// Modify the database:
+try dbQueue.write { db in
+    try db.create(table: "place") { ... }
+    try Place(...).insert(db)
+}
+
+// Read values:
+try dbQueue.read { db in
+    let places = try Place.fetchAll(db)
+    let placeCount = try Place.fetchCount(db)
+}
+
+ +

Database access methods can return values:

+
let placeCount = try dbQueue.read { db in
+    try Place.fetchCount(db)
+}
+
+let newPlaceCount = try dbQueue.write { db -> Int in
+    try Place(...).insert(db)
+    return try Place.fetchCount(db)
+}
+
+ +

A database queue serializes accesses to the database, which means that there is never more than one thread that uses the database.

+ +
    +
  • When you don’t need to modify the database, prefer the read method. It prevents any modification to the database.

  • +
  • The write method wraps your database statements in a transaction that commits if and only if no error occurs. On the first unhandled error, all changes are reverted, the whole transaction is rollbacked, and the error is rethrown.

    + +

    When precise transaction handling is required, see Transactions and Savepoints.

  • +
+ +

A database queue needs your application to follow rules in order to deliver its safety guarantees. Please refer to the Concurrency guide.

+ +
+

:bulb: Tip: see the Demo Applications for sample code that sets up a database queue on iOS.

+
+

DatabaseQueue Configuration

+
var config = Configuration()
+config.readonly = true
+config.foreignKeysEnabled = true // Default is already true
+config.label = "MyDatabase"      // Useful when your app opens multiple databases
+
+let dbQueue = try DatabaseQueue(
+    path: "/path/to/database.sqlite",
+    configuration: config)
+
+ +

See Configuration for more details.

+

Database Pools

+ +

A database pool allows concurrent database accesses.

+
import GRDB
+let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
+
+ +

SQLite creates the database file if it does not already exist. The connection is closed when the database pool gets deinitialized.

+ +
+

:point_up: Note: unless read-only, a database pool opens your database in the SQLite “WAL mode”. The WAL mode does not fit all situations. Please have a look at https://www.sqlite.org/wal.html.

+
+ +

A database pool can be used from any thread. The write and read methods are synchronous, and block the current thread until your database statements are executed in a protected dispatch queue:

+
// Modify the database:
+try dbPool.write { db in
+    try db.create(table: "place") { ... }
+    try Place(...).insert(db)
+}
+
+// Read values:
+try dbPool.read { db in
+    let places = try Place.fetchAll(db)
+    let placeCount = try Place.fetchCount(db)
+}
+
+ +

Database access methods can return values:

+
let placeCount = try dbPool.read { db in
+    try Place.fetchCount(db)
+}
+
+let newPlaceCount = try dbPool.write { db -> Int in
+    try Place(...).insert(db)
+    return try Place.fetchCount(db)
+}
+
+ +

Database pools allow several threads to access the database at the same time:

+ +
    +
  • When you don’t need to modify the database, prefer the read method, because several threads can perform reads in parallel.

    + +

    Reads are generally non-blocking, unless the maximum number of concurrent reads has been reached. In this case, a read has to wait for another read to complete. That maximum number can be configured.

  • +
  • Reads are guaranteed an immutable view of the last committed state of the database, regardless of concurrent writes. This kind of isolation is called snapshot isolation.

  • +
  • Unlike reads, writes are serialized. There is never more than a single thread that is writing into the database.

  • +
  • The write method wraps your database statements in a transaction that commits if and only if no error occurs. On the first unhandled error, all changes are reverted, the whole transaction is rollbacked, and the error is rethrown.

    + +

    When precise transaction handling is required, see Transactions and Savepoints.

  • +
  • Database pools can take snapshots of the database.

  • +
+ +

A database pool needs your application to follow rules in order to deliver its safety guarantees. See the Concurrency guide for more details about database pools, how they differ from database queues, and advanced use cases.

+ +
+

:bulb: Tip: see the Demo Applications for sample code that sets up a database queue on iOS, and just replace DatabaseQueue with DatabasePool.

+
+

DatabasePool Configuration

+
var config = Configuration()
+config.readonly = true
+config.foreignKeysEnabled = true // Default is already true
+config.label = "MyDatabase"      // Useful when your app opens multiple databases
+config.maximumReaderCount = 10   // The default is 5
+
+let dbPool = try DatabasePool(
+    path: "/path/to/database.sqlite",
+    configuration: config)
+
+ +

See Configuration for more details.

+ +

Database pools are more memory-hungry than database queues. See Memory Management for more information.

+

SQLite API

+ +

In this section of the documentation, we will talk SQL. Jump to the query interface if SQL is not your cup of tea.

+ + + +

Advanced topics:

+ + +

Executing Updates

+ +

Once granted with a database connection, the execute method executes the SQL statements that do not return any database row, such as CREATE TABLE, INSERT, DELETE, ALTER, etc.

+ +

For example:

+
try dbQueue.write { db in
+    try db.execute(sql: """
+        CREATE TABLE player (
+            id INTEGER PRIMARY KEY AUTOINCREMENT,
+            name TEXT NOT NULL,
+            score INT)
+        """)
+
+    try db.execute(
+        sql: "INSERT INTO player (name, score) VALUES (?, ?)",
+        arguments: ["Barbara", 1000])
+
+    try db.execute(
+        sql: "UPDATE player SET score = :score WHERE id = :id",
+        arguments: ["score": 1000, "id": 1])
+    }
+}
+
+ +

The ? and colon-prefixed keys like :score in the SQL query are the statements arguments. You pass arguments with arrays or dictionaries, as in the example above. See Values for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and StatementArguments for a detailed documentation of SQLite arguments.

+ +

You can also embed query arguments right into your SQL queries, with the literal argument label, as in the example below. See SQL Interpolation for more details.

+
try dbQueue.write { db in
+    try db.execute(literal: """
+        INSERT INTO player (name, score) VALUES (\("O'Brien"), \(550))
+        """)
+}
+
+ +

Never ever embed values directly in your raw SQL strings. See Avoiding SQL Injection for more information:

+
// WRONG: don't embed values in raw SQL strings
+let id = 123
+let name = textField.text
+try db.execute(
+    sql: "UPDATE player SET name = '\(name)' WHERE id = \(id)")
+
+// CORRECT: use arguments dictionary
+try db.execute(
+    sql: "UPDATE player SET name = :name WHERE id = :id",
+    arguments: ["name": name, "id": id])
+
+// CORRECT: use arguments array
+try db.execute(
+    sql: "UPDATE player SET name = ? WHERE id = ?",
+    arguments: [name, id])
+
+// CORRECT: use SQL Interpolation
+try db.execute(
+    literal: "UPDATE player SET name = \(name) WHERE id = \(id)")
+
+ +

Join multiple statements with a semicolon:

+
try db.execute(sql: """
+    INSERT INTO player (name, score) VALUES (?, ?);
+    INSERT INTO player (name, score) VALUES (?, ?);
+    """, arguments: ["Arthur", 750, "Barbara", 1000])
+
+try db.execute(literal: """
+    INSERT INTO player (name, score) VALUES (\("Arthur"), \(750));
+    INSERT INTO player (name, score) VALUES (\("Barbara"), \(1000));
+    """)
+
+ +

When you want to make sure that a single statement is executed, use Prepared Statements.

+ +

After an INSERT statement, you can get the row ID of the inserted row:

+
try db.execute(
+    sql: "INSERT INTO player (name, score) VALUES (?, ?)",
+    arguments: ["Arthur", 1000])
+let playerId = db.lastInsertedRowID
+
+ +

Don’t miss Records, that provide classic persistence methods:

+
var player = Player(name: "Arthur", score: 1000)
+try player.insert(db)
+let playerId = player.id
+
+

Fetch Queries

+ +

Database connections let you fetch database rows, plain values, and custom models aka “records”.

+ +

Rows are the raw results of SQL queries:

+
try dbQueue.read { db in
+    if let row = try Row.fetchOne(db, sql: "SELECT * FROM wine WHERE id = ?", arguments: [1]) {
+        let name: String = row["name"]
+        let color: Color = row["color"]
+        print(name, color)
+    }
+}
+
+ +

Values are the Bool, Int, String, Date, Swift enums, etc. stored in row columns:

+
try dbQueue.read { db in
+    let urls = try URL.fetchCursor(db, sql: "SELECT url FROM wine")
+    while let url = try urls.next() {
+        print(url)
+    }
+}
+
+ +

Records are your application objects that can initialize themselves from rows:

+
let wines = try dbQueue.read { db in
+    try Wine.fetchAll(db, sql: "SELECT * FROM wine")
+}
+
+ + +

Fetching Methods

+ +

Throughout GRDB, you can always fetch cursors, arrays, sets, or single values of any fetchable type (database row, simple value, or custom record):

+
try Row.fetchCursor(...) // A Cursor of Row
+try Row.fetchAll(...)    // [Row]
+try Row.fetchSet(...)    // Set<Row>
+try Row.fetchOne(...)    // Row?
+
+ +
    +
  • fetchCursor returns a cursor over fetched values:

    +
    let rows = try Row.fetchCursor(db, sql: "SELECT ...") // A Cursor of Row
    +
  • +
  • fetchAll returns an array:

    +
    let players = try Player.fetchAll(db, sql: "SELECT ...") // [Player]
    +
  • +
  • fetchSet returns a set:

    +
    let names = try String.fetchSet(db, sql: "SELECT ...") // Set<String>
    +
  • +
  • fetchOne returns a single optional value, and consumes a single database row (if any).

    +
    let count = try Int.fetchOne(db, sql: "SELECT COUNT(*) ...") // Int?
    +
  • +
+ +

All those fetching methods require an SQL string that contains a single SQL statement. When you want to fetch from multiple statements joined with a semicolon, iterate the multiple prepared statements found in the SQL string:

+
let statements = try db.allStatements(sql: """
+    SELECT ...; 
+    SELECT ...; 
+    SELECT ...;
+    """)
+while let statement = try statements.next() {
+    let players = try Player.fetchAll(statement)
+}
+
+ +

You can join the results of all statements yielded by the allStatements method, like the SQLite sqlite3_exec function:

+
// A single cursor of all rows from all statements
+let rows = try db
+    .allStatements(sql: "...")
+    .flatMap { statement in try Row.fetchCursor(statement) }
+
+ +

See prepared statements for more information about allStatements().

+

Cursors

+ +

Whenever you consume several rows from the database, you can fetch an Array, a Set, or a Cursor.

+ +

The fetchAll() and fetchSet() methods return regular Swift array and sets, that you iterate like all other arrays and sets:

+
try dbQueue.read { db in
+    // [Player]
+    let players = try Player.fetchAll(db, sql: "SELECT ...")
+    for player in players {
+        // use player
+    }
+}
+
+ +

Unlike arrays and sets, cursors returned by fetchCursor() load their results step after step:

+
try dbQueue.read { db in
+    // Cursor of Player
+    let players = try Player.fetchCursor(db, sql: "SELECT ...")
+    while let player = try players.next() {
+        // use player
+    }
+}
+
+ +
    +
  • Cursors can not be used on any thread: you must consume a cursor on the dispatch queue it was created in. Particularly, don’t extract a cursor out of a database access method:

    +
    // Wrong
    +let cursor = try dbQueue.read { db in
    +    try Player.fetchCursor(db, ...)
    +}
    +while let player = try cursor.next() { ... }
    +
    + +

    Conversely, arrays and sets may be consumed on any thread:

    +
    // OK
    +let array = try dbQueue.read { db in
    +    try Player.fetchAll(db, ...)
    +}
    +for player in array { ... }
    +
  • +
  • Cursors can be iterated only one time. Arrays and sets can be iterated many times.

  • +
  • Cursors iterate database results in a lazy fashion, and don’t consume much memory. Arrays and sets contain copies of database values, and may take a lot of memory when there are many fetched results.

  • +
  • Cursors are granted with direct access to SQLite, unlike arrays and sets that have to take the time to copy database values. If you look after extra performance, you may prefer cursors.

  • +
  • Cursors can feed Swift collections.

    + +

    You will most of the time use fetchAll or fetchSet when you want an array or a set. For more specific needs, you may prefer one of the initializers below. All of them accept an extra optional minimumCapacity argument which helps optimizing your app when you have an idea of the number of elements in a cursor (the built-in fetchAll and fetchSet do not perform such an optimization).

    + +

    Arrays and all types conforming to RangeReplaceableCollection:

    +
    // [String]
    +let cursor = try String.fetchCursor(db, ...)
    +let array = try Array(cursor)
    +
    + +

    Sets:

    +
    // Set<Int>
    +let cursor = try Int.fetchCursor(db, ...)
    +let set = try Set(cursor)
    +
    + +

    Dictionaries:

    +
    // [Int64: [Player]]
    +let cursor = try Player.fetchCursor(db)
    +let dictionary = try Dictionary(grouping: cursor, by: { $0.teamID })
    +
    +// [Int64: Player]
    +let cursor = try Player.fetchCursor(db).map { ($0.id, $0) }
    +let dictionary = try Dictionary(uniqueKeysWithValues: cursor)
    +
  • +
  • Cursors adopt the Cursor protocol, which looks a lot like standard lazy sequences of Swift. As such, cursors come with many convenience methods: compactMap, contains, dropFirst, dropLast, drop(while:), enumerated, filter, first, flatMap, forEach, joined, joined(separator:), max, max(by:), min, min(by:), map, prefix, prefix(while:), reduce, reduce(into:), suffix:

    +
    // Prints all Github links
    +try URL
    +    .fetchCursor(db, sql: "SELECT url FROM link")
    +    .filter { url in url.host == "github.com" }
    +    .forEach { url in print(url) }
    +
    +// An efficient cursor of coordinates:
    +let locations = try Row.
    +    .fetchCursor(db, sql: "SELECT latitude, longitude FROM place")
    +    .map { row in
    +        CLLocationCoordinate2D(latitude: row[0], longitude: row[1])
    +    }
    +
  • +
  • Cursors are not Swift sequences. That’s because Swift sequences can’t handle iteration errors, when reading SQLite results may fail at any time.

  • +
  • Cursors require a little care:

    + +
      +
    • Don’t modify the results during a cursor iteration:

      +
      // Undefined behavior
      +while let player = try players.next() {
      +    try db.execute(sql: "DELETE ...")
      +}
      +
    • +
    • Don’t turn a cursor of Row into an array or a set. You would not get the distinct rows you expect. To get a array of rows, use Row.fetchAll(...). To get a set of rows, use Row.fetchSet(...). Generally speaking, make sure you copy a row whenever you extract it from a cursor for later use: row.copy().

    • +
  • +
+ +

If you don’t see, or don’t care about the difference, use arrays. If you care about memory and performance, use cursors when appropriate.

+

Row Queries

+ + +

Fetching Rows

+ +

Fetch cursors of rows, arrays, sets, or single rows (see fetching methods):

+
try dbQueue.read { db in
+    try Row.fetchCursor(db, sql: "SELECT ...", arguments: ...) // A Cursor of Row
+    try Row.fetchAll(db, sql: "SELECT ...", arguments: ...)    // [Row]
+    try Row.fetchSet(db, sql: "SELECT ...", arguments: ...)    // Set<Row>
+    try Row.fetchOne(db, sql: "SELECT ...", arguments: ...)    // Row?
+
+    let rows = try Row.fetchCursor(db, sql: "SELECT * FROM wine")
+    while let row = try rows.next() {
+        let name: String = row["name"]
+        let color: Color = row["color"]
+        print(name, color)
+    }
+}
+
+let rows = try dbQueue.read { db in
+    try Row.fetchAll(db, sql: "SELECT * FROM player")
+}
+
+ +

Arguments are optional arrays or dictionaries that fill the positional ? and colon-prefixed keys like :name in the query:

+
let rows = try Row.fetchAll(db,
+    sql: "SELECT * FROM player WHERE name = ?",
+    arguments: ["Arthur"])
+
+let rows = try Row.fetchAll(db,
+    sql: "SELECT * FROM player WHERE name = :name",
+    arguments: ["name": "Arthur"])
+
+ +

See Values for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and StatementArguments for a detailed documentation of SQLite arguments.

+ +

Unlike row arrays that contain copies of the database rows, row cursors are close to the SQLite metal, and require a little care:

+ +
+

:point_up: Don’t turn a cursor of Row into an array or a set. You would not get the distinct rows you expect. To get a array of rows, use Row.fetchAll(...). To get a set of rows, use Row.fetchSet(...). Generally speaking, make sure you copy a row whenever you extract it from a cursor for later use: row.copy().

+
+

Column Values

+ +

Read column values by index or column name:

+
let name: String = row[0]      // 0 is the leftmost column
+let name: String = row["name"] // Leftmost matching column - lookup is case-insensitive
+let name: String = row[Column("name")] // Using query interface's Column
+
+ +

Make sure to ask for an optional when the value may be NULL:

+
let name: String? = row["name"]
+
+ +

The row[] subscript returns the type you ask for. See Values for more information on supported value types:

+
let bookCount: Int     = row["bookCount"]
+let bookCount64: Int64 = row["bookCount"]
+let hasBooks: Bool     = row["bookCount"] // false when 0
+
+let string: String     = row["date"]      // "2015-09-11 18:14:15.123"
+let date: Date         = row["date"]      // Date
+self.date = row["date"] // Depends on the type of the property.
+
+ +

You can also use the as type casting operator:

+
row[...] as Int
+row[...] as Int?
+
+ +
+

:warning: Warning: avoid the as! and as? operators:

+
if let int = row[...] as? Int { ... } // BAD - doesn't work
+if let int = row[...] as Int? { ... } // GOOD
+
+
+ +

Generally speaking, you can extract the type you need, provided it can be converted from the underlying SQLite value:

+ +
    +
  • Successful conversions include:

    + +
      +
    • All numeric SQLite values to all numeric Swift types, and Bool (zero is the only false boolean).
    • +
    • Text SQLite values to Swift String.
    • +
    • Blob SQLite values to Foundation Data.
    • +
    + +

    See Values for more information on supported types (Bool, Int, String, Date, Swift enums, etc.)

  • +
  • NULL returns nil.

    +
    let row = try Row.fetchOne(db, sql: "SELECT NULL")!
    +row[0] as Int? // nil
    +row[0] as Int  // fatal error: could not convert NULL to Int.
    +
    + +

    There is one exception, though: the DatabaseValue type:

    +
    row[0] as DatabaseValue // DatabaseValue.null
    +
  • +
  • Missing columns return nil.

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'foo' AS foo")!
    +row["missing"] as String? // nil
    +row["missing"] as String  // fatal error: no such column: missing
    +
    + +

    You can explicitly check for a column presence with the hasColumn method.

  • +
  • Invalid conversions throw a fatal error.

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'Mom’s birthday'")!
    +row[0] as String // "Mom’s birthday"
    +row[0] as Date?  // fatal error: could not convert "Mom’s birthday" to Date.
    +row[0] as Date   // fatal error: could not convert "Mom’s birthday" to Date.
    +
    +let row = try Row.fetchOne(db, sql: "SELECT 256")!
    +row[0] as Int    // 256
    +row[0] as UInt8? // fatal error: could not convert 256 to UInt8.
    +row[0] as UInt8  // fatal error: could not convert 256 to UInt8.
    +
    + +

    Those conversion fatal errors can be avoided with the DatabaseValue type:

    +
    let row = try Row.fetchOne(db, sql: "SELECT 'Mom’s birthday'")!
    +let dbValue: DatabaseValue = row[0]
    +if dbValue.isNull {
    +    // Handle NULL
    +} else if let date = Date.fromDatabaseValue(dbValue) {
    +    // Handle valid date
    +} else {
    +    // Handle invalid date
    +}
    +
    + +

    This extra verbosity is the consequence of having to deal with an untrusted database: you may consider fixing the content of your database instead. See Fatal Errors for more information.

  • +
  • SQLite has a weak type system, and provides convenience conversions that can turn String to Int, Double to Blob, etc.

    + +

    GRDB will sometimes let those conversions go through:

    +
    let rows = try Row.fetchCursor(db, sql: "SELECT '20 small cigars'")
    +while let row = try rows.next() {
    +    row[0] as Int   // 20
    +}
    +
    + +

    Don’t freak out: those conversions did not prevent SQLite from becoming the immensely successful database engine you want to use. And GRDB adds safety checks described just above. You can also prevent those convenience conversions altogether by using the DatabaseValue type.

  • +
+

DatabaseValue

+ +

DatabaseValue is an intermediate type between SQLite and your values, which gives information about the raw value stored in the database.

+ +

You get DatabaseValue just like other value types:

+
let dbValue: DatabaseValue = row[0]
+let dbValue: DatabaseValue? = row["name"] // nil if and only if column does not exist
+
+// Check for NULL:
+dbValue.isNull // Bool
+
+// The stored value:
+dbValue.storage.value // Int64, Double, String, Data, or nil
+
+// All the five storage classes supported by SQLite:
+switch dbValue.storage {
+case .null:                 print("NULL")
+case .int64(let int64):     print("Int64: \(int64)")
+case .double(let double):   print("Double: \(double)")
+case .string(let string):   print("String: \(string)")
+case .blob(let data):       print("Data: \(data)")
+}
+
+ +

You can extract regular values (Bool, Int, String, Date, Swift enums, etc.) from DatabaseValue with the DatabaseValueConvertible.fromDatabaseValue() method:

+
let dbValue: DatabaseValue = row["bookCount"]
+let bookCount   = Int.fromDatabaseValue(dbValue)   // Int?
+let bookCount64 = Int64.fromDatabaseValue(dbValue) // Int64?
+let hasBooks    = Bool.fromDatabaseValue(dbValue)  // Bool?, false when 0
+
+let dbValue: DatabaseValue = row["date"]
+let string = String.fromDatabaseValue(dbValue)     // "2015-09-11 18:14:15.123"
+let date   = Date.fromDatabaseValue(dbValue)       // Date?
+
+ +

fromDatabaseValue returns nil for invalid conversions:

+
let row = try Row.fetchOne(db, sql: "SELECT 'Mom’s birthday'")!
+let dbValue: DatabaseValue = row[0]
+let string = String.fromDatabaseValue(dbValue) // "Mom’s birthday"
+let int    = Int.fromDatabaseValue(dbValue)    // nil
+let date   = Date.fromDatabaseValue(dbValue)   // nil
+
+

Rows as Dictionaries

+ +

Row adopts the standard RandomAccessCollection protocol, and can be seen as a dictionary of DatabaseValue:

+
// All the (columnName, dbValue) tuples, from left to right:
+for (columnName, dbValue) in row {
+    ...
+}
+
+ +

You can build rows from dictionaries (standard Swift dictionaries and NSDictionary). See Values for more information on supported types:

+
let row: Row = ["name": "foo", "date": nil]
+let row = Row(["name": "foo", "date": nil])
+let row = Row(/* [AnyHashable: Any] */) // nil if invalid dictionary
+
+ +

Yet rows are not real dictionaries: they may contain duplicate columns:

+
let row = try Row.fetchOne(db, sql: "SELECT 1 AS foo, 2 AS foo")!
+row.columnNames    // ["foo", "foo"]
+row.databaseValues // [1, 2]
+row["foo"]         // 1 (leftmost matching column)
+for (columnName, dbValue) in row { ... } // ("foo", 1), ("foo", 2)
+
+ +

When you build a dictionary from a row, you have to disambiguate identical columns, and choose how to present database values. For example:

+ +
    +
  • A [String: DatabaseValue] dictionary that keeps leftmost value in case of duplicated column name:

    +
    let dict = Dictionary(row, uniquingKeysWith: { (left, _) in left })
    +
  • +
  • A [String: AnyObject] dictionary which keeps rightmost value in case of duplicated column name. This dictionary is identical to FMResultSet’s resultDictionary from FMDB. It contains NSNull values for null columns, and can be shared with Objective-C:

    +
    let dict = Dictionary(
    +    row.map { (column, dbValue) in
    +        (column, dbValue.storage.value as AnyObject)
    +    },
    +    uniquingKeysWith: { (_, right) in right })
    +
  • +
  • A [String: Any] dictionary that can feed, for example, JSONSerialization:

    +
    let dict = Dictionary(
    +    row.map { (column, dbValue) in
    +        (column, dbValue.storage.value)
    +    },
    +    uniquingKeysWith: { (left, _) in left })
    +
  • +
+ +

See the documentation of Dictionary.init(_:uniquingKeysWith:) for more information.

+

Value Queries

+ +

Instead of rows, you can directly fetch values. Like rows, fetch them as cursors, arrays, sets, or single values (see fetching methods). Values are extracted from the leftmost column of the SQL queries:

+
try dbQueue.read { db in
+    try Int.fetchCursor(db, sql: "SELECT ...", arguments: ...) // A Cursor of Int
+    try Int.fetchAll(db, sql: "SELECT ...", arguments: ...)    // [Int]
+    try Int.fetchSet(db, sql: "SELECT ...", arguments: ...)    // Set<Int>
+    try Int.fetchOne(db, sql: "SELECT ...", arguments: ...)    // Int?
+
+    // When database may contain NULL:
+    try Optional<Int>.fetchCursor(db, sql: "SELECT ...", arguments: ...) // A Cursor of Int?
+    try Optional<Int>.fetchAll(db, sql: "SELECT ...", arguments: ...)    // [Int?]
+    try Optional<Int>.fetchSet(db, sql: "SELECT ...", arguments: ...)    // Set<Int?>
+}
+
+let playerCount = try dbQueue.read { db in
+    try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM player")!
+}
+
+ +

fetchOne returns an optional value which is nil in two cases: either the SELECT statement yielded no row, or one row with a NULL value.

+ +

There are many supported value types (Bool, Int, String, Date, Swift enums, etc.). See Values for more information:

+
let count = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM player")! // Int
+let urls = try URL.fetchAll(db, sql: "SELECT url FROM link")          // [URL]
+
+

Values

+ +

GRDB ships with built-in support for the following value types:

+ + + +

Values can be used as statement arguments:

+
let url: URL = ...
+let verified: Bool = ...
+try db.execute(
+    sql: "INSERT INTO link (url, verified) VALUES (?, ?)",
+    arguments: [url, verified])
+
+ +

Values can be extracted from rows:

+
let rows = try Row.fetchCursor(db, sql: "SELECT * FROM link")
+while let row = try rows.next() {
+    let url: URL = row["url"]
+    let verified: Bool = row["verified"]
+}
+
+ +

Values can be directly fetched:

+
let urls = try URL.fetchAll(db, sql: "SELECT url FROM link")  // [URL]
+
+ +

Use values in Records:

+
struct Link: FetchableRecord {
+    var url: URL
+    var isVerified: Bool
+
+    init(row: Row) {
+        url = row["url"]
+        isVerified = row["verified"]
+    }
+}
+
+ +

Use values in the query interface:

+
let url: URL = ...
+let link = try Link.filter(Column("url") == url).fetchOne(db)
+
+

Data (and Memory Savings)

+ +

Data suits the BLOB SQLite columns. It can be stored and fetched from the database just like other values:

+
let rows = try Row.fetchCursor(db, sql: "SELECT data, ...")
+while let row = try rows.next() {
+    let data: Data = row["data"]
+}
+
+ +

At each step of the request iteration, the row[] subscript creates two copies of the database bytes: one fetched by SQLite, and another, stored in the Swift Data value.

+ +

You have the opportunity to save memory by not copying the data fetched by SQLite:

+
while let row = try rows.next() {
+    let data = row.dataNoCopy(named: "data") // Data?
+}
+
+ +

The non-copied data does not live longer than the iteration step: make sure that you do not use it past this point.

+

Date and DateComponents

+ +

Date and DateComponents can be stored and fetched from the database.

+ +

Here is how GRDB supports the various date formats supported by SQLite:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SQLite formatDateDateComponents
YYYY-MM-DDRead ¹Read / Write
YYYY-MM-DD HH:MMRead ¹ ²Read ² / Write
YYYY-MM-DD HH:MM:SSRead ¹ ²Read ² / Write
YYYY-MM-DD HH:MM:SS.SSSRead ¹ ² / Write ¹Read ² / Write
YYYY-MM-DD*T*HH:MMRead ¹ ²Read ²
YYYY-MM-DD*T*HH:MM:SSRead ¹ ²Read ²
YYYY-MM-DD*T*HH:MM:SS.SSSRead ¹ ²Read ²
HH:MMRead ² / Write
HH:MM:SSRead ² / Write
HH:MM:SS.SSSRead ² / Write
Timestamps since unix epochRead ³
now
+ +

¹ Missing components are assumed to be zero. Dates are stored and read in the UTC time zone, unless the format is followed by a timezone indicator ⁽²⁾.

+ +

² This format may be optionally followed by a timezone indicator of the form [+-]HH:MM or just Z.

+ +

³ GRDB 2+ interprets numerical values as timestamps that fuel Date(timeIntervalSince1970:). Previous GRDB versions used to interpret numbers as julian days. Julian days are still supported, with the Date(julianDay:) initializer.

+

Date

+ +

Date can be stored and fetched from the database just like other values:

+
try db.execute(
+    sql: "INSERT INTO player (creationDate, ...) VALUES (?, ...)",
+    arguments: [Date(), ...])
+
+let row = try Row.fetchOne(db, ...)!
+let creationDate: Date = row["creationDate"]
+
+ +

Dates are stored using the format “YYYY-MM-DD HH:MM:SS.SSS” in the UTC time zone. It is precise to the millisecond.

+ +
+

:point_up: Note: this format was chosen because it is the only format that is:

+ +
    +
  • Comparable (ORDER BY date works)
  • +
  • Comparable with the SQLite keyword CURRENT_TIMESTAMP (WHERE date > CURRENT_TIMESTAMP works)
  • +
  • Able to feed SQLite date & time functions
  • +
  • Precise enough
  • +
+
+ +

When the default format does not fit your needs, customize date conversions. For example:

+
try db.execute(
+    sql: "INSERT INTO player (creationDate, ...) VALUES (?, ...)",
+    arguments: [Date().timeIntervalSinceReferenceDate, ...])
+
+let row = try Row.fetchOne(db, ...)!
+let creationDate = Date(timeIntervalSinceReferenceDate: row["creationDate"])
+
+ +

See Codable Records for more date customization options.

+

DateComponents

+ +

DateComponents is indirectly supported, through the DatabaseDateComponents helper type.

+ +

DatabaseDateComponents reads date components from all date formats supported by SQLite, and stores them in the format of your choice, from HH:MM to YYYY-MM-DD HH:MM:SS.SSS.

+ +

DatabaseDateComponents can be stored and fetched from the database just like other values:

+
let components = DateComponents()
+components.year = 1973
+components.month = 9
+components.day = 18
+
+// Store "1973-09-18"
+let dbComponents = DatabaseDateComponents(components, format: .YMD)
+try db.execute(
+    sql: "INSERT INTO player (birthDate, ...) VALUES (?, ...)",
+    arguments: [dbComponents, ...])
+
+// Read "1973-09-18"
+let row = try Row.fetchOne(db, sql: "SELECT birthDate ...")!
+let dbComponents: DatabaseDateComponents = row["birthDate"]
+dbComponents.format         // .YMD (the actual format found in the database)
+dbComponents.dateComponents // DateComponents
+
+

NSNumber, NSDecimalNumber, and Decimal

+ +

NSNumber and Decimal can be stored and fetched from the database just like other values.

+ +

Here is how GRDB supports the various data types supported by SQLite:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
IntegerDoubleString
NSNumberRead / WriteRead / WriteRead
NSDecimalNumberRead / WriteRead / WriteRead
DecimalReadReadRead / Write
+ +
    +
  • All three types can decode database integers and doubles:

    +
    let number = try NSNumber.fetchOne(db, sql: "SELECT 10")            // NSNumber
    +let number = try NSDecimalNumber.fetchOne(db, sql: "SELECT 1.23")   // NSDecimalNumber
    +let number = try Decimal.fetchOne(db, sql: "SELECT -100")           // Decimal
    +
  • +
  • All three types decode database strings as decimal numbers:

    +
    let number = try NSNumber.fetchOne(db, sql: "SELECT '10'")          // NSDecimalNumber (sic)
    +let number = try NSDecimalNumber.fetchOne(db, sql: "SELECT '1.23'") // NSDecimalNumber
    +let number = try Decimal.fetchOne(db, sql: "SELECT '-100'")         // Decimal
    +
  • +
  • NSNumber and NSDecimalNumber send 64-bit signed integers and doubles in the database:

    +
    // INSERT INTO transfer VALUES (10)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSNumber(value: 10)])
    +
    +// INSERT INTO transfer VALUES (10.0)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSNumber(value: 10.0)])
    +
    +// INSERT INTO transfer VALUES (10)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSDecimalNumber(string: "10.0")])
    +
    +// INSERT INTO transfer VALUES (10.5)
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [NSDecimalNumber(string: "10.5")])
    +
    + +
    +

    :warning: Warning: since SQLite does not support decimal numbers, sending a non-integer NSDecimalNumber can result in a loss of precision during the conversion to double.

    + +

    Instead of sending non-integer NSDecimalNumber to the database, you may prefer:

    + +
      +
    • Send Decimal instead (those store decimal strings in the database).
    • +
    • Send integers instead (for example, store amounts of cents instead of amounts of Euros).
    • +
    +
  • +
  • Decimal sends decimal strings in the database:

    +
    // INSERT INTO transfer VALUES ('10')
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [Decimal(10)])
    +
    +// INSERT INTO transfer VALUES ('10.5')
    +try db.execute(sql: "INSERT INTO transfer VALUES (?)", arguments: [Decimal(string: "10.5")!])
    +
  • +
+

UUID

+ +

UUID can be stored and fetched from the database just like other values.

+ +

GRDB stores uuids as 16-bytes data blobs, and decodes them from both 16-bytes data blobs and strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”.

+

Swift Enums

+ +

Swift enums and generally all types that adopt the RawRepresentable protocol can be stored and fetched from the database just like their raw values:

+
enum Color : Int {
+    case red, white, rose
+}
+
+enum Grape : String {
+    case chardonnay, merlot, riesling
+}
+
+// Declare empty DatabaseValueConvertible adoption
+extension Color : DatabaseValueConvertible { }
+extension Grape : DatabaseValueConvertible { }
+
+// Store
+try db.execute(
+    sql: "INSERT INTO wine (grape, color) VALUES (?, ?)",
+    arguments: [Grape.merlot, Color.red])
+
+// Read
+let rows = try Row.fetchCursor(db, sql: "SELECT * FROM wine")
+while let row = try rows.next() {
+    let grape: Grape = row["grape"]
+    let color: Color = row["color"]
+}
+
+ +

When a database value does not match any enum case, you get a fatal error. This fatal error can be avoided with the DatabaseValue type:

+
let row = try Row.fetchOne(db, sql: "SELECT 'syrah'")!
+
+row[0] as String  // "syrah"
+row[0] as Grape?  // fatal error: could not convert "syrah" to Grape.
+row[0] as Grape   // fatal error: could not convert "syrah" to Grape.
+
+let dbValue: DatabaseValue = row[0]
+if dbValue.isNull {
+    // Handle NULL
+} else if let grape = Grape.fromDatabaseValue(dbValue) {
+    // Handle valid grape
+} else {
+    // Handle unknown grape
+}
+
+

Custom Value Types

+ +

Conversion to and from the database is based on the DatabaseValueConvertible protocol:

+
protocol DatabaseValueConvertible {
+    /// Returns a value that can be stored in the database.
+    var databaseValue: DatabaseValue { get }
+
+    /// Returns a value initialized from dbValue, if possible.
+    static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self?
+}
+
+ +

All types that adopt this protocol can be used like all other values (Bool, Int, String, Date, Swift enums, etc.)

+ +

The databaseValue property returns DatabaseValue, a type that wraps the five values supported by SQLite: NULL, Int64, Double, String and Data. Since DatabaseValue has no public initializer, use DatabaseValue.null, or another type that already adopts the protocol: 1.databaseValue, "foo".databaseValue, etc. Conversion to DatabaseValue must not fail.

+ +

The fromDatabaseValue() factory method returns an instance of your custom type if the database value contains a suitable value. If the database value does not contain a suitable value, such as “foo” for Date, fromDatabaseValue must return nil (GRDB will interpret this nil result as a conversion error, and react accordingly).

+ +

Value types that adopt both DatabaseValueConvertible and an archival protocol (Codable, Encodable or Decodable) are automatically coded and decoded from JSON arrays and objects:

+
// Encoded as a JSON object in the database:
+struct Color: Codable, DatabaseValueConvertible {
+    var r: Double
+    var g: Double
+    var b: Double
+}
+
+ +

For such codable value types, GRDB uses the standard JSONDecoder and JSONEncoder from Foundation. By default, Data values are handled with the .base64 strategy, Date with the .millisecondsSince1970 strategy, and non conforming floats with the .throw strategy.

+ +

In order to customize the JSON format, provide a custom implementation of the DatabaseValueConvertible requirements.

+ +
+

:point_up: Note: standard sequences such as Array, Set, or Dictionary do not conform to DatabaseValueConvertible, even conditionally. You won’t be able to directly fetch or store arrays, sets, or dictionaries as JSON database values. You can get free JSON support from these standard types when they are embedded as properties of Codable Records, though.

+
+

Transactions and Savepoints

+ + +

Transactions and Safety

+ +

A transaction is a fundamental tool of SQLite that guarantees data consistency as well as proper isolation between application threads and database connections.

+ +

GRDB generally opens transactions for you, as a way to enforce its concurrency guarantees, and provide maximal security for both your application data and application logic:

+
// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbQueue.write { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbPool.write { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+ +

Yet you may need to exactly control when transactions take place:

+

Explicit Transactions

+ +

DatabaseQueue.inDatabase() and DatabasePool.writeWithoutTransaction() execute your database statements outside of any transaction:

+
// INSERT INTO credit ...
+// INSERT INTO debit ...
+try dbQueue.inDatabase { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+try dbPool.writeWithoutTransaction { db in
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+}
+
+ +

Writing outside of any transaction is dangerous, for two reasons:

+ +
    +
  • In our credit/debit example, you may successfully insert a credit, but fail inserting the debit, and end up with unbalanced accounts (oops).

    +
    // UNSAFE DATABASE INTEGRITY
    +try dbQueue.inDatabase { db in // or dbPool.writeWithoutTransaction
    +    try Credit(destinationAccount, amount).insert(db) // may succeed
    +    try Debit(sourceAccount, amount).insert(db)      // may fail
    +}
    +
    + +

    Transactions avoid this kind of bug.

  • +
  • Database pool concurrent reads can see an inconsistent state of the database:

    +
    // UNSAFE CONCURRENCY
    +try dbPool.writeWithoutTransaction { db in
    +    try Credit(destinationAccount, amount).insert(db)
    +    // <- Concurrent dbPool.read sees a partial db update here
    +    try Debit(sourceAccount, amount).insert(db)
    +}
    +
    + +

    Transactions avoid this kind of bug, too.

  • +
+ +

To open explicit transactions, use one of the Database.inTransaction, DatabaseQueue.inTransaction, or DatabasePool.writeInTransaction methods:

+
// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbQueue.inDatabase { db in  // or dbPool.writeWithoutTransaction
+    try db.inTransaction {
+        try Credit(destinationAccount, amount).insert(db)
+        try Debit(sourceAccount, amount).insert(db)
+        return .commit
+    }
+}
+
+// BEGIN TRANSACTION
+// INSERT INTO credit ...
+// INSERT INTO debit ...
+// COMMIT
+try dbQueue.inTransaction { db in  // or dbPool.writeInTransaction
+    try Credit(destinationAccount, amount).insert(db)
+    try Debit(sourceAccount, amount).insert(db)
+    return .commit
+}
+
+ +

If an error is thrown from the transaction block, the transaction is rollbacked and the error is rethrown by the inTransaction method. If you return .rollback instead of .commit, the transaction is also rollbacked, but no error is thrown.

+ +

You can also perform manual transaction management:

+
try dbQueue.inDatabase { db in  // or dbPool.writeWithoutTransaction
+    try db.beginTransaction()
+    ...
+    try db.commit()
+
+    try db.execute(sql: "BEGIN TRANSACTION")
+    ...
+    try db.execute(sql: "ROLLBACK")
+}
+
+ +

Transactions can’t be left opened unless you set the allowsUnsafeTransactions configuration flag:

+
// fatal error: A transaction has been left opened at the end of a database access
+try dbQueue.inDatabase { db in
+    try db.execute(sql: "BEGIN TRANSACTION")
+    // <- no commit or rollback
+}
+
+ +

You can ask if a transaction is currently opened:

+
func myCriticalMethod(_ db: Database) throws {
+    precondition(db.isInsideTransaction, "This method requires a transaction")
+    try ...
+}
+
+ +

Yet, you have a better option than checking for transactions: critical database sections should use savepoints, described below:

+
func myCriticalMethod(_ db: Database) throws {
+    try db.inSavepoint {
+        // Here the database is guaranteed to be inside a transaction.
+        try ...
+    }
+}
+
+

Savepoints

+ +

Statements grouped in a savepoint can be rollbacked without invalidating a whole transaction:

+
try dbQueue.write { db in
+    // Makes sure both inserts succeed, or none:
+    try db.inSavepoint {
+        try Credit(destinationAccount, amount).insert(db)
+        try Debit(sourceAccount, amount).insert(db)
+        return .commit
+    }
+
+    // Other savepoints, etc...
+}
+
+ +

If an error is thrown from the savepoint block, the savepoint is rollbacked and the error is rethrown by the inSavepoint method. If you return .rollback instead of .commit, the savepoint is also rollbacked, but no error is thrown.

+ +

Unlike transactions, savepoints can be nested. They implicitly open a transaction if no one was opened when the savepoint begins. As such, they behave just like nested transactions. Yet the database changes are only written to disk when the outermost transaction is committed:

+
try dbQueue.inDatabase { db in
+    try db.inSavepoint {
+        ...
+        try db.inSavepoint {
+            ...
+            return .commit
+        }
+        ...
+        return .commit  // writes changes to disk
+    }
+}
+
+ +

SQLite savepoints are more than nested transactions, though. For advanced uses, use SQLite savepoint documentation.

+

Transaction Kinds

+ +

SQLite supports three kinds of transactions: deferred (the default), immediate, and exclusive.

+ +

The transaction kind can be changed in the database configuration, or for each transaction:

+
// 1) Default configuration:
+let dbQueue = try DatabaseQueue(path: "...")
+
+// BEGIN DEFERED TRANSACTION ...
+dbQueue.write { db in ... }
+
+// BEGIN EXCLUSIVE TRANSACTION ...
+dbQueue.inTransaction(.exclusive) { db in ... }
+
+// 2) Customized default transaction kind:
+var config = Configuration()
+config.defaultTransactionKind = .immediate
+let dbQueue = try DatabaseQueue(path: "...", configuration: config)
+
+// BEGIN IMMEDIATE TRANSACTION ...
+dbQueue.write { db in ... }
+
+// BEGIN EXCLUSIVE TRANSACTION ...
+dbQueue.inTransaction(.exclusive) { db in ... }
+
+

Prepared Statements

+ +

Prepared Statements let you prepare an SQL query and execute it later, several times if you need, with different arguments.

+
try dbQueue.write { db in
+    let insertSQL = "INSERT INTO player (name, score) VALUES (:name, :score)"
+    let insertStatement = try db.makeStatement(sql: insertSQL)
+
+    let selectSQL = "SELECT * FROM player WHERE name = ?"
+    let selectStatement = try db.makeStatement(sql: selectSQL)
+}
+
+ +

The ? and colon-prefixed keys like :name in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type StatementArguments, which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols).

+
insertStatement.arguments = ["name": "Arthur", "score": 1000]
+selectStatement.arguments = ["Arthur"]
+
+ +

Alternatively, you can create a prepared statement with SQL Interpolation:

+
let insertStatement = try db.makeStatement(literal: "INSERT ...")
+let selectStatement = try db.makeStatement(literal: "SELECT ...")
+//                                         ~~~~~~~
+
+ +

Statements can be executed:

+
try insertStatement.execute()
+
+ +

Statements can be used wherever a raw SQL query string would fit (see fetch queries):

+
let rows = try Row.fetchCursor(selectStatement)    // A Cursor of Row
+let players = try Player.fetchAll(selectStatement) // [Player]
+let players = try Player.fetchSet(selectStatement) // Set<Player>
+let player = try Player.fetchOne(selectStatement)  // Player?
+
+ +

You can set the arguments at the moment of the statement execution:

+
try insertStatement.execute(arguments: ["name": "Arthur", "score": 1000])
+let player = try Player.fetchOne(selectStatement, arguments: ["Arthur"])
+
+ +

When you want to build multiple statements joined with a semicolon, use the allStatements method:

+
let statements = try db.allStatements(sql: """
+    INSERT INTO player (name, score) VALUES (?, ?);
+    INSERT INTO player (name, score) VALUES (?, ?);
+    """, arguments: ["Arthur", 100, "O'Brien", 1000])
+while let statement = try statements.next() {
+    try statement.execute()
+}
+
+ +

allStatements also supports SQL Interpolation:

+
let statements = try db.allStatements(literal: """
+    INSERT INTO player (name, score) VALUES (\("Arthur"), \(100));
+    INSERT INTO player (name, score) VALUES (\("O'Brien"), \(1000));
+    """)
+while let statement = try statements.next() {
+    try statement.execute()
+}
+
+ +

You can turn the cursor returned from allStatements into a regular Swift array, but in this case make sure all individual statements can compile even if the previous ones were not run:

+
// OK: Array of statements
+let statements = try Array(db.allStatements(sql: """
+    INSERT ...; 
+    UPDATE ...; 
+    SELECT ...;
+    """))
+
+// FAILURE: Can't build an array of statements since 
+// the INSERT won't compile until CREATE TABLE is run.
+let statements = try Array(db.allStatements(sql: """
+    CREATE TABLE player ...; 
+    INSERT INTO player ...;
+    """))
+
+ +

See also Database.execute(sql:) in the Executing Updates chapter.

+ +
+

:point_up: Note: it is a programmer error to reuse a prepared statement that has failed: GRDB may crash if you do so.

+
+ +

For more information about prepared statements, see the Statement reference.

+

Prepared Statements Cache

+ +

When the same query will be used several times in the lifetime of your application, you may feel a natural desire to cache prepared statements.

+ +

Don’t cache statements yourself.

+ +
+

:point_up: Note: This is because you don’t have the necessary tools. Statements are tied to specific SQLite connections and dispatch queues which you don’t manage yourself, especially when you use database pools. A change in the database schema may, or may not invalidate a statement.

+
+ +

Instead, use the cachedStatement method. GRDB does all the hard caching and memory management stuff for you:

+
let statement = try db.cachedStatement(sql: sql)
+
+ +

Cached statements also support SQL Interpolation:

+
let statement = try db.cachedStatement(literal: "INSERT ...")
+//                                     ~~~~~~~
+
+ +
+

:warning: Warning: Should a cached prepared statement throw an error, don’t reuse it (it is a programmer error). Instead, reload one from the cache.

+
+

Custom SQL Functions and Aggregates

+ +

SQLite lets you define SQL functions and aggregates.

+ +

A custom SQL function or aggregate extends SQLite:

+
SELECT reverse(name) FROM player;   -- custom function
+SELECT maxLength(name) FROM player; -- custom aggregate
+
+ + +

Custom SQL Functions

+ +

A function argument takes an array of DatabaseValue, and returns any valid value (Bool, Int, String, Date, Swift enums, etc.) The number of database values is guaranteed to be argumentCount.

+ +

SQLite has the opportunity to perform additional optimizations when functions are “pure”, which means that their result only depends on their arguments. So make sure to set the pure argument to true when possible.

+
let reverse = DatabaseFunction("reverse", argumentCount: 1, pure: true) { (values: [DatabaseValue]) in
+    // Extract string value, if any...
+    guard let string = String.fromDatabaseValue(values[0]) else {
+        return nil
+    }
+    // ... and return reversed string:
+    return String(string.reversed())
+}
+
+ +

You make a function available to a database connection through its configuration:

+
var config = Configuration()
+config.prepareDatabase { db in
+    db.add(function: reverse)
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    // "oof"
+    try String.fetchOne(db, sql: "SELECT reverse('foo')")!
+}
+
+ +

Functions can take a variable number of arguments:

+ +

When you don’t provide any explicit argumentCount, the function can take any number of arguments:

+
let averageOf = DatabaseFunction("averageOf", pure: true) { (values: [DatabaseValue]) in
+    let doubles = values.compactMap { Double.fromDatabaseValue($0) }
+    return doubles.reduce(0, +) / Double(doubles.count)
+}
+db.add(function: averageOf)
+
+// 2.0
+try Double.fetchOne(db, sql: "SELECT averageOf(1, 2, 3)")!
+
+ +

Functions can throw:

+
let sqrt = DatabaseFunction("sqrt", argumentCount: 1, pure: true) { (values: [DatabaseValue]) in
+    guard let double = Double.fromDatabaseValue(values[0]) else {
+        return nil
+    }
+    guard double >= 0 else {
+        throw DatabaseError(message: "invalid negative number")
+    }
+    return sqrt(double)
+}
+db.add(function: sqrt)
+
+// SQLite error 1 with statement `SELECT sqrt(-1)`: invalid negative number
+try Double.fetchOne(db, sql: "SELECT sqrt(-1)")!
+
+ +

Use custom functions in the query interface:

+
// SELECT reverseString("name") FROM player
+Player.select(reverseString(nameColumn))
+
+ +

GRDB ships with built-in SQL functions that perform unicode-aware string transformations. See Unicode.

+

Custom Aggregates

+ +

Before registering a custom aggregate, you need to define a type that adopts the DatabaseAggregate protocol:

+
protocol DatabaseAggregate {
+    // Initializes an aggregate
+    init()
+
+    // Called at each step of the aggregation
+    mutating func step(_ dbValues: [DatabaseValue]) throws
+
+    // Returns the final result
+    func finalize() throws -> DatabaseValueConvertible?
+}
+
+ +

For example:

+
struct MaxLength : DatabaseAggregate {
+    var maxLength: Int = 0
+
+    mutating func step(_ dbValues: [DatabaseValue]) {
+        // At each step, extract string value, if any...
+        guard let string = String.fromDatabaseValue(dbValues[0]) else {
+            return
+        }
+        // ... and update the result
+        let length = string.count
+        if length > maxLength {
+            maxLength = length
+        }
+    }
+
+    func finalize() -> DatabaseValueConvertible? {
+        maxLength
+    }
+}
+
+let maxLength = DatabaseFunction(
+    "maxLength",
+    argumentCount: 1,
+    pure: true,
+    aggregate: MaxLength.self)
+
+ +

Like custom SQL Functions, you make an aggregate function available to a database connection through its configuration:

+
var config = Configuration()
+config.prepareDatabase { db in
+    db.add(function: maxLength)
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    // Some Int
+    try Int.fetchOne(db, sql: "SELECT maxLength(name) FROM player")!
+}
+
+ +

The step method of the aggregate takes an array of DatabaseValue. This array contains as many values as the argumentCount parameter (or any number of values, when argumentCount is omitted).

+ +

The finalize method of the aggregate returns the final aggregated value (Bool, Int, String, Date, Swift enums, etc.).

+ +

SQLite has the opportunity to perform additional optimizations when aggregates are “pure”, which means that their result only depends on their inputs. So make sure to set the pure argument to true when possible.

+ +

Use custom aggregates in the query interface:

+
// SELECT maxLength("name") FROM player
+let request = Player.select(maxLength.apply(nameColumn))
+try Int.fetchOne(db, request) // Int?
+
+

Database Schema Introspection

+ +

GRDB comes with a set of schema introspection methods:

+
try dbQueue.read { db in
+    // Bool, true if the table exists
+    try db.tableExists("player")
+
+    // [ColumnInfo], the columns in the table
+    try db.columns(in: "player")
+
+    // PrimaryKeyInfo
+    try db.primaryKey("player")
+
+    // [ForeignKeyInfo], the foreign keys defined on the table
+    try db.foreignKeys(on: "player")
+
+    // [IndexInfo], the indexes defined on the table
+    try db.indexes(on: "player")
+
+    // Bool, true if column(s) is a unique key (primary key or unique index)
+    try db.table("player", hasUniqueKey: ["email"])
+}
+
+// Bool, true if argument is the name of an internal SQLite table
+Database.isSQLiteInternalTable(...)
+
+// Bool, true if argument is the name of an internal GRDB table
+Database.isGRDBInternalTable(...)
+
+

Row Adapters

+ +

Row adapters let you present database rows in the way expected by the row consumers.

+ +

They basically help two incompatible row interfaces to work together. For example, a row consumer expects a column named “consumed”, but the produced row has a column named “produced”.

+ +

In this case, the ColumnMapping row adapter comes in handy:

+
// Turn the 'produced' column into 'consumed':
+let adapter = ColumnMapping(["consumed": "produced"])
+let row = try Row.fetchOne(db, sql: "SELECT 'Hello' AS produced", adapter: adapter)!
+
+// [consumed:"Hello"]
+print(row)
+
+// "Hello"
+print(row["consumed"])
+
+// ▿ [consumed:"Hello"]
+//   unadapted: [produced:"Hello"]
+print(row.debugDescription)
+
+// [produced:"Hello"]
+print(row.unadapted)
+
+ +

Record types are typical row consumers that expect database rows to have a specific layout so that they can decode them:

+
struct MyRecord: Decodable, FetchableRecord {
+    var consumed: String
+}
+let record = try MyRecord.fetchOne(db, sql: "SELECT 'Hello' AS produced", adapter: adapter)!
+print(record.consumed) // "Hello"
+
+ +

There are several situations where row adapters are useful:

+ +
    +
  • They help disambiguate columns with identical names, which may happen when you select columns from several tables. See Joined Queries Support for an example.

  • +
  • They help when SQLite outputs unexpected column names, which may happen with some subqueries. See RenameColumnAdapter for an example.

  • +
+ +

Available row adapters are described below.

+ + +

ColumnMapping

+ +

ColumnMapping renames columns. Build one with a dictionary whose keys are adapted column names, and values the column names in the raw row:

+
// [newA:0, newB:1]
+let adapter = ColumnMapping(["newA": "a", "newB": "b"])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+ +

Note that columns that are not present in the dictionary are not present in the resulting adapted row.

+

EmptyRowAdapter

+ +

EmptyRowAdapter hides all columns.

+
let adapter = EmptyRowAdapter()
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+row.isEmpty // true
+
+ +

This limit adapter may turn out useful in some narrow use cases. You’ll be happy to find it when you need it.

+

RangeRowAdapter

+ +

RangeRowAdapter only exposes a range of columns.

+
// [b:1]
+let adapter = RangeRowAdapter(1..<2)
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+

RenameColumnAdapter

+ +

RenameColumnAdapter lets you transform column names with a function:

+
// [arrr:0, brrr:1, crrr:2]
+let adapter = RenameColumnAdapter { column in column + "rrr" }
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+ +

This adapter may turn out useful, for example, when subqueries contain duplicated column names:

+
let sql = "SELECT * FROM (SELECT 1 AS id, 2 AS id)"
+
+// Prints ["id", "id:1"]
+// Note the "id:1" column, generated by SQLite.
+let row = try Row.fetchOne(db, sql: sql)!
+print(Array(row.columnNames))
+
+// Drop the `:...` suffix, and prints ["id", "id"]
+let adapter = RenameColumnAdapter { String($0.prefix(while: { $0 != ":" })) }
+let adaptedRow = try Row.fetchOne(db, sql: sql, adapter: adapter)!
+print(Array(adaptedRow.columnNames))
+
+

ScopeAdapter

+ +

ScopeAdapter defines row scopes:

+
let adapter = ScopeAdapter([
+    "left": RangeRowAdapter(0..<2),
+    "right": RangeRowAdapter(2..<4)])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
+
+ +

ScopeAdapter does not change the columns and values of the fetched row. Instead, it defines scopes, which you access through the Row.scopes property:

+
row                   // [a:0 b:1 c:2 d:3]
+row.scopes["left"]    // [a:0 b:1]
+row.scopes["right"]   // [c:2 d:3]
+row.scopes["missing"] // nil
+
+ +

Scopes can be nested:

+
let adapter = ScopeAdapter([
+    "left": ScopeAdapter([
+        "left": RangeRowAdapter(0..<1),
+        "right": RangeRowAdapter(1..<2)]),
+    "right": ScopeAdapter([
+        "left": RangeRowAdapter(2..<3),
+        "right": RangeRowAdapter(3..<4)])
+    ])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
+
+let leftRow = row.scopes["left"]!
+leftRow.scopes["left"]  // [a:0]
+leftRow.scopes["right"] // [b:1]
+
+let rightRow = row.scopes["right"]!
+rightRow.scopes["left"]  // [c:2]
+rightRow.scopes["right"] // [d:3]
+
+ +

Any adapter can be extended with scopes:

+
let baseAdapter = RangeRowAdapter(0..<2)
+let adapter = ScopeAdapter(base: baseAdapter, scopes: [
+    "remainder": SuffixRowAdapter(fromIndex: 2)])
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c, 3 AS d", adapter: adapter)!
+
+row // [a:0 b:1]
+row.scopes["remainder"] // [c:2 d:3]
+
+ +

To see how ScopeAdapter can be used, see Joined Queries Support.

+

SuffixRowAdapter

+ +

SuffixRowAdapter hides the first columns in a row:

+
// [b:1 c:2]
+let adapter = SuffixRowAdapter(fromIndex: 1)
+let row = try Row.fetchOne(db, sql: "SELECT 0 AS a, 1 AS b, 2 AS c", adapter: adapter)!
+
+

Raw SQLite Pointers

+ +

If not all SQLite APIs are exposed in GRDB, you can still use the SQLite C Interface and call SQLite C functions.

+ +

Those functions are embedded right into the GRDB module, regardless of the underlying SQLite implementation (system SQLite, SQLCipher, or custom SQLite build):

+
import GRDB
+
+let sqliteVersion = String(cString: sqlite3_libversion())
+
+ +

Raw pointers to database connections and statements are available through the Database.sqliteConnection and Statement.sqliteStatement properties:

+
try dbQueue.read { db in
+    // The raw pointer to a database connection:
+    let sqliteConnection = db.sqliteConnection
+
+    // The raw pointer to a statement:
+    let statement = try db.makeStatement(sql: "SELECT ...")
+    let sqliteStatement = statement.sqliteStatement
+}
+
+ +
+

:point_up: Notes

+ +
    +
  • Those pointers are owned by GRDB: don’t close connections or finalize statements created by GRDB.
  • +
  • GRDB opens SQLite connections in the “multi-thread mode”, which (oddly) means that they are not thread-safe. Make sure you touch raw databases and statements inside their dedicated dispatch queues.
  • +
  • Use the raw SQLite C Interface at your own risk. GRDB won’t prevent you from shooting yourself in the foot.
  • +
+
+

Records

+ +

On top of the SQLite API, GRDB provides protocols and a class that help manipulating database rows as regular objects named “records”:

+
try dbQueue.write { db in
+    if var place = try Place.fetchOne(db, id: 1) {
+        place.isFavorite = true
+        try place.update(db)
+    }
+}
+
+ +

Of course, you need to open a database connection, and create database tables first.

+ +

To define your custom records, you subclass the ready-made Record class, or you extend your structs and classes with protocols that come with focused sets of features: fetching methods, persistence methods, record comparison…

+ +

Extending structs with record protocols is more “swifty”. Subclassing the Record class is more “classic”. You can choose either way. See some examples of record definitions, and the list of record methods for an overview.

+ +
+

:point_up: Note: if you are familiar with Core Data’s NSManagedObject or Realm’s Object, you may experience a cultural shock: GRDB records are not uniqued, do not auto-update, and do not lazy-load. This is both a purpose, and a consequence of protocol-oriented programming. You should read How to build an iOS application with SQLite and GRDB.swift for a general introduction.

+ +

:bulb: Tip: after you have read this chapter, check the Good Practices for Designing Record Types Guide.

+ +

:bulb: Tip: see the Demo Applications for sample apps that uses records.

+
+ +

Overview

+ + + +

Protocols and the Record Class

+ + + +

Records in a Glance

+ + +

Inserting Records

+ +

To insert a record in the database, call the insert method:

+
let player = Player(name: "Arthur", email: "arthur@example.com")
+try player.insert(db)
+
+ +

:point_right: insert is available for subclasses of the Record class, and types that adopt the PersistableRecord protocol.

+

Fetching Records

+ +

To fetch records from the database, call a fetching method:

+
let arthur = try Player.fetchOne(db,            // Player?
+    sql: "SELECT * FROM players WHERE name = ?",
+    arguments: ["Arthur"])
+
+let bestPlayers = try Player                    // [Player]
+    .order(Column("score").desc)
+    .limit(10)
+    .fetchAll(db)
+
+let spain = try Country.fetchOne(db, id: "ES")  // Country?
+
+ +

:point_right: Fetching from raw SQL is available for subclasses of the Record class, and types that adopt the FetchableRecord protocol.

+ +

:point_right: Fetching without SQL, using the query interface, is available for subclasses of the Record class, and types that adopt both FetchableRecord and TableRecord protocol.

+

Updating Records

+ +

To update a record in the database, call the update method:

+
var player: Player = ...
+player.score = 1000
+try player.update(db)
+
+ +

It is possible to avoid useless updates:

+
// does not hit the database if score has not changed
+try player.updateChanges(db) {
+    $0.score = 1000
+}
+
+ +

See the query interface for batch updates:

+
try Player
+    .filter(Column("team") == "red")
+    .updateAll(db, Column("score") += 1)
+
+ +

:point_right: update methods are available for subclasses of the Record class, and types that adopt the PersistableRecord protocol. Batch updates are available on the TableRecord protocol.

+

Deleting Records

+ +

To delete a record in the database, call the delete method:

+
let player: Player = ...
+try player.delete(db)
+
+ +

You can also delete by primary key, unique key, or perform batch deletes (see Delete Requests):

+
try Player.deleteOne(db, id: 1)
+try Player.deleteOne(db, key: ["email": "arthur@example.com"])
+try Country.deleteAll(db, ids: ["FR", "US"])
+try Player
+    .filter(Column("email") == nil)
+    .deleteAll(db)
+
+ +

:point_right: delete methods are available for subclasses of the Record class, and types that adopt the PersistableRecord protocol. Batch deletes are available on the TableRecord protocol.

+

Counting Records

+ +

To count records, call the fetchCount method:

+
let playerCount: Int = try Player.fetchCount(db)
+
+let playerWithEmailCount: Int = try Player
+    .filter(Column("email") == nil)
+    .fetchCount(db)
+
+ +

:point_right: fetchCount is available for subclasses of the Record class, and types that adopt the TableRecord protocol.

+ +

Details follow:

+ + +

Record Protocols Overview

+ +

GRDB ships with three record protocols. Your own types will adopt one or several of them, according to the abilities you want to extend your types with.

+ +
    +
  • FetchableRecord is able to decode database rows.

    +
    struct Place: FetchableRecord { ... }
    +let places = try dbQueue.read { db in
    +    try Place.fetchAll(db, sql: "SELECT * FROM place")
    +}
    +
    + +
    +

    :bulb: Tip: FetchableRecord can derive its implementation from the standard Decodable protocol. See Codable Records for more information.

    +
    + +

    FetchableRecord can decode database rows, but it is not able to build SQL requests for you. For that, you also need TableRecord:

  • +
  • TableRecord is able to generate SQL queries:

    +
    struct Place: TableRecord { ... }
    +let placeCount = try dbQueue.read { db in
    +    // Generates and runs `SELECT COUNT(*) FROM place`
    +    try Place.fetchCount(db)
    +}
    +
    + +

    When a type adopts both TableRecord and FetchableRecord, it can load from those requests:

    +
    struct Place: TableRecord, FetchableRecord { ... }
    +try dbQueue.read { db in
    +    let places = try Place.order(Column("title")).fetchAll(db)
    +    let paris = try Place.fetchOne(id: 1)
    +}
    +
  • +
  • PersistableRecord is able to write: it can create, update, and delete rows in the database:

    +
    struct Place : PersistableRecord { ... }
    +try dbQueue.write { db in
    +    try Place.delete(db, id: 1)
    +    try Place(...).insert(db)
    +}
    +
    + +

    A persistable record can also compare itself against other records, and avoid useless database updates.

    + +
    +

    :bulb: Tip: PersistableRecord can derive its implementation from the standard Encodable protocol. See Codable Records for more information.

    +
  • +
+

FetchableRecord Protocol

+ +

The FetchableRecord protocol grants fetching methods to any type that can be built from a database row:

+
protocol FetchableRecord {
+    /// Row initializer
+    init(row: Row)
+}
+
+ +

To use FetchableRecord, subclass the Record class, or adopt it explicitly. For example:

+
struct Place {
+    var id: Int64?
+    var title: String
+    var coordinate: CLLocationCoordinate2D
+}
+
+extension Place : FetchableRecord {
+    init(row: Row) {
+        id = row["id"]
+        title = row["title"]
+        coordinate = CLLocationCoordinate2D(
+            latitude: row["latitude"],
+            longitude: row["longitude"])
+    }
+}
+
+ +

Rows also accept column enums:

+
extension Place : FetchableRecord {
+    enum Columns: String, ColumnExpression {
+        case id, title, latitude, longitude
+    }
+
+    init(row: Row) {
+        id = row[Columns.id]
+        title = row[Columns.title]
+        coordinate = CLLocationCoordinate2D(
+            latitude: row[Columns.latitude],
+            longitude: row[Columns.longitude])
+    }
+}
+
+ +

See column values for more information about the row[] subscript.

+ +

When your record type adopts the standard Decodable protocol, you don’t have to provide the implementation for init(row:). See Codable Records for more information:

+
// That's all
+struct Player: Decodable, FetchableRecord {
+    var id: Int64
+    var name: String
+    var score: Int
+}
+
+ +

FetchableRecord allows adopting types to be fetched from SQL queries:

+
try Place.fetchCursor(db, sql: "SELECT ...", arguments:...) // A Cursor of Place
+try Place.fetchAll(db, sql: "SELECT ...", arguments:...)    // [Place]
+try Place.fetchSet(db, sql: "SELECT ...", arguments:...)    // Set<Place>
+try Place.fetchOne(db, sql: "SELECT ...", arguments:...)    // Place?
+
+ +

See fetching methods for information about the fetchCursor, fetchAll, fetchSet and fetchOne methods. See StatementArguments for more information about the query arguments.

+ +
+

:point_up: Note: for performance reasons, the same row argument to init(row:) is reused during the iteration of a fetch query. If you want to keep the row for later use, make sure to store a copy: self.row = row.copy().

+ +

:point_up: Note: The FetchableRecord.init(row:) initializer fits the needs of most applications. But some application are more demanding than others. When FetchableRecord does not exactly provide the support you need, have a look at the Beyond FetchableRecord chapter.

+
+

TableRecord Protocol

+ +

The TableRecord protocol generates SQL for you. To use TableRecord, subclass the Record class, or adopt it explicitly:

+
protocol TableRecord {
+    static var databaseTableName: String { get }
+    static var databaseSelection: [SQLSelectable] { get }
+}
+
+ +

The databaseSelection type property is optional, and documented in the Columns Selected by a Request chapter.

+ +

The databaseTableName type property is the name of a database table. By default, it is derived from the type name:

+
struct Place: TableRecord { }
+print(Place.databaseTableName) // prints "place"
+
+ +

For example:

+ +
    +
  • Place: place
  • +
  • Country: country
  • +
  • PostalAddress: postalAddress
  • +
  • HTTPRequest: httpRequest
  • +
  • TOEFL: toefl
  • +
+ +

You can still provide a custom table name:

+
struct Place: TableRecord {
+    static let databaseTableName = "location"
+}
+print(Place.databaseTableName) // prints "location"
+
+ +

Subclasses of the Record class must always override their superclass’s databaseTableName property:

+
class Place: Record {
+    override class var databaseTableName: String { "place" }
+}
+print(Place.databaseTableName) // prints "place"
+
+ +

When a type adopts both TableRecord and FetchableRecord, it can be fetched using the query interface:

+
// SELECT * FROM place WHERE name = 'Paris'
+let paris = try Place.filter(nameColumn == "Paris").fetchOne(db)
+
+ +

TableRecord can also fetch deal with primary and unique keys: see Fetching by Key and Testing for Record Existence.

+

PersistableRecord Protocol

+ +

GRDB record types can create, update, and delete rows in the database.

+ +

Those abilities are granted by three protocols:

+
// Defines how a record encodes itself into the database
+protocol EncodableRecord {
+    /// Defines the values persisted in the database
+    func encode(to container: inout PersistenceContainer)
+}
+
+// Adds persistence methods
+protocol MutablePersistableRecord: TableRecord, EncodableRecord {
+    /// Optional method that lets your adopting type store its rowID upon
+    /// successful insertion. Don't call it directly: it is called for you.
+    mutating func didInsert(with rowID: Int64, for column: String?)
+}
+
+// Adds immutability
+protocol PersistableRecord: MutablePersistableRecord {
+    /// Non-mutating version of the optional didInsert(with:for:)
+    func didInsert(with rowID: Int64, for column: String?)
+}
+
+ +

Yes, three protocols instead of one. Here is how you pick one or the other:

+ +
    +
  • If your type is a class, choose PersistableRecord. On top of that, implement didInsert(with:for:) if the database table has an auto-incremented primary key.

  • +
  • If your type is a struct, and the database table has an auto-incremented primary key, choose MutablePersistableRecord, and implement didInsert(with:for:).

  • +
  • Otherwise, choose PersistableRecord, and ignore didInsert(with:for:).

  • +
+ +

The encode(to:) method defines which values (Bool, Int, String, Date, Swift enums, etc.) are assigned to database columns.

+ +

The optional didInsert method lets the adopting type store its rowID after successful insertion, and is only useful for tables that have an auto-incremented primary key. It is called from a protected dispatch queue, and serialized with all database updates.

+ +

To use the persistable protocols, subclass the Record class, or adopt one of them explicitly. For example:

+
extension Place : MutablePersistableRecord {
+    /// The values persisted in the database
+    func encode(to container: inout PersistenceContainer) {
+        container["id"] = id
+        container["title"] = title
+        container["latitude"] = coordinate.latitude
+        container["longitude"] = coordinate.longitude
+    }
+
+    // Update auto-incremented id upon successful insertion
+    mutating func didInsert(with rowID: Int64, for column: String?) {
+        id = rowID
+    }
+}
+
+var paris = Place(
+    id: nil,
+    title: "Paris",
+    coordinate: CLLocationCoordinate2D(latitude: 48.8534100, longitude: 2.3488000))
+
+try paris.insert(db)
+paris.id   // some value
+
+ +

Persistence containers also accept column enums:

+
extension Place : MutablePersistableRecord {
+    enum Columns: String, ColumnExpression {
+        case id, title, latitude, longitude
+    }
+
+    func encode(to container: inout PersistenceContainer) {
+        container[Columns.id] = id
+        container[Columns.title] = title
+        container[Columns.latitude] = coordinate.latitude
+        container[Columns.longitude] = coordinate.longitude
+    }
+}
+
+ +

When your record type adopts the standard Encodable protocol, you don’t have to provide the implementation for encode(to:). See Codable Records for more information:

+
// That's all
+struct Player: Encodable, MutablePersistableRecord {
+    var id: Int64?
+    var name: String
+    var score: Int
+
+    // Update auto-incremented id upon successful insertion
+    mutating func didInsert(with rowID: Int64, for column: String?) {
+        id = rowID
+    }
+}
+
+

Persistence Methods

+ +

Record subclasses and types that adopt PersistableRecord are given default implementations for methods that insert, update, and delete:

+
// INSERT
+try place.insert(db)
+let insertedPlace = try place.inserted(db) // non-mutating
+
+// UPDATE
+try place.update(db)
+try place.update(db, columns: ["title"])
+
+// Maybe UPDATE
+try place.updateChanges(db, from: otherPlace)
+try place.updateChanges(db) { $0.isFavorite = true }
+try place.updateChanges(db) // Record class only
+
+// INSERT or UPDATE
+try place.save(db)
+let savedPlace = place.saved(db) // non-mutating
+
+// DELETE
+try place.delete(db)
+
+// EXISTENCE CHECK
+let exists = try place.exists(db)
+
+ +

The TableRecord protocol comes with batch operations:

+
// UPDATE
+try Place.updateAll(db, ...)
+
+// DELETE
+try Place.deleteAll(db)
+try Place.deleteAll(db, ids:...)
+try Place.deleteAll(db, keys:...)
+try Place.deleteOne(db, id:...)
+try Place.deleteOne(db, key:...)
+
+ +
    +
  • All those methods can throw a DatabaseError.

  • +
  • update and updateChanges throw PersistenceError if the database does not contain any row for the primary key of the record.

  • +
  • save makes sure your values are stored in the database. It performs an UPDATE if the record has a non-null primary key, and then, if no row was modified, an INSERT. It directly performs an INSERT if the record has no primary key, or a null primary key.

  • +
  • delete and deleteOne returns whether a database row was deleted or not. deleteAll returns the number of deleted rows. updateAll returns the number of updated rows. updateChanges returns whether a database row was updated or not.

  • +
+ +

All primary keys are supported, including composite primary keys that span several columns, and the implicit rowid primary key.

+

Customizing the Persistence Methods

+ +

Your custom type may want to perform extra work when the persistence methods are invoked.

+ +

For example, it may want to have its UUID automatically set before inserting. Or it may want to validate its values before saving.

+ +

When you subclass Record, you simply have to override the customized method, and call super:

+
class Player : Record {
+    var uuid: UUID?
+
+    override func insert(_ db: Database) throws {
+        if uuid == nil {
+            uuid = UUID()
+        }
+        try super.insert(db)
+    }
+}
+
+ +

If you use the raw PersistableRecord protocol, use one of the special methods performInsert, performUpdate, performSave, performDelete, or performExists:

+
struct Link : PersistableRecord {
+    var url: URL
+
+    func insert(_ db: Database) throws {
+        try validate()
+        try performInsert(db)
+    }
+
+    func update(_ db: Database, columns: Set<String>) throws {
+        try validate()
+        try performUpdate(db, columns: columns)
+    }
+
+    func validate() throws {
+        if url.host == nil {
+            throw ValidationError("url must be absolute.")
+        }
+    }
+}
+
+ +
+

:point_up: Note: the special methods performInsert, performUpdate, etc. are reserved for your custom implementations. Do not use them elsewhere. Do not provide another implementation for those methods.

+ +

:point_up: Note: it is recommended that you do not implement your own version of the save method. Its default implementation forwards the job to update or insert: these are the methods that may need customization, not save.

+
+

Identifiable Records

+ +

When a record type maps a table with a single-column primary key, it is recommended to have it adopt the standard Identifiable protocol.

+
struct Player: Identifiable, FetchableRecord, PersistableRecord {
+    var id: Int64 // fulfills the Identifiable requirement
+    var name: String
+    var score: Int
+}
+
+ +

When id has a database-compatible type (Int64, Int, String, UUID, …), the Identifiable conformance unlocks type-safe record and request methods:

+
let player = try Player.fetchOne(db, id: 1)
+let players = try Player.fetchAll(db, ids: [1, 2, 3])
+let players = try Player.fetchSet(db, ids: [1, 2, 3])
+
+let request = Player.filter(id: 1)
+let request = Player.filter(ids: [1, 2, 3])
+
+let ids = try Player.selectID().fetchAll(db)
+let ids = try Player.filter(...).selectID().fetchSet(db)
+
+try Player.deleteOne(db, id: 1)
+try Player.deleteAll(db, ids: [1, 2, 3])
+
+ +
+

:point_up: Note: Identifiable is not available on all application targets, and not all tables have a single-column primary key. GRDB provides other methods that deal with primary and unique keys, but they won’t check the type of their arguments:

+
// Those methods are not type-checked
+try Player.fetchOne(db, key: 1)
+try Player.fetchOne(db, key: ["email": "arthur@example.com"])
+try Country.fetchAll(db, keys: ["FR", "US"])
+try Citizenship.fetchOne(db, key: ["citizenId": 1, "countryCode": "FR"])
+
+let request = Player.filter(key: 1)
+let request = Player.filter(keys: [1, 2, 3])
+
+try Player.deleteOne(db, key: 1)
+try Player.deleteAll(db, keys: [1, 2, 3])
+
+
+ +

Some database tables have a single-column primary key which is not called “id”:

+
try db.create(table: "country") { t in
+    t.column("isoCode", .text).notNull().primaryKey()
+    t.column("name", .text).notNull()
+    t.column("population", .integer).notNull()
+}
+
+ +

In this case, Identifiable conformance can be achieved, for example, by returning the primary key column from the id property:

+
struct Country: Identifiable, FetchableRecord, PersistableRecord {
+    var isoCode: String
+    var name: String
+    var population: Int
+
+    // Fulfill the Identifiable requirement
+    var id: String { isoCode }
+}
+
+let france = try dbQueue.read { db in
+    try Country.fetchOne(db, id: "FR")
+}
+
+

Codable Records

+ +

Record types that adopt an archival protocol (Codable, Encodable or Decodable) get free database support just by declaring conformance to the desired record protocols:

+
// Declare a record...
+struct Player: Codable, FetchableRecord, PersistableRecord {
+    var name: String
+    var score: Int
+}
+
+// ...and there you go:
+try dbQueue.write { db in
+    try Player(name: "Arthur", score: 100).insert(db)
+    let players = try Player.fetchAll(db)
+}
+
+ +

Codable records encode and decode their properties according to their own implementation of the Encodable and Decodable protocols. Yet databases have specific requirements:

+ +
    +
  • Properties are always coded according to their preferred database representation, when they have one (all values that adopt the DatabaseValueConvertible protocol).
  • +
  • You can customize the encoding and decoding of dates and uuids.
  • +
  • Complex properties (arrays, dictionaries, nested structs, etc.) are stored as JSON.
  • +
+ +

For more information about Codable records, see:

+ + + +
+

:bulb: Tip: see the Demo Applications for sample code that uses Codable records.

+
+

JSON Columns

+ +

When a Codable record contains a property that is not a simple value (Bool, Int, String, Date, Swift enums, etc.), that value is encoded and decoded as a JSON string. For example:

+
enum AchievementColor: String, Codable {
+    case bronze, silver, gold
+}
+
+struct Achievement: Codable {
+    var name: String
+    var color: AchievementColor
+}
+
+struct Player: Codable, FetchableRecord, PersistableRecord {
+    var name: String
+    var score: Int
+    var achievements: [Achievement] // stored in a JSON column
+}
+
+try! dbQueue.write { db in
+    // INSERT INTO player (name, score, achievements)
+    // VALUES (
+    //   'Arthur',
+    //   100,
+    //   '[{"color":"gold","name":"Use Codable Records"}]')
+    let achievement = Achievement(name: "Use Codable Records", color: .gold)
+    let player = Player(name: "Arthur", score: 100, achievements: [achievement])
+    try player.insert(db)
+}
+
+ +

GRDB uses the standard JSONDecoder and JSONEncoder from Foundation. By default, Data values are handled with the .base64 strategy, Date with the .millisecondsSince1970 strategy, and non conforming floats with the .throw strategy.

+ +

You can customize the JSON format by implementing those methods:

+
protocol FetchableRecord {
+    static func databaseJSONDecoder(for column: String) -> JSONDecoder
+}
+
+protocol EncodableRecord {
+    static func databaseJSONEncoder(for column: String) -> JSONEncoder
+}
+
+ +
+

:bulb: Tip: Make sure you set the JSONEncoder sortedKeys option, available from iOS 11.0+, macOS 10.13+, tvOS 9.0+ and watchOS 4.0+. This option makes sure that the JSON output is stable. This stability is required for Record Comparison to work as expected, and database observation tools such as ValueObservation to accurately recognize changed records.

+
+

Column Names Coding Strategies

+ +

By default, Codable Records store their values into database columns that match their coding keys: the teamID property is stored into the teamID column.

+ +

This behavior can be overridden, so that you can, for example, store the teamID property into the team_id column:

+
protocol FetchableRecord {
+    static var databaseColumnDecodingStrategy: DatabaseColumnDecodingStrategy { get }
+}
+
+protocol EncodableRecord {
+    static var databaseColumnEncodingStrategy: DatabaseColumnEncodingStrategy { get }
+}
+
+ +

See DatabaseColumnDecodingStrategy and DatabaseColumnEncodingStrategy to learn about all available strategies.

+

Date and UUID Coding Strategies

+ +

By default, Codable Records encode and decode their Date and UUID properties as described in the general Date and DateComponents and UUID chapters.

+ +

To sum up: dates encode themselves in the “YYYY-MM-DD HH:MM:SS.SSS” format, in the UTC time zone, and decode a variety of date formats and timestamps. UUIDs encode themselves as 16-bytes data blobs, and decode both 16-bytes data blobs and strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”.

+ +

Those behaviors can be overridden:

+
protocol FetchableRecord {
+    static var databaseDateDecodingStrategy: DatabaseDateDecodingStrategy { get }
+}
+
+protocol EncodableRecord {
+    static var databaseDateEncodingStrategy: DatabaseDateEncodingStrategy { get }
+    static var databaseUUIDEncodingStrategy: DatabaseUUIDEncodingStrategy { get }
+}
+
+ +

See DatabaseDateDecodingStrategy, DatabaseDateEncodingStrategy, and DatabaseUUIDEncodingStrategy to learn about all available strategies.

+ +

There is no customization of uuid decoding, because UUID can already decode all its encoded variants (16-bytes blobs and uuid strings, both uppercase and lowercase).

+ +

Customized date and uuid handling apply:

+ +
    +
  • When encoding and decoding database rows to and from records (fetching and persistence methods).
  • +
  • In requests by single-column primary key: fetchOne(_:id:), filter(id:), deleteAll(_:keys:), etc.
  • +
+ +

They do not apply in other requests based on date or uuid values.

+ +

So make sure that dates and uuids are properly encoded in your requests. For example:

+
struct Player: Codable, FetchableRecord, PersistableRecord, Identifiable {
+    // UUIDs are stored as strings
+    static let databaseUUIDEncodingStrategy = DatabaseUUIDEncodingStrategy.uppercaseString
+    var id: UUID
+    ...
+}
+
+try dbQueue.write { db in
+    let uuid = UUID()
+    let player = Player(id: uuid, ...)
+
+    // OK: inserts a player in the database, with a string uuid
+    try player.insert(db)
+
+    // OK: performs a string-based query, finds the inserted player
+    _ = try Player.filter(id: uuid).fetchOne(db)
+
+    // NOT OK: performs a blob-based query, fails to find the inserted player
+    _ = try Player.filter(Column("id") == uuid).fetchOne(db)
+
+    // OK: performs a string-based query, finds the inserted player
+    _ = try Player.filter(Column("id") == uuid.uuidString).fetchOne(db)
+}
+
+

The userInfo Dictionary

+ +

Your Codable Records can be stored in the database, but they may also have other purposes. In this case, you may need to customize their implementations of Decodable.init(from:) and Encodable.encode(to:), depending on the context.

+ +

The standard way to provide such context is the userInfo dictionary. Implement those properties:

+
protocol FetchableRecord {
+    static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] { get }
+}
+
+protocol EncodableRecord {
+    static var databaseEncodingUserInfo: [CodingUserInfoKey: Any] { get }
+}
+
+ +

For example, here is a Player type that customizes its decoding:

+
// A key that holds a decoder's name
+let decoderName = CodingUserInfoKey(rawValue: "decoderName")!
+
+struct Player: FetchableRecord, Decodable {
+    init(from decoder: Decoder) throws {
+        // Print the decoder name
+        let decoderName = decoder.userInfo[decoderName] as? String
+        print("Decoded from \(decoderName ?? "unknown decoder")")
+        ...
+    }
+}
+
+ +

You can have a specific decoding from JSON…

+
// prints "Decoded from JSON"
+let decoder = JSONDecoder()
+decoder.userInfo = [decoderName: "JSON"]
+let player = try decoder.decode(Player.self, from: jsonData)
+
+ +

… and another one from database rows:

+
extension Player: FetchableRecord {
+    static let databaseDecodingUserInfo: [CodingUserInfoKey: Any] = [decoderName: "database row"]
+}
+
+// prints "Decoded from database row"
+let player = try Player.fetchOne(db, ...)
+
+ +
+

:point_up: Note: make sure the databaseDecodingUserInfo and databaseEncodingUserInfo properties are explicitly declared as [CodingUserInfoKey: Any]. If they are not, the Swift compiler may silently miss the protocol requirement, resulting in sticky empty userInfo.

+
+

Tip: Derive Columns from Coding Keys

+ +

Codable types are granted with a CodingKeys enum. You can use them to safely define database columns:

+
struct Player: Codable {
+    var id: Int64
+    var name: String
+    var score: Int
+}
+
+extension Player: FetchableRecord, PersistableRecord {
+    enum Columns {
+        static let id = Column(CodingKeys.id)
+        static let name = Column(CodingKeys.name)
+        static let score = Column(CodingKeys.score)
+    }
+}
+
+ +

See the query interface and Good Practices for Designing Record Types for further information.

+

Record Class

+ +

Record is a class that is designed to be subclassed. It inherits its features from the FetchableRecord, TableRecord, and PersistableRecord protocols. On top of that, Record instances can compare against previous versions of themselves in order to avoid useless updates.

+ +

Record subclasses define their custom database relationship by overriding database methods. For example:

+
class Place: Record {
+    var id: Int64?
+    var title: String
+    var isFavorite: Bool
+    var coordinate: CLLocationCoordinate2D
+
+    init(id: Int64?, title: String, isFavorite: Bool, coordinate: CLLocationCoordinate2D) {
+        self.id = id
+        self.title = title
+        self.isFavorite = isFavorite
+        self.coordinate = coordinate
+        super.init()
+    }
+
+    /// The table name
+    override class var databaseTableName: String { "place" }
+
+    /// The table columns
+    enum Columns: String, ColumnExpression {
+        case id, title, favorite, latitude, longitude
+    }
+
+    /// Creates a record from a database row
+    required init(row: Row) {
+        id = row[Columns.id]
+        title = row[Columns.title]
+        isFavorite = row[Columns.favorite]
+        coordinate = CLLocationCoordinate2D(
+            latitude: row[Columns.latitude],
+            longitude: row[Columns.longitude])
+        super.init(row: row)
+    }
+
+    /// The values persisted in the database
+    override func encode(to container: inout PersistenceContainer) {
+        container[Columns.id] = id
+        container[Columns.title] = title
+        container[Columns.favorite] = isFavorite
+        container[Columns.latitude] = coordinate.latitude
+        container[Columns.longitude] = coordinate.longitude
+    }
+
+    /// Update record ID after a successful insertion
+    override func didInsert(with rowID: Int64, for column: String?) {
+        id = rowID
+    }
+}
+
+

Record Comparison

+ +

Records that adopt the EncodableRecord protocol can compare against other records, or against previous versions of themselves.

+ +

This helps avoiding costly UPDATE statements when a record has not been edited.

+ + +

The updateChanges Methods

+ +

The updateChanges methods perform a database update of the changed columns only (and does nothing if record has no change).

+ +
    +
  • updateChanges(_:from:)

    + +

    This method lets you compare two records:

    +
    if let oldPlayer = try Player.fetchOne(db, id: 42) {
    +    var newPlayer = oldPlayer
    +    newPlayer.score = 100
    +    if try newPlayer.updateChanges(db, from: oldPlayer) {
    +        print("player was modified, and updated in the database")
    +    } else {
    +        print("player was not modified, and database was not hit")
    +    }
    +}
    +
  • +
  • updateChanges(_:with:)

    + +

    This method lets you update a record in place:

    +
    if var player = try Player.fetchOne(db, id: 42) {
    +    let modified = try player.updateChanges(db) {
    +        $0.score = 100
    +    }
    +    if modified {
    +        print("player was modified, and updated in the database")
    +    } else {
    +        print("player was not modified, and database was not hit")
    +    }
    +}
    +
  • +
  • updateChanges(_:) (Record class only)

    + +

    Instances of the Record class are able to compare against themselves, and know if they have changes that have not been saved since the last fetch or saving:

    +
    // Record class only
    +if let player = try Player.fetchOne(db, id: 42) {
    +    player.score = 100
    +    if try player.updateChanges(db) {
    +        print("player was modified, and updated in the database")
    +    } else {
    +        print("player was not modified, and database was not hit")
    +    }
    +}
    +
  • +
+

The databaseEquals Method

+ +

This method returns whether two records have the same database representation:

+
let oldPlayer: Player = ...
+var newPlayer: Player = ...
+if newPlayer.databaseEquals(oldPlayer) == false {
+    try newPlayer.save(db)
+}
+
+ +
+

:point_up: Note: The comparison is performed on the database representation of records. As long as your record type adopts the EncodableRecord protocol, you don’t need to care about Equatable.

+
+

The databaseChanges and hasDatabaseChanges Methods

+ +

databaseChanges(from:) returns a dictionary of differences between two records:

+
let oldPlayer = Player(id: 1, name: "Arthur", score: 100)
+let newPlayer = Player(id: 1, name: "Arthur", score: 1000)
+for (column, oldValue) in newPlayer.databaseChanges(from: oldPlayer) {
+    print("\(column) was \(oldValue)")
+}
+// prints "score was 100"
+
+ +

The Record class is able to compare against itself:

+
// Record class only
+let player = Player(id: 1, name: "Arthur", score: 100)
+try player.insert(db)
+player.score = 1000
+for (column, oldValue) in player.databaseChanges {
+    print("\(column) was \(oldValue)")
+}
+// prints "score was 100"
+
+ +

Record instances also have a hasDatabaseChanges property:

+
// Record class only
+player.score = 1000
+if player.hasDatabaseChanges {
+    try player.save(db)
+}
+
+ +

Record.hasDatabaseChanges is false after a Record instance has been fetched or saved into the database. Subsequent modifications may set it, or not: hasDatabaseChanges is based on value comparison. Setting a property to the same value does not set the changed flag:

+
let player = Player(name: "Barbara", score: 750)
+player.hasDatabaseChanges // true
+
+try player.insert(db)
+player.hasDatabaseChanges // false
+
+player.name = "Barbara"
+player.hasDatabaseChanges // false
+
+player.score = 1000
+player.hasDatabaseChanges // true
+player.databaseChanges    // ["score": 750]
+
+ +

For an efficient algorithm which synchronizes the content of a database table with a JSON payload, check groue/SortedDifference.

+

Record Customization Options

+ +

GRDB records come with many default behaviors, that are designed to fit most situations. Many of those defaults can be customized for your specific needs:

+ + + +

Codable Records have a few extra options:

+ + +

Conflict Resolution

+ +

Insertions and updates can create conflicts: for example, a query may attempt to insert a duplicate row that violates a unique index.

+ +

Those conflicts normally end with an error. Yet SQLite let you alter the default behavior, and handle conflicts with specific policies. For example, the INSERT OR REPLACE statement handles conflicts with the “replace” policy which replaces the conflicting row instead of throwing an error.

+ +

The five different policies are: abort (the default), replace, rollback, fail, and ignore.

+ +

SQLite let you specify conflict policies at two different places:

+ +
    +
  • In the definition of the database table:

    +
    // CREATE TABLE player (
    +//     id INTEGER PRIMARY KEY AUTOINCREMENT,
    +//     email TEXT UNIQUE ON CONFLICT REPLACE
    +// )
    +try db.create(table: "player") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("email", .text).unique(onConflict: .replace) // <--
    +}
    +
    +// Despite the unique index on email, both inserts succeed.
    +// The second insert replaces the first row:
    +try db.execute(sql: "INSERT INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +try db.execute(sql: "INSERT INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +
  • +
  • In each modification query:

    +
    // CREATE TABLE player (
    +//     id INTEGER PRIMARY KEY AUTOINCREMENT,
    +//     email TEXT UNIQUE
    +// )
    +try db.create(table: "player") { t in
    +    t.autoIncrementedPrimaryKey("id")
    +    t.column("email", .text).unique()
    +}
    +
    +// Again, despite the unique index on email, both inserts succeed.
    +try db.execute(sql: "INSERT OR REPLACE INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +try db.execute(sql: "INSERT OR REPLACE INTO player (email) VALUES (?)", arguments: ["arthur@example.com"])
    +
  • +
+ +

When you want to handle conflicts at the query level, specify a custom persistenceConflictPolicy in your type that adopts the PersistableRecord protocol. It will alter the INSERT and UPDATE queries run by the insert, update and save persistence methods:

+
protocol MutablePersistableRecord {
+    /// The policy that handles SQLite conflicts when records are
+    /// inserted or updated.
+    ///
+    /// This property is optional: its default value uses the ABORT
+    /// policy for both insertions and updates, so that GRDB generate
+    /// regular INSERT and UPDATE queries.
+    static var persistenceConflictPolicy: PersistenceConflictPolicy { get }
+}
+
+struct Player : MutablePersistableRecord {
+    static let persistenceConflictPolicy = PersistenceConflictPolicy(
+        insert: .replace,
+        update: .replace)
+}
+
+// INSERT OR REPLACE INTO player (...) VALUES (...)
+try player.insert(db)
+
+ +
+

:point_up: Note: the ignore policy does not play well at all with the didInsert method which notifies the rowID of inserted records. Choose your poison:

+ +
    +
  • if you specify the ignore policy in the database table definition, don’t implement the didInsert method: it will be called with some random id in case of failed insert.
  • +
  • if you specify the ignore policy at the query level, the didInsert method is never called.
  • +
+ +

:point_up: Note: The replace policy may have to delete rows so that inserts and updates can succeed. Those deletions are not reported to transaction observers (this might change in a future release of SQLite).

+
+

The Implicit RowID Primary Key

+ +

All SQLite tables have a primary key. Even when the primary key is not explicit:

+
// No explicit primary key
+try db.create(table: "event") { t in
+    t.column("message", .text)
+    t.column("date", .datetime)
+}
+
+// No way to define an explicit primary key
+try db.create(virtualTable: "book", using: FTS4()) { t in
+    t.column("title")
+    t.column("author")
+    t.column("body")
+}
+
+ +

The implicit primary key is stored in the hidden column rowid. Hidden means that SELECT * does not select it, and yet it can be selected and queried: SELECT *, rowid ... WHERE rowid = 1.

+ +

Some GRDB methods will automatically use this hidden column when a table has no explicit primary key:

+
// SELECT * FROM event WHERE rowid = 1
+let event = try Event.fetchOne(db, id: 1)
+
+// DELETE FROM book WHERE rowid = 1
+try Book.deleteOne(db, id: 1)
+
+

Exposing the RowID Column

+ +

By default, a record type that wraps a table without any explicit primary key doesn’t know about the hidden rowid column.

+ +

Without primary key, records don’t have any identity, and the persistence method can behave in undesired fashion: update() throws errors, save() always performs insertions and may break constraints, exists() is always false.

+ +

When SQLite won’t let you provide an explicit primary key (as in full-text tables, for example), you may want to make your record type fully aware of the hidden rowid column:

+ +
    +
  1. Have the databaseSelection static property (from the TableRecord protocol) return the hidden rowid column:

    +
    struct Event : TableRecord {
    +    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
    +}
    +
    +// When you subclass Record, you need an override:
    +class Book : Record {
    +    override class var databaseSelection: [SQLSelectable] {
    +        [AllColums(), Column.rowID]
    +    }
    +}
    +
    + +

    GRDB will then select the rowid column by default:

    +
    // SELECT *, rowid FROM event
    +let events = try Event.fetchAll(db)
    +
  2. +
  3. Have init(row:) from the FetchableRecord protocol consume the “rowid” column:

    +
    struct Event : FetchableRecord {
    +    var id: Int64?
    +
    +    init(row: Row) {
    +        id = row[Column.rowID] // or `row[.rowID]` with Swift 5.5+
    +    }
    +}
    +
    + +

    Your fetched records will then know their ids:

    +
    let event = try Event.fetchOne(db)!
    +event.id // some value
    +
  4. +
  5. Encode the rowid in encode(to:), and keep it in the didInsert(with:for:) method (both from the PersistableRecord and MutablePersistableRecord protocols):

    +
    struct Event : MutablePersistableRecord {
    +    var id: Int64?
    +
    +    func encode(to container: inout PersistenceContainer) {
    +        container[Column.rowID] = id // or `container[.rowID]` with Swift 5.5+
    +        container["message"] = message
    +        container["date"] = date
    +    }
    +
    +    // Update auto-incremented id upon successful insertion
    +    mutating func didInsert(with rowID: Int64, for column: String?) {
    +        id = rowID
    +    }
    +}
    +
    + +

    You will then be able to track your record ids, update them, or check for their existence:

    +
    let event = Event(message: "foo", date: Date())
    +
    +// Insertion sets the record id:
    +try event.insert(db)
    +event.id // some value
    +
    +// Record can be updated:
    +event.message = "bar"
    +try event.update(db)
    +
    +// Record knows if it exists:
    +event.exists(db) // true
    +
  6. +
+

Beyond FetchableRecord

+ +

Some GRDB users eventually discover that the FetchableRecord protocol does not fit all situations. Use cases that are not well handled by FetchableRecord include:

+ +
    +
  • Your application needs polymorphic row decoding: it decodes some type or another, depending on the values contained in a database row.

  • +
  • Your application needs to decode rows with a context: each decoded value should be initialized with some extra value that does not come from the database.

  • +
  • Your application needs a record type that supports untrusted databases, and may fail at decoding database rows (throw an error when a row contains invalid values).

  • +
+ +

Since those use cases are not well handled by FetchableRecord, don’t try to implement them on top of this protocol: you’ll just fight the framework.

+ +

Instead, please have a look at the CustomizedDecodingOfDatabaseRows playground. You’ll run some sample code, and learn how to escape FetchableRecord when you need. And remember that leaving FetchableRecord will not deprive you of query interface requests and generally all SQL generation features of the TableRecord and PersistableRecord protocols.

+

Examples of Record Definitions

+ +

We will show below how to declare a record type for the following database table:

+
try dbQueue.write { db in
+    try db.create(table: "place") { t in
+        t.autoIncrementedPrimaryKey("id")
+        t.column("title", .text).notNull()
+        t.column("isFavorite", .boolean).notNull().defaults(to: false)
+        t.column("longitude", .double).notNull()
+        t.column("latitude", .double).notNull()
+    }
+}
+
+ +

Each one of the three examples below is correct. You will pick one or the other depending on your personal preferences and the requirements of your application:

+ +
+ Define a Codable struct, and adopt the record protocols you need + +This is the shortest way to define a record type. + +See the [Record Protocols Overview](#record-protocols-overview), and [Codable Records] for more information. + +“`swift +struct Place: Codable { + var id: Int64? + var title: String + var isFavorite: Bool + private var latitude: CLLocationDegrees + private var longitude: CLLocationDegrees + + var coordinate: CLLocationCoordinate2D { + get { + CLLocationCoordinate2D( + latitude: latitude, + longitude: longitude) + } + set { + latitude = newValue.latitude + longitude = newValue.longitude + } + } +} + +// SQL generation +extension Place: TableRecord { + /// The table columns + enum Columns { + static let id = Column(CodingKeys.id) + static let title = Column(CodingKeys.title) + static let isFavorite = Column(CodingKeys.isFavorite) + static let latitude = Column(CodingKeys.latitude) + static let longitude = Column(CodingKeys.longitude) + } +} + +// Fetching methods +extension Place: FetchableRecord { } + +// Persistence methods +extension Place: MutablePersistableRecord { + // Update auto-incremented id upon successful insertion + mutating func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +”` + +
+ +
+ Define a plain struct, and adopt the record protocols you need + +See the [Record Protocols Overview](#record-protocols-overview) for more information. + +“`swift +struct Place { + var id: Int64? + var title: String + var isFavorite: Bool + var coordinate: CLLocationCoordinate2D +} + +// SQL generation +extension Place: TableRecord { + /// The table columns + enum Columns: String, ColumnExpression { + case id, title, isFavorite, latitude, longitude + } +} + +// Fetching methods +extension Place: FetchableRecord { + /// Creates a record from a database row + init(row: Row) { + id = row[Columns.id] + title = row[Columns.title] + isFavorite = row[Columns.isFavorite] + coordinate = CLLocationCoordinate2D( + latitude: row[Columns.latitude], + longitude: row[Columns.longitude]) + } +} + +// Persistence methods +extension Place: MutablePersistableRecord { + /// The values persisted in the database + func encode(to container: inout PersistenceContainer) { + container[Columns.id] = id + container[Columns.title] = title + container[Columns.isFavorite] = isFavorite + container[Columns.latitude] = coordinate.latitude + container[Columns.longitude] = coordinate.longitude + } + + // Update auto-incremented id upon successful insertion + mutating func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +”` + +
+ +
+ Define a plain struct optimized for fetching performance + +This struct derives its persistence methods from the standard Encodable protocol (see [Codable Records]), but performs optimized row decoding by accessing database columns with numeric indexes. + +See the [Record Protocols Overview](#record-protocols-overview) for more information. + +“`swift +struct Place: Encodable { + var id: Int64? + var title: String + var isFavorite: Bool + private var latitude: CLLocationDegrees + private var longitude: CLLocationDegrees + + var coordinate: CLLocationCoordinate2D { + get { + CLLocationCoordinate2D( + latitude: latitude, + longitude: longitude) + } + set { + latitude = newValue.latitude + longitude = newValue.longitude + } + } +} + +// SQL generation +extension Place: TableRecord { + /// The table columns + enum Columns { + static let id = Column(CodingKeys.id) + static let title = Column(CodingKeys.title) + static let isFavorite = Column(CodingKeys.isFavorite) + static let latitude = Column(CodingKeys.latitude) + static let longitude = Column(CodingKeys.longitude) + } + + /// Arrange the selected columns and lock their order + static let databaseSelection: [SQLSelectable] = [ + Columns.id, + Columns.title, + Columns.favorite, + Columns.latitude, + Columns.longitude] +} + +// Fetching methods +extension Place: FetchableRecord { + /// Creates a record from a database row + init(row: Row) { + // For high performance, use numeric indexes that match the + // order of Place.databaseSelection + id = row[0] + title = row[1] + isFavorite = row[2] + coordinate = CLLocationCoordinate2D( + latitude: row[3], + longitude: row[4]) + } +} + +// Persistence methods +extension Place: MutablePersistableRecord { + // Update auto-incremented id upon successful insertion + mutating func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +”` + +
+ +
+ Subclass the Record class + +See the [Record class](#record-class) for more information. + +“`swift +class Place: Record { + var id: Int64? + var title: String + var isFavorite: Bool + var coordinate: CLLocationCoordinate2D + + init(id: Int64?, title: String, isFavorite: Bool, coordinate: CLLocationCoordinate2D) { + self.id = id + self.title = title + self.isFavorite = isFavorite + self.coordinate = coordinate + super.init() + } + + /// The table name + override class var databaseTableName: String { "place” } + + /// The table columns + enum Columns: String, ColumnExpression { + case id, title, isFavorite, latitude, longitude + } + + /// Creates a record from a database row + required init(row: Row) { + id = row[Columns.id] + title = row[Columns.title] + isFavorite = row[Columns.isFavorite] + coordinate = CLLocationCoordinate2D( + latitude: row[Columns.latitude], + longitude: row[Columns.longitude]) + super.init(row: row) + } + + /// The values persisted in the database + override func encode(to container: inout PersistenceContainer) { + container[Columns.id] = id + container[Columns.title] = title + container[Columns.isFavorite] = isFavorite + container[Columns.latitude] = coordinate.latitude + container[Columns.longitude] = coordinate.longitude + } + + // Update auto-incremented id upon successful insertion + override func didInsert(with rowID: Int64, for column: String?) { + id = rowID + } +} +“` + +
+

List of Record Methods

+ +

This is the list of record methods, along with their required protocols. The Record class adopts all these protocols, and adds a few extra methods.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MethodProtocolsNotes
Core Methods
init(row:)FetchableRecord
Type.databaseTableNameTableRecord
Type.databaseSelectionTableRecord*
Type.persistenceConflictPolicyPersistableRecord*
record.encode(to:)EncodableRecord
record.didInsert(with:for:)PersistableRecord
Insert and Update Records
record.insert(db)PersistableRecord
record.inserted(db)PersistableRecord
record.save(db)PersistableRecord
record.saved(db)PersistableRecord
record.update(db)PersistableRecord
record.update(db, columns:...)PersistableRecord
record.updateChanges(db, from:...)PersistableRecord*
record.updateChanges(db) { ... }PersistableRecord*
record.updateChanges(db)Record*
Type.updateAll(db, ...)TableRecord
Type.filter(...).updateAll(db, ...)TableRecord²
Delete Records
record.delete(db)PersistableRecord
Type.deleteOne(db, key:...)TableRecord¹
Type.deleteOne(db, id:...)TableRecord & Identifiable¹
Type.deleteAll(db)TableRecord
Type.deleteAll(db, keys:...)TableRecord¹
Type.deleteAll(db, ids:...)TableRecord & Identifiable¹
Type.filter(...).deleteAll(db)TableRecord²
Check Record Existence
record.exists(db)PersistableRecord
Type.exists(db, key: ...)TableRecord¹
Type.exists(db, id: ...)TableRecord & Identifiable¹
Type.filter(...).isEmpty(db)TableRecord²
Convert Record to Dictionary
record.databaseDictionaryEncodableRecord
Count Records
Type.fetchCount(db)TableRecord
Type.filter(...).fetchCount(db)TableRecord²
Fetch Record Cursors
Type.fetchCursor(db)FetchableRecord & TableRecord
Type.fetchCursor(db, keys:...)FetchableRecord & TableRecord¹
Type.fetchCursor(db, ids:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchCursor(db, sql: sql)FetchableRecord³
Type.fetchCursor(statement)FetchableRecord⁴
Type.filter(...).fetchCursor(db)FetchableRecord & TableRecord²
Fetch Record Arrays
Type.fetchAll(db)FetchableRecord & TableRecord
Type.fetchAll(db, keys:...)FetchableRecord & TableRecord¹
Type.fetchAll(db, ids:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchAll(db, sql: sql)FetchableRecord³
Type.fetchAll(statement)FetchableRecord⁴
Type.filter(...).fetchAll(db)FetchableRecord & TableRecord²
Fetch Record Sets
Type.fetchSet(db)FetchableRecord & TableRecord
Type.fetchSet(db, keys:...)FetchableRecord & TableRecord¹
Type.fetchSet(db, ids:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchSet(db, sql: sql)FetchableRecord³
Type.fetchSet(statement)FetchableRecord⁴
Type.filter(...).fetchSet(db)FetchableRecord & TableRecord²
Fetch Individual Records
Type.fetchOne(db)FetchableRecord & TableRecord
Type.fetchOne(db, key:...)FetchableRecord & TableRecord¹
Type.fetchOne(db, id:...)FetchableRecord & TableRecord & Identifiable¹
Type.fetchOne(db, sql: sql)FetchableRecord³
Type.fetchOne(statement)FetchableRecord⁴
Type.filter(...).fetchOne(db)FetchableRecord & TableRecord²
Codable Records
Type.databaseDecodingUserInfoFetchableRecord*
Type.databaseJSONDecoder(for:)FetchableRecord*
Type.databaseDateDecodingStrategyFetchableRecord*
Type.databaseEncodingUserInfoEncodableRecord*
Type.databaseJSONEncoder(for:)EncodableRecord*
Type.databaseDateEncodingStrategyEncodableRecord*
Type.databaseUUIDEncodingStrategyEncodableRecord*
Define Associations
Type.belongsTo(...)TableRecord*
Type.hasMany(...)TableRecord*
Type.hasOne(...)TableRecord*
Type.hasManyThrough(...)TableRecord*
Type.hasOneThrough(...)TableRecord*
Building Query Interface Requests
record.request(for:...)TableRecord & EncodableRecord*
Type.all()TableRecord²
Type.none()TableRecord²
Type.select(...)TableRecord²
Type.select(..., as:...)TableRecord²
Type.selectID()TableRecord & Identifiable*
Type.annotated(with:...)TableRecord²
Type.filter(...)TableRecord²
Type.filter(id:)TableRecord & Identifiable*
Type.filter(ids:)TableRecord & Identifiable*
Type.matching(...)TableRecord²
Type.including(all:)TableRecord²
Type.including(optional:)TableRecord²
Type.including(required:)TableRecord²
Type.joining(optional:)TableRecord²
Type.joining(required:)TableRecord²
Type.group(...)TableRecord²
Type.groupByPrimaryKey()TableRecord²
Type.having(...)TableRecord²
Type.order(...)TableRecord²
Type.orderByPrimaryKey()TableRecord²
Type.limit(...)TableRecord²
Type.with(...)TableRecord²
Record Comparison
record.databaseEquals(...)EncodableRecord
record.databaseChanges(from:...)EncodableRecord
record.updateChanges(db, from:...)PersistableRecord
record.updateChanges(db) { ... }PersistableRecord
record.hasDatabaseChangesRecord
record.databaseChangesRecord
record.updateChanges(db)Record
+ +

¹ All unique keys are supported: primary keys (single-column, composite, implicit RowID) and unique indexes:

+
try Player.fetchOne(db, id: 1)                                // Player?
+try Player.fetchOne(db, key: ["email": "arthur@example.com"]) // Player?
+try Country.fetchAll(db, keys: ["FR", "US"])                  // [Country]
+
+ +

² See Fetch Requests:

+
let request = Player.filter(emailColumn != nil).order(nameColumn)
+let players = try request.fetchAll(db)  // [Player]
+let count = try request.fetchCount(db)  // Int
+
+ +

³ See SQL queries:

+
let player = try Player.fetchOne(db, sql: "SELECT * FROM player WHERE id = ?", arguments: [1]) // Player?
+
+ +

⁴ See Prepared Statements:

+
let statement = try db.makeStatement(sql: "SELECT * FROM player WHERE id = ?")
+let player = try Player.fetchOne(statement, arguments: [1])  // Player?
+
+

The Query Interface

+ +

The query interface lets you write pure Swift instead of SQL:

+
try dbQueue.write { db in
+    // Update database schema
+    try db.create(table: "wine") { t in ... }
+
+    // Fetch records
+    let wines = try Wine
+        .filter(originColumn == "Burgundy")
+        .order(priceColumn)
+        .fetchAll(db)
+
+    // Count
+    let count = try Wine
+        .filter(colorColumn == Color.red)
+        .fetchCount(db)
+
+    // Update
+    try Wine
+        .filter(originColumn == "Burgundy")
+        .updateAll(db, priceColumn *= 0.75)
+
+    // Delete
+    try Wine
+        .filter(corkedColumn == true)
+        .deleteAll(db)
+}
+
+ +

You need to open a database connection before you can query the database.

+ +

Please bear in mind that the query interface can not generate all possible SQL queries. You may also prefer writing SQL, and this is just OK. From little snippets to full queries, your SQL skills are welcome:

+
try dbQueue.write { db in
+    // Update database schema (with SQL)
+    try db.execute(sql: "CREATE TABLE wine (...)")
+
+    // Fetch records (with SQL)
+    let wines = try Wine.fetchAll(db,
+        sql: "SELECT * FROM wine WHERE origin = ? ORDER BY price",
+        arguments: ["Burgundy"])
+
+    // Count (with an SQL snippet)
+    let count = try Wine
+        .filter(sql: "color = ?", arguments: [Color.red])
+        .fetchCount(db)
+
+    // Update (with SQL)
+    try db.execute(sql: "UPDATE wine SET price = price * 0.75 WHERE origin = 'Burgundy'")
+
+    // Delete (with SQL)
+    try db.execute(sql: "DELETE FROM wine WHERE corked")
+}
+
+ +

So don’t miss the SQL API.

+ +
+

:point_up: Note: the generated SQL may change between GRDB releases, without notice: don’t have your application rely on any specific SQL output.

+
+ + +

Database Schema

+ +

Once granted with a database connection, you can setup your database schema without writing SQL:

+ + +

Create Tables

+
// CREATE TABLE place (
+//   id INTEGER PRIMARY KEY AUTOINCREMENT,
+//   title TEXT,
+//   favorite BOOLEAN NOT NULL DEFAULT 0,
+//   latitude DOUBLE NOT NULL,
+//   longitude DOUBLE NOT NULL
+// )
+try db.create(table: "place") { t in
+    t.autoIncrementedPrimaryKey("id")
+    t.column("title", .text)
+    t.column("favorite", .boolean).notNull().defaults(to: false)
+    t.column("longitude", .double).notNull()
+    t.column("latitude", .double).notNull()
+}
+
+ +

The create(table:) method covers nearly all SQLite table creation features. For virtual tables, see Full-Text Search, or use raw SQL.

+ +

SQLite itself has many reference documents about table creation: CREATE TABLE, Datatypes In SQLite Version 3, SQLite Foreign Key Support, ON CONFLICT, The WITHOUT ROWID Optimization.

+ +

Configure table creation:

+
// CREATE TABLE example ( ... )
+try db.create(table: "example") { t in ... }
+
+// CREATE TEMPORARY TABLE example IF NOT EXISTS (
+try db.create(table: "example", temporary: true, ifNotExists: true) { t in ... }
+
+ +
+

:bulb: Tip: database table names should be singular, and camel-cased. Make them look like Swift identifiers: place, country, postalAddress, ‘httpRequest’.

+ +

This will help you using Associations when you need them. Database table names that follow another naming convention are totally OK, but you will need to perform extra configuration.

+ +

:point_up: Note: WITHOUT ROWID tables can not be tracked with Database Observation tools.

+
+ +

Add regular columns with their name and eventual type (text, integer, double, numeric, boolean, blob, date and datetime) - see SQLite data types:

+
// CREATE TABLE example (
+//   a,
+//   name TEXT,
+//   creationDate DATETIME,
+try db.create(table: "example") { t in
+    t.column("a")
+    t.column("name", .text)
+    t.column("creationDate", .datetime)
+
+ +

Define not null columns, and set default values:

+
    // email TEXT NOT NULL,
+    t.column("email", .text).notNull()
+
+    // name TEXT NOT NULL DEFAULT 'Anonymous',
+    t.column("name", .text).notNull().defaults(to: "Anonymous")
+
+ +

Use an individual column as primary, unique, or foreign key. When defining a foreign key, the referenced column is the primary key of the referenced table (unless you specify otherwise):

+
    // id INTEGER PRIMARY KEY AUTOINCREMENT,
+    t.autoIncrementedPrimaryKey("id")
+
+    // uuid TEXT PRIMARY KEY,
+    t.column("uuid", .text).primaryKey()
+
+    // email TEXT UNIQUE,
+    t.column("email", .text).unique()
+
+    // countryCode TEXT REFERENCES country(code) ON DELETE CASCADE,
+    t.column("countryCode", .text).references("country", onDelete: .cascade)
+
+ +
+

:bulb: Tip: when you need an integer primary key that automatically generates unique values, it is highly recommended that you use the autoIncrementedPrimaryKey method:

+
try db.create(table: "example") { t in
+    t.autoIncrementedPrimaryKey("id")
+    ...
+}
+
+ +

The reason for this recommendation is that auto-incremented primary keys prevent the reuse of ids. This prevents your app or database observation tools to think that a row was updated, when it was actually deleted, then replaced. Depending on your application needs, this may be acceptable. But usually it is not.

+
+ +

Create an index on the column:

+
    t.column("score", .integer).indexed()
+
+ +

For extra index options, see Create Indexes below.

+ +

Perform integrity checks on individual columns, and SQLite will only let conforming rows in. In the example below, the $0 closure variable is a column which lets you build any SQL expression.

+
    // name TEXT CHECK (LENGTH(name) > 0)
+    // score INTEGER CHECK (score > 0)
+    t.column("name", .text).check { length($0) > 0 }
+    t.column("score", .integer).check(sql: "score > 0")
+
+ +

Columns can also be defined with a raw sql String, or an SQL literal in which you can safely embed raw values without any risk of syntax errors or SQL injection:

+
    t.column(sql: "name TEXT")
+
+    let defaultName: String = ...
+    t.column(literal: "name TEXT DEFAULT \(defaultName)")
+
+ +

Other table constraints can involve several columns:

+
    // PRIMARY KEY (a, b),
+    t.primaryKey(["a", "b"])
+
+    // UNIQUE (a, b) ON CONFLICT REPLACE,
+    t.uniqueKey(["a", "b"], onConflict: .replace)
+
+    // FOREIGN KEY (a, b) REFERENCES parents(c, d),
+    t.foreignKey(["a", "b"], references: "parents")
+
+    // CHECK (a + b < 10),
+    t.check(Column("a") + Column("b") < 10)
+
+    // CHECK (a + b < 10)
+    t.check(sql: "a + b < 10")
+
+    // Raw SQL constraints
+    t.constraint(sql: "CHECK (a + b < 10)")
+    t.constraint(literal: "CHECK (a + b < \(10))")
+
+ +

Generated columns are available with a custom SQLite build:

+
    t.column("totalScore", .integer).generatedAs(sql: "score + bonus")
+    t.column("totalScore", .integer).generatedAs(Column("score") + Column("bonus"))
+}
+
+

Modify Tables

+ +

SQLite lets you modify existing tables:

+
// ALTER TABLE referer RENAME TO referrer
+try db.rename(table: "referer", to: "referrer")
+
+// ALTER TABLE player ADD COLUMN hasBonus BOOLEAN
+// ALTER TABLE player RENAME COLUMN url TO homeURL
+try db.alter(table: "player") { t in
+    t.add(column: "hasBonus", .boolean)
+    t.rename(column: "url", to: "homeURL") // SQLite 3.25+
+}
+
+ +
+

:point_up: Note: SQLite restricts the possible table alterations, and may require you to recreate dependent triggers or views. See the documentation of the ALTER TABLE for details. See Advanced Database Schema Changes for a way to lift restrictions.

+
+

Drop Tables

+ +

Drop tables with the drop(table:) method:

+
try db.drop(table: "obsolete")
+
+

Create Indexes

+ +

Create indexes with the create(index:) method:

+
// CREATE UNIQUE INDEX byEmail ON users(email)
+try db.create(index: "byEmail", on: "users", columns: ["email"], unique: true)
+
+ +

Relevant SQLite documentation:

+ + +

Requests

+ +

The query interface requests let you fetch values from the database:

+
let request = Player.filter(emailColumn != nil).order(nameColumn)
+let players = try request.fetchAll(db)  // [Player]
+let count = try request.fetchCount(db)  // Int
+
+ +

Query interface requests usually start from a type that adopts the TableRecord protocol, such as a Record subclass (see Records):

+
class Player: Record { ... }
+
+// The request for all players:
+let request = Player.all()
+let players = try request.fetchAll(db) // [Player]
+
+ +

When you can not use a record type, use Table:

+
// The request for all rows from the player table:
+let table = Table("player")
+let request = table.all()
+let rows = try request.fetchAll(db)    // [Row]
+
+// The request for all players from the player table:
+let table = Table<Player>("player")
+let request = table.all()
+let players = try request.fetchAll(db) // [Player]
+
+ +
+

:point_up: Note: all examples in the documentation below use a record type, but you can always substitute a Table instead.

+
+ +

Next, declare the table columns that you want to use for filtering, or sorting:

+
let idColumn = Column("id")
+let nameColumn = Column("name")
+
+ +

You can also declare column enums, if you prefer:

+
// Columns.id and Columns.name can be used just as
+// idColumn and nameColumn declared above.
+enum Columns: String, ColumnExpression {
+    case id
+    case name
+}
+
+ +

You can now build requests with the following methods: all, none, select, distinct, filter, matching, group, having, order, reversed, limit, joining, including, with. All those methods return another request, which you can further refine by applying another method: Player.select(...).filter(...).order(...).

+ +
    +
  • all(), none(): the requests for all rows, or no row.

    +
    // SELECT * FROM player
    +Player.all()
    +
    + +

    By default, all columns are selected. See Columns Selected by a Request.

  • +
  • select(...) and select(..., as:) define the selected columns. See Columns Selected by a Request.

    +
    // SELECT name FROM player
    +Player.select(nameColumn, as: String.self)
    +
  • +
  • selectID() is available on Identifiable Records. It supports all tables that have a single-column primary key:

    +
    // SELECT id FROM player
    +Player.selectID()
    +
    +// SELECT id FROM player WHERE name IS NOT NULL
    +Player.filter(nameColumn != nil).selectID()
    +
  • +
  • annotated(with: expression...) extends the selection.

    +
    // SELECT *, (score + bonus) AS total FROM player
    +Player.annotated(with: (scoreColumn + bonusColumn).forKey("total"))
    +
    + +

    Such annotations can help using Associations:

    +
    // SELECT player.*, team.name
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +let teamAlias = TableAlias()
    +let request = Player
    +    .annotated(with: teamAlias[nameColumn])
    +    .joining(required: Player.team.aliased(teamAlias))
    +
  • +
  • annotated(with: aggregate) extends the selection with association aggregates.

    +
    // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount
    +// FROM team
    +// LEFT JOIN player ON player.teamId = team.id
    +// GROUP BY team.id
    +Team.annotated(with: Team.players.count)
    +
  • +
  • distinct() performs uniquing.

    +
    // SELECT DISTINCT name FROM player
    +Player.select(nameColumn, as: String.self).distinct()
    +
  • +
  • filter(expression) applies conditions.

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +Player.filter([1,2,3].contains(idColumn))
    +
    +// SELECT * FROM player WHERE (name IS NOT NULL) AND (height > 1.75)
    +Player.filter(nameColumn != nil && heightColumn > 1.75)
    +
  • +
  • filter(id:) and filter(ids:) are type-safe methods available on Identifiable Records:

    +
    // SELECT * FROM player WHERE id = 1
    +Player.filter(id: 1)
    +
    +// SELECT * FROM country WHERE isoCode IN ('FR', 'US')
    +Country.filter(ids: ["FR", "US"])
    +
  • +
  • filter(key:) and filter(keys:) apply conditions on primary and unique keys:

    +
    // SELECT * FROM player WHERE id = 1
    +Player.filter(key: 1)
    +
    +// SELECT * FROM country WHERE isoCode IN ('FR', 'US')
    +Country.filter(keys: ["FR", "US"])
    +
    +// SELECT * FROM citizenship WHERE citizenId = 1 AND countryCode = 'FR'
    +Citizenship.filter(key: ["citizenId": 1, "countryCode": "FR"])
    +
    +// SELECT * FROM player WHERE email = 'arthur@example.com'
    +Player.filter(key: ["email": "arthur@example.com"])
    +
  • +
  • matching(pattern) performs full-text search.

    +
    // SELECT * FROM document WHERE document MATCH 'sqlite database'
    +let pattern = FTS3Pattern(matchingAllTokensIn: "SQLite database")
    +Document.matching(pattern)
    +
    + +

    When the pattern is nil, no row will match.

  • +
  • group(expression, ...) groups rows.

    +
    // SELECT name, MAX(score) FROM player GROUP BY name
    +Player
    +    .select(nameColumn, max(scoreColumn))
    +    .group(nameColumn)
    +
  • +
  • having(expression) applies conditions on grouped rows.

    +
    // SELECT team, MAX(score) FROM player GROUP BY team HAVING MIN(score) >= 1000
    +Player
    +    .select(teamColumn, max(scoreColumn))
    +    .group(teamColumn)
    +    .having(min(scoreColumn) >= 1000)
    +
  • +
  • having(aggregate) applies conditions on grouped rows, according to an association aggregate.

    +
    // SELECT team.*
    +// FROM team
    +// LEFT JOIN player ON player.teamId = team.id
    +// GROUP BY team.id
    +// HAVING COUNT(DISTINCT player.id) >= 5
    +Team.having(Team.players.count >= 5)
    +
  • +
  • order(ordering, ...) sorts.

    +
    // SELECT * FROM player ORDER BY name
    +Player.order(nameColumn)
    +
    +// SELECT * FROM player ORDER BY score DESC, name
    +Player.order(scoreColumn.desc, nameColumn)
    +
    + +

    SQLite considers NULL values to be smaller than any other values for sorting purposes. Hence, NULLs naturally appear at the beginning of an ascending ordering and at the end of a descending ordering. With a custom SQLite build, this can be changed using .ascNullsLast and .descNullsFirst:

    +
    // SELECT * FROM player ORDER BY score ASC NULLS LAST
    +Player.order(nameColumn.ascNullsLast)
    +
    + +

    Each order call clears any previous ordering:

    +
    // SELECT * FROM player ORDER BY name
    +Player.order(scoreColumn).order(nameColumn)
    +
  • +
  • reversed() reverses the eventual orderings.

    +
    // SELECT * FROM player ORDER BY score ASC, name DESC
    +Player.order(scoreColumn.desc, nameColumn).reversed()
    +
    + +

    If no ordering was already specified, this method has no effect:

    +
    // SELECT * FROM player
    +Player.all().reversed()
    +
  • +
  • limit(limit, offset: offset) limits and pages results.

    +
    // SELECT * FROM player LIMIT 5
    +Player.limit(5)
    +
    +// SELECT * FROM player LIMIT 5 OFFSET 10
    +Player.limit(5, offset: 10)
    +
  • +
  • joining(...) and including(...) fetch and join records through Associations.

    +
    // SELECT player.*, team.*
    +// FROM player
    +// JOIN team ON team.id = player.teamId
    +Player.including(required: Player.team)
    +
  • +
  • with(cte) embeds a common table expression:

    +
    // WITH ... SELECT * FROM player
    +let cte = CommonTableExpression(...)
    +Player.with(cte)
    +
  • +
  • Other requests that involve the primary key:

    + +
      +
    • orderByPrimaryKey() sorts by primary key.

      +
      // SELECT * FROM player ORDER BY id
      +Player.orderByPrimaryKey()
      +
      +// SELECT * FROM country ORDER BY code
      +Country.orderByPrimaryKey()
      +
      +// SELECT * FROM citizenship ORDER BY citizenId, countryCode
      +Citizenship.orderByPrimaryKey()
      +
    • +
    • groupByPrimaryKey() groups rows by primary key.

    • +
  • +
+ +

You can refine requests by chaining those methods:

+
// SELECT * FROM player WHERE (email IS NOT NULL) ORDER BY name
+Player.order(nameColumn).filter(emailColumn != nil)
+
+ +

The select, order, group, and limit methods ignore and replace previously applied selection, orderings, grouping, and limits. On the opposite, filter, matching, and having methods extend the query:

+
Player                          // SELECT * FROM player
+    .filter(nameColumn != nil)  // WHERE (name IS NOT NULL)
+    .filter(emailColumn != nil) //        AND (email IS NOT NULL)
+    .order(nameColumn)          // - ignored -
+    .reversed()                 // - ignored -
+    .order(scoreColumn)         // ORDER BY score
+    .limit(20, offset: 40)      // - ignored -
+    .limit(10)                  // LIMIT 10
+
+ +

Raw SQL snippets are also accepted, with eventual arguments:

+
// SELECT DATE(creationDate), COUNT(*) FROM player WHERE name = 'Arthur' GROUP BY date(creationDate)
+Player
+    .select(sql: "DATE(creationDate), COUNT(*)")
+    .filter(sql: "name = ?", arguments: ["Arthur"])
+    .group(sql: "DATE(creationDate)")
+
+

Columns Selected by a Request

+ +

By default, query interface requests select all columns:

+
// SELECT * FROM player
+struct Player: TableRecord { ... }
+let request = Player.all()
+
+// SELECT * FROM player
+let table = Table("player")
+let request = table.all()
+
+ +

The selection can be changed for each individual requests, or in the case of record-based requests, for all requests built from this record type.

+ +

The select(...) and select(..., as:) methods change the selection of a single request (see Fetching from Requests for detailed information):

+
let request = Player.select(max(Column("score")))
+let maxScore = try Int.fetchOne(db, request) // Int?
+
+let request = Player.select(max(Column("score")), as: Int.self)
+let maxScore = try request.fetchOne(db)      // Int?
+
+ +

The default selection for a record type is controlled by the databaseSelection property:

+
struct RestrictedPlayer : TableRecord {
+    static let databaseTableName = "player"
+    static let databaseSelection: [SQLSelectable] = [Column("id"), Column("name")]
+}
+
+struct ExtendedPlayer : TableRecord {
+    static let databaseTableName = "player"
+    static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
+}
+
+// SELECT id, name FROM player
+let request = RestrictedPlayer.all()
+
+// SELECT *, rowid FROM player
+let request = ExtendedPlayer.all()
+
+ +
+

:point_up: Note: make sure the databaseSelection property is explicitly declared as [SQLSelectable]. If it is not, the Swift compiler may silently miss the protocol requirement, resulting in sticky SELECT * requests. To verify your setup, see the How do I print a request as SQL? FAQ.

+
+

Expressions

+ +

Feed requests with SQL expressions built from your Swift code:

+

SQL Operators

+ +

GRDB comes with a Swift version of many SQLite built-in operators, listed below. But not all: see Adding support for missing SQL functions or operators.

+ +
    +
  • =, <>, <, <=, >, >=, IS, IS NOT

    + +

    Comparison operators are based on the Swift operators ==, !=, ===, !==, <, <=, >, >=:

    +
    // SELECT * FROM player WHERE (name = 'Arthur')
    +Player.filter(nameColumn == "Arthur")
    +
    +// SELECT * FROM player WHERE (name IS NULL)
    +Player.filter(nameColumn == nil)
    +
    +// SELECT * FROM player WHERE (score IS 1000)
    +Player.filter(scoreColumn === 1000)
    +
    +// SELECT * FROM rectangle WHERE width < height
    +Rectangle.filter(widthColumn < heightColumn)
    +
    + +

    Subqueries are supported:

    +
    // SELECT * FROM player WHERE score = (SELECT max(score) FROM player)
    +let maximumScore = Player.select(max(scoreColumn))
    +Player.filter(scoreColumn == maximumScore)
    +
    +// SELECT * FROM player WHERE score = (SELECT max(score) FROM player)
    +let maximumScore = SQLRequest("SELECT max(score) FROM player")
    +Player.filter(scoreColumn == maximumScore)
    +
    + +
    +

    :point_up: Note: SQLite string comparison, by default, is case-sensitive and not Unicode-aware. See string comparison if you need more control.

    +
  • +
  • *, /, +, -

    + +

    SQLite arithmetic operators are derived from their Swift equivalent:

    +
    // SELECT ((temperature * 1.8) + 32) AS fahrenheit FROM planet
    +Planet.select((temperatureColumn * 1.8 + 32).forKey("fahrenheit"))
    +
    + +
    +

    :point_up: Note: an expression like nameColumn + "rrr" will be interpreted by SQLite as a numerical addition (with funny results), not as a string concatenation. See the concat operator below.

    +
    + +

    When you want to join a sequence of expressions with the + or * operator, use joined(operator:):

    +
    // SELECT score + bonus + 1000 FROM player
    +let values = [
    +    scoreColumn,
    +    bonusColumn,
    +    1000.databaseValue]
    +Player.select(values.joined(operator: .add))
    +
    + +

    Note in the example above how you concatenate raw values: 1000.databaseValue. A plain 1000 would not compile.

    + +

    When the sequence is empty, joined(operator: .add) returns 0, and joined(operator: .multiply) returns 1.

  • +
  • ||

    + +

    Concatenate several strings:

    +
    // SELECT firstName || ' ' || lastName FROM player
    +Player.select([firstNameColumn, " ".databaseValue, lastNameColumn].joined(operator: .concat))
    +
    + +

    Note in the example above how you concatenate raw strings: " ".databaseValue. A plain " " would not compile.

    + +

    When the sequence is empty, joined(operator: .concat) returns the empty string.

  • +
  • AND, OR, NOT

    + +

    The SQL logical operators are derived from the Swift &&, || and !:

    +
    // SELECT * FROM player WHERE ((NOT verified) OR (score < 1000))
    +Player.filter(!verifiedColumn || scoreColumn < 1000)
    +
    + +

    When you want to join a sequence of expressions with the AND or OR operator, use joined(operator:):

    +
    // SELECT * FROM player WHERE (verified AND (score >= 1000) AND (name IS NOT NULL))
    +let conditions = [
    +    verifiedColumn,
    +    scoreColumn >= 1000,
    +    nameColumn != nil]
    +Player.filter(conditions.joined(operator: .and))
    +
    + +

    When the sequence is empty, joined(operator: .and) returns true, and joined(operator: .or) returns false:

    +
    // SELECT * FROM player WHERE 1
    +Player.filter([].joined(operator: .and))
    +
    +// SELECT * FROM player WHERE 0
    +Player.filter([].joined(operator: .or))
    +
  • +
  • BETWEEN, IN, NOT IN

    + +

    To check inclusion in a Swift sequence (array, set, range…), call the contains method:

    +
    // SELECT * FROM player WHERE id IN (1, 2, 3)
    +Player.filter([1, 2, 3].contains(idColumn))
    +
    +// SELECT * FROM player WHERE id NOT IN (1, 2, 3)
    +Player.filter(![1, 2, 3].contains(idColumn))
    +
    +// SELECT * FROM player WHERE score BETWEEN 0 AND 1000
    +Player.filter((0...1000).contains(scoreColumn))
    +
    +// SELECT * FROM player WHERE (score >= 0) AND (score < 1000)
    +Player.filter((0..<1000).contains(scoreColumn))
    +
    +// SELECT * FROM player WHERE initial BETWEEN 'A' AND 'N'
    +Player.filter(("A"..."N").contains(initialColumn))
    +
    +// SELECT * FROM player WHERE (initial >= 'A') AND (initial < 'N')
    +Player.filter(("A"..<"N").contains(initialColumn))
    +
    + +

    To check inclusion inside a subquery, call the contains method as well:

    +
    // SELECT * FROM player WHERE id IN (SELECT playerId FROM playerSelection)
    +let selectedPlayerIds = PlayerSelection.select(playerIdColumn)
    +Player.filter(selectedPlayerIds.contains(idColumn))
    +
    +// SELECT * FROM player WHERE id IN (SELECT playerId FROM playerSelection)
    +let selectedPlayerIds = SQLRequest("SELECT playerId FROM playerSelection")
    +Player.filter(selectedPlayerIds.contains(idColumn))
    +
    + +

    To check inclusion inside a common table expression, call the contains method as well:

    +
    // WITH selectedName AS (...)
    +// SELECT * FROM player WHERE name IN selectedName
    +let cte = CommonTableExpression(named: "selectedName", ...)
    +Player
    +    .with(cte)
    +    .filter(cte.contains(nameColumn))
    +
    + +
    +

    :point_up: Note: SQLite string comparison, by default, is case-sensitive and not Unicode-aware. See string comparison if you need more control.

    +
  • +
  • EXISTS, NOT EXISTS

    + +

    To check if a subquery would return rows, call the exists method:

    +
    // Teams that have at least one other player
    +//
    +//  SELECT * FROM team
    +//  WHERE EXISTS (SELECT * FROM player WHERE teamID = team.id)
    +let teamAlias = TableAlias()
    +let player = Player.filter(Column("teamID") == teamAlias[Column("id")])
    +let teams = Team.aliased(teamAlias).filter(player.exists())
    +
    +// Teams that have no player
    +//
    +//  SELECT * FROM team
    +//  WHERE NOT EXISTS (SELECT * FROM player WHERE teamID = team.id)
    +let teams = Team.aliased(teamAlias).filter(!player.exists())
    +
    + +

    In the above example, you use a TableAlias in order to let a subquery refer to a column from another table.

    + +

    In the next example, which involves the same table twice, the table alias requires an explicit disambiguation with TableAlias(name:):

    +
    // Players who coach at least one other player
    +//
    +//  SELECT coach.* FROM player coach
    +//  WHERE EXISTS (SELECT * FROM player WHERE coachId = coach.id)
    +let coachAlias = TableAlias(name: "coach")
    +let coachedPlayer = Player.filter(Column("coachId") == coachAlias[Column("id")])
    +let coaches = Player.aliased(coachAlias).filter(coachedPlayer.exists())
    +
    + +

    Finally, subqueries can also be expressed as SQL, with SQL Interpolation:

    +
    // SELECT coach.* FROM player coach
    +// WHERE EXISTS (SELECT * FROM player WHERE coachId = coach.id)
    +let coachedPlayer = SQLRequest("SELECT * FROM player WHERE coachId = \(coachAlias[Column("id")])")
    +let coaches = Player.aliased(coachAlias).filter(coachedPlayer.exists())
    +
  • +
  • LIKE

    + +

    The SQLite LIKE operator is available as the like method:

    +
    // SELECT * FROM player WHERE (email LIKE '%@example.com')
    +Player.filter(emailColumn.like("%@example.com"))
    +
    +// SELECT * FROM book WHERE (title LIKE '%10\%%' ESCAPE '\')
    +Player.filter(emailColumn.like("%10\\%%", escape: "\\"))
    +
    + +
    +

    :point_up: Note: the SQLite LIKE operator is case-insensitive but not Unicode-aware. For example, the expression 'a' LIKE 'A' is true but 'æ' LIKE 'Æ' is false.

    +
  • +
  • MATCH

    + +

    The full-text MATCH operator is available through FTS3Pattern (for FTS3 and FTS4 tables) and FTS5Pattern (for FTS5):

    + +

    FTS3 and FTS4:

    +
    let pattern = FTS3Pattern(matchingAllTokensIn: "SQLite database")
    +
    +// SELECT * FROM document WHERE document MATCH 'sqlite database'
    +Document.matching(pattern)
    +
    +// SELECT * FROM document WHERE content MATCH 'sqlite database'
    +Document.filter(contentColumn.match(pattern))
    +
    + +

    FTS5:

    +
    let pattern = FTS5Pattern(matchingAllTokensIn: "SQLite database")
    +
    +// SELECT * FROM document WHERE document MATCH 'sqlite database'
    +Document.matching(pattern)
    +
  • +
+

SQL Functions

+ +

GRDB comes with a Swift version of many SQLite built-in functions, listed below. But not all: see Adding support for missing SQL functions or operators.

+ +
    +
  • ABS, AVG, COUNT, DATETIME, JULIANDAY, LENGTH, MAX, MIN, SUM:

    + +

    Those are based on the abs, average, count, dateTime, julianDay, length, max, min and sum Swift functions:

    +
    // SELECT MIN(score), MAX(score) FROM player
    +Player.select(min(scoreColumn), max(scoreColumn))
    +
    +// SELECT COUNT(name) FROM player
    +Player.select(count(nameColumn))
    +
    +// SELECT COUNT(DISTINCT name) FROM player
    +Player.select(count(distinct: nameColumn))
    +
    +// SELECT JULIANDAY(date, 'start of year') FROM game
    +Game.select(julianDay(dateColumn, .startOfYear))
    +
    + +

    For more information about the functions dateTime and julianDay, see Date And Time Functions.

  • +
  • IFNULL

    + +

    Use the Swift ?? operator:

    +
    // SELECT IFNULL(name, 'Anonymous') FROM player
    +Player.select(nameColumn ?? "Anonymous")
    +
    +// SELECT IFNULL(name, email) FROM player
    +Player.select(nameColumn ?? emailColumn)
    +
  • +
  • LOWER, UPPER

    + +

    The query interface does not give access to those SQLite functions. Nothing against them, but they are not unicode aware.

    + +

    Instead, GRDB extends SQLite with SQL functions that call the Swift built-in string functions capitalized, lowercased, uppercased, localizedCapitalized, localizedLowercased and localizedUppercased:

    +
    Player.select(nameColumn.uppercased())
    +
    + +
    +

    :point_up: Note: When comparing strings, you’d rather use a collation:

    +
    let name: String = ...
    +
    +// Not recommended
    +nameColumn.uppercased() == name.uppercased()
    +
    +// Better
    +nameColumn.collating(.caseInsensitiveCompare) == name
    +
    +
  • +
  • Custom SQL functions and aggregates

    + +

    You can apply your own custom SQL functions and aggregates:

    +
    let f = DatabaseFunction("f", ...)
    +
    +// SELECT f(name) FROM player
    +Player.select(f.apply(nameColumn))
    +
  • +
+

Adding support for missing SQL functions or operators

+ +

When you spot an SQL function or operator that misses its Swift version, you can define it right into your application code.

+ +

For example, you can add support for the DATE function, thanks to SQL Interpolation:

+
func date(_ value: SQLSpecificExpressible) -> SQLExpression {
+    SQL("DATE(\(value))").sqlExpression
+}
+
+// SELECT * FROM "player" WHERE DATE("createdAt") = '2020-01-23'
+let request = Player.filter(date(Column("createdAt")) == "2020-01-23")
+
+ +

See the Query Interface Organization for more information about SQLSpecificExpressible and SQLExpression.

+

Fetching from Requests

+ +

Once you have a request, you can fetch the records at the origin of the request:

+
// Some request based on `Player`
+let request = Player.filter(...)... // QueryInterfaceRequest<Player>
+
+// Fetch players:
+try request.fetchCursor(db) // A Cursor of Player
+try request.fetchAll(db)    // [Player]
+try request.fetchSet(db)    // Set<Player>
+try request.fetchOne(db)    // Player?
+
+ +

For example:

+
let allPlayers = try Player.fetchAll(db)                            // [Player]
+let arthur = try Player.filter(nameColumn == "Arthur").fetchOne(db) // Player?
+
+ +

See fetching methods for information about the fetchCursor, fetchAll, fetchSet and fetchOne methods.

+ +

You sometimes want to fetch other values.

+ +

The simplest way is to use the request as an argument to a fetching method of the desired type:

+
// Fetch an Int
+let request = Player.select(max(scoreColumn))
+let maxScore = try Int.fetchOne(db, request) // Int?
+
+// Fetch a Row
+let request = Player.select(min(scoreColumn), max(scoreColumn))
+let row = try Row.fetchOne(db, request)!     // Row
+let minScore = row[0] as Int?
+let maxScore = row[1] as Int?
+
+ +

You can also change the request so that it knows the type it has to fetch:

+ +
    +
  • With asRequest(of:), useful when you use Associations:

    +
    struct BookInfo: FetchableRecord, Decodable {
    +    var book: Book
    +    var author: Author
    +}
    +
    +// A request of BookInfo
    +let request = Book
    +    .including(required: Book.author)
    +    .asRequest(of: BookInfo.self)
    +
    +let bookInfos = try dbQueue.read { db in
    +    try request.fetchAll(db) // [BookInfo]
    +}
    +
  • +
  • With select(..., as:), which is handy when you change the selection:

    +
    // A request of Int
    +let request = Player.select(max(scoreColumn), as: Int.self)
    +
    +let maxScore = try dbQueue.read { db in
    +    try request.fetchOne(db) // Int?
    +}
    +
  • +
+

Fetching by Key

+ +

Fetching records according to their primary key is a common task.

+ +

Identifiable Records can use the type-safe methods fetchOne(_:id:), fetchAll(_:ids:) and fetchSet(_:ids:):

+
try Player.fetchOne(db, id: 1)               // Player?
+try Country.fetchAll(db, ids: ["FR", "US"])  // [Countries]
+
+ +

All record types can use fetchOne(_:key:), fetchAll(_:keys:) and fetchSet(_:keys:) that apply conditions on primary and unique keys:

+
try Player.fetchOne(db, key: 1)              // Player?
+try Country.fetchAll(db, keys: ["FR", "US"]) // [Country]
+try Player.fetchOne(db, key: ["email": "arthur@example.com"])            // Player?
+try Citizenship.fetchOne(db, key: ["citizenId": 1, "countryCode": "FR"]) // Citizenship?
+
+ +

When the table has no explicit primary key, GRDB uses the hidden "rowid” column:

+
// SELECT * FROM document WHERE rowid = 1
+try Document.fetchOne(db, key: 1)            // Document?
+
+ +

When you want to build a request and plan to fetch from it later, use a filter method:

+
let request = Player.filter(id: 1)
+let request = Country.filter(ids: ["FR", "US"])
+let request = Player.filter(key: ["email": "arthur@example.com"])
+let request = Citizenship.filter(key: ["citizenId": 1, "countryCode": "FR"])
+
+

Testing for Record Existence

+ +

You can check if a request has matching rows in the database.

+
// Some request based on `Player`
+let request = Player.filter(...)...
+
+// Check for player existence:
+let noSuchPlayer = try request.isEmpty(db) // Bool
+
+ +

You should check for emptiness instead of counting:

+
// Correct
+let noSuchPlayer = try request.fetchCount(db) == 0
+// Even better
+let noSuchPlayer = try request.isEmpty(db)
+
+ +

You can also check if a given primary or unique key exists in the database.

+ +

Identifiable Records can use the type-safe method exists(_:id:):

+
try Player.exists(db, id: 1)
+try Country.exists(db, id: "FR")
+
+ +

All record types can use exists(_:key:) that can check primary and unique keys:

+
try Player.exists(db, key: 1)
+try Country.exists(db, key: "FR")
+try Player.exists(db, key: ["email": "arthur@example.com"])
+try Citizenship.exists(db, key: ["citizenId": 1, "countryCode": "FR"])
+
+ +

You should check for key existence instead of fetching a record and checking for nil:

+
// Correct
+let playerExists = try Player.fetchOne(db, id: 1) != nil
+// Even better
+let playerExists = try Player.exists(db, id: 1)
+
+

Fetching Aggregated Values

+ +

Requests can count. The fetchCount() method returns the number of rows that would be returned by a fetch request:

+
// SELECT COUNT(*) FROM player
+let count = try Player.fetchCount(db) // Int
+
+// SELECT COUNT(*) FROM player WHERE email IS NOT NULL
+let count = try Player.filter(emailColumn != nil).fetchCount(db)
+
+// SELECT COUNT(DISTINCT name) FROM player
+let count = try Player.select(nameColumn).distinct().fetchCount(db)
+
+// SELECT COUNT(*) FROM (SELECT DISTINCT name, score FROM player)
+let count = try Player.select(nameColumn, scoreColumn).distinct().fetchCount(db)
+
+ +

Other aggregated values can also be selected and fetched (see SQL Functions):

+
let request = Player.select(max(scoreColumn))
+let maxScore = try Int.fetchOne(db, request) // Int?
+
+let request = Player.select(min(scoreColumn), max(scoreColumn))
+let row = try Row.fetchOne(db, request)!     // Row
+let minScore = row[0] as Int?
+let maxScore = row[1] as Int?
+
+

Delete Requests

+ +

Requests can delete records, with the deleteAll() method:

+
// DELETE FROM player
+try Player.deleteAll(db)
+
+// DELETE FROM player WHERE team = 'red'
+try Player
+    .filter(teamColumn == "red")
+    .deleteAll(db)
+
+// DELETE FROM player ORDER BY score LIMIT 10
+try Player
+    .order(scoreColumn)
+    .limit(10)
+    .deleteAll(db)
+
+ +
+

:point_up: Note Deletion methods are available on types that adopt the TableRecord protocol, and Table:

+
struct Player: TableRecord { ... }
+try Player.deleteAll(db)          // Fine
+try Table("player").deleteAll(db) // Just as fine
+
+
+ +

Deleting records according to their primary key is a common task.

+ +

Identifiable Records can use the type-safe methods deleteOne(_:id:) and deleteAll(_:ids:):

+
try Player.deleteOne(db, id: 1)
+try Country.deleteAll(db, ids: ["FR", "US"])
+
+ +

All record types can use deleteOne(_:key:) and deleteAll(_:keys:) that apply conditions on primary and unique keys:

+
try Player.deleteOne(db, key: 1)
+try Country.deleteAll(db, keys: ["FR", "US"])
+try Player.deleteOne(db, key: ["email": "arthur@example.com"])
+try Citizenship.deleteOne(db, key: ["citizenId": 1, "countryCode": "FR"])
+
+ +

When the table has no explicit primary key, GRDB uses the hidden “rowid” column:

+
// DELETE FROM document WHERE rowid = 1
+try Document.deleteOne(db, id: 1)             // Document?
+
+

Update Requests

+ +

Requests can batch update records. The updateAll() method accepts column assignments defined with the set(to:) method:

+
// UPDATE player SET score = 0, isHealthy = 1, bonus = NULL
+try Player.updateAll(db, 
+    Column("score").set(to: 0), 
+    Column("isHealthy").set(to: true), 
+    Column("bonus").set(to: nil))
+
+// UPDATE player SET score = 0 WHERE team = 'red'
+try Player
+    .filter(Column("team") == "red")
+    .updateAll(db, Column("score").set(to: 0))
+
+// UPDATE player SET top = 1 ORDER BY score DESC LIMIT 10
+try Player
+    .order(Column("score").desc)
+    .limit(10)
+    .updateAll(db, Column("top").set(to: true))
+
+// UPDATE country SET population = 67848156 WHERE id = 'FR'
+try Country
+    .filter(id: "FR")
+    .updateAll(db, Column("population").set(to: 67_848_156))
+
+ +

Column assignments accept any expression:

+
// UPDATE player SET score = score + (bonus * 2)
+try Player.updateAll(db, Column("score").set(to: Column("score") + Column("bonus") * 2))
+
+ +

As a convenience, you can also use the +=, -=, *=, or /= operators:

+
// UPDATE player SET score = score + (bonus * 2)
+try Player.updateAll(db, Column("score") += Column("bonus") * 2)
+
+ +

Default Conflict Resolution rules apply, and you may also provide a specific one:

+
// UPDATE OR IGNORE player SET ...
+try Player.updateAll(db, onConflict: .ignore, /* assignments... */)
+
+ +
+

:point_up: Note The updateAll method is available on types that adopt the TableRecord protocol, and Table:

+
struct Player: TableRecord { ... }
+try Player.updateAll(db, ...)          // Fine
+try Table("player").updateAll(db, ...) // Just as fine
+
+
+

Custom Requests

+ +

Until now, we have seen requests created from any type that adopts the TableRecord protocol:

+
let request = Player.all()  // QueryInterfaceRequest<Player>
+
+ +

Those requests of type QueryInterfaceRequest can fetch and count:

+
try request.fetchCursor(db) // A Cursor of Player
+try request.fetchAll(db)    // [Player]
+try request.fetchSet(db)    // Set<Player>
+try request.fetchOne(db)    // Player?
+try request.fetchCount(db)  // Int
+
+ +

When the query interface can not generate the SQL you need, you can still fallback to raw SQL:

+
// Custom SQL is always welcome
+try Player.fetchAll(db, sql: "SELECT ...")   // [Player]
+
+ +

But you may prefer to bring some elegance back in, and build custom requests:

+
// No custom SQL in sight
+try Player.customRequest().fetchAll(db) // [Player]
+
+ +

To build custom requests, you can use one of the built-in requests or derive requests from other requests.

+ +
    +
  • SQLRequest is a fetch request built from raw SQL. For example:

    +
    extension Player {
    +    static func filter(color: Color) -> SQLRequest<Player> {
    +        SQLRequest<Player>(
    +            sql: "SELECT * FROM player WHERE color = ?"
    +            arguments: [color])
    +    }
    +}
    +
    +// [Player]
    +try Player.filter(color: .red).fetchAll(db)
    +
    + +

    SQLRequest supports SQL Interpolation:

    +
    extension Player {
    +    static func filter(color: Color) -> SQLRequest<Player> {
    +        "SELECT * FROM player WHERE color = \(color)"
    +    }
    +}
    +
  • +
  • The asRequest(of:) method changes the type fetched by the request. It is useful, for example, when you use Associations:

    +
    struct BookInfo: FetchableRecord, Decodable {
    +    var book: Book
    +    var author: Author
    +}
    +
    +let request = Book
    +    .including(required: Book.author)
    +    .asRequest(of: BookInfo.self)
    +
    +// [BookInfo]
    +try request.fetchAll(db)
    +
  • +
  • The adapted(_:) method eases the consumption of complex rows with row adapters. See Joined Queries Support for some sample code that uses this method.

  • +
  • AnyFetchRequest: a type-erased request.

  • +
+

Joined Queries Support

+ +

GRDB helps consuming joined queries with complex selection.

+ +

In this chapter, we will focus on the extraction of information from complex rows, such as the ones fetched by the query below:

+
-- How to consume the left, middle, and right parts of those rows?
+SELECT player.*, team.*, MAX(round.score) AS maxScore
+FROM player
+LEFT JOIN team ON ...
+LEFT JOIN round ON ...
+GROUP BY ...
+
+ +

We will not talk about the generation of joined queries, which is covered in Associations.

+ +

So what are we talking about?

+ +

It is difficult to consume rows fetched from complex joined queries, because they often contain several columns with the same name: id from table player, id from table team, etc.

+ +

When such ambiguity happens, GRDB row accessors always favor the leftmost matching column. This means that row["id"] would give a player id, without any obvious way to access the team id.

+ +

A classical technique to avoid this ambiguity is to give each column a unique name. For example:

+
-- A classical technique
+SELECT player.id AS player_id, player.name AS player_name, team.id AS team_id, team.name AS team_name, team.color AS team_color, MAX(round.score) AS maxScore
+FROM player
+LEFT JOIN team ON ...
+LEFT JOIN round ON ...
+GROUP BY ...
+
+ +

This technique works pretty well, but it has three drawbacks:

+ +
    +
  1. The selection becomes hard to read and understand.
  2. +
  3. Such queries are difficult to write by hand.
  4. +
  5. The mangled names are a very bad fit for FetchableRecord types that expect specific column names. After all, if the Team record type can read SELECT * FROM team ..., it should be able to read SELECT ..., team.*, ... as well.
  6. +
+ +

We thus need another technique. Below we’ll see how to split rows into slices, and preserve column names.

+ +

SELECT player.*, team.*, MAX(round.score) AS maxScore FROM ... will be split into three slices: one that contains player’s columns, one that contains team’s columns, and a remaining slice that contains remaining column(s). The Player record type will be able to read the first slice, which contains the columns expected by the Player.init(row:) initializer. In the same way, the Team record type could read the second slice.

+ +

Unlike the name-mangling technique, splitting rows keeps SQL legible, accepts your hand-crafted SQL queries, and plays as nicely as possible with your existing record types.

+ + +

Splitting Rows, an Introduction

+ +

Let’s first write some introductory code, hoping that this chapter will make you understand how pieces fall together. We’ll see later how records will help us streamline the initial approach, how to track changes in joined requests, and how we can use the standard Decodable protocol.

+ +

To split rows, we will use row adapters. Row adapters adapt rows so that row consumers see exactly the columns they want. Among other things, row adapters can define several row scopes that give access to as many row slices. Sounds like a perfect match.

+ +

At the very beginning, there is an SQL query:

+
try dbQueue.read { db in
+    let sql = """
+        SELECT player.*, team.*, MAX(round.score) AS maxScore
+        FROM player
+        LEFT JOIN team ON ...
+        LEFT JOIN round ON ...
+        GROUP BY ...
+        """
+
+ +

We need an adapter that extracts player columns, in a slice that has as many columns as there are columns in the player table. That’s RangeRowAdapter:

+
    // SELECT player.*, team.*, ...
+    //        <------>
+    let playerWidth = try db.columns(in: "player").count
+    let playerAdapter = RangeRowAdapter(0 ..< playerWidth)
+
+ +

We also need an adapter that extracts team columns:

+
    // SELECT player.*, team.*, ...
+    //                  <---->
+    let teamWidth = try db.columns(in: "team").count
+    let teamAdapter = RangeRowAdapter(playerWidth ..< (playerWidth + teamWidth))
+
+ +

We merge those two adapters in a single ScopeAdapter that will allow us to access both sliced rows:

+
    let playerScope = "player"
+    let teamScope = "team"
+    let adapter = ScopeAdapter([
+        playerScope: playerAdapter,
+        teamScope: teamAdapter])
+
+ +

And now we can fetch, and start consuming our rows. You already know row cursors:

+
    let rows = try Row.fetchCursor(db, sql: sql, adapter: adapter)
+    while let row = try rows.next() {
+
+ +

From a fetched row, we can build a player:

+
        let player: Player = row[playerScope]
+
+ +

In the SQL query, the team is joined with the LEFT JOIN operator. This means that the team may be missing: its slice may contain team values, or it may only contain NULLs. When this happens, we don’t want to build a Team record, and we thus load an optional Team:

+
        let team: Team? = row[teamScope]
+
+ +

And finally, we can load the maximum score, assuming that the “maxScore” column is not ambiguous:

+
        let maxScore: Int = row["maxScore"]
+
+        print("player: \(player)")
+        print("team: \(team)")
+        print("maxScore: \(maxScore)")
+    }
+}
+
+ +
+

:bulb: In this chapter, we have learned:

+ +
    +
  • how to use RangeRowAdapter to extract a specific table’s columns into a row slice.
  • +
  • how to use ScopeAdapter to gives access to several row slices through named scopes.
  • +
  • how to use Row subscripting to extract records from rows, or optional records in order to deal with left joins.
  • +
+
+

Splitting Rows, the Record Way

+ +

Our introduction above has introduced important techniques. It uses row adapters in order to split rows. It uses Row subscripting in order to extract records from row slices.

+ +

But we may want to make it more usable and robust:

+ +
    +
  1. It’s generally easier to consume records than raw rows.
  2. +
  3. Joined records not always need all columns from a table (see TableRecord.databaseSelection in Columns Selected by a Request).
  4. +
  5. Building row adapters is long and error prone.
  6. +
+ +

To address the first bullet, let’s define a record that holds our player, optional team, and maximum score. Since it can decode database rows, it adopts the FetchableRecord protocol:

+
struct PlayerInfo {
+    var player: Player
+    var team: Team?
+    var maxScore: Int
+}
+
+/// PlayerInfo can decode rows:
+extension PlayerInfo: FetchableRecord {
+    private enum Scopes {
+        static let player = "player"
+        static let team = "team"
+    }
+
+    init(row: Row) {
+        player = row[Scopes.player]
+        team = row[Scopes.team]
+        maxScore = row["maxScore"]
+    }
+}
+
+ +

Now we write a method that returns a custom request, and then build the fetching method on top of that request:

+
extension PlayerInfo {
+    /// The request for all player infos
+    static func all() -> AdaptedFetchRequest<SQLRequest<PlayerInfo>> {
+
+ +

To acknowledge that both Player and Team records may customize their selection of the “player” and “team” columns, we’ll write our SQL in a slightly different way:

+
        // Let Player and Team customize their selection:
+        let request: SQLRequest<PlayerInfo> = """
+            SELECT
+                \(columnsOf: Player.self), -- instead of player.*
+                \(columnsOf: Team.self),   -- instead of team.*
+                MAX(round.score) AS maxScore
+            FROM player
+            LEFT JOIN team ON ...
+            LEFT JOIN round ON ...
+            GROUP BY ...
+            """
+
+ +

Our SQL is no longer a regular String, but an SQLRequest<PlayerInfo> which profits from SQL Interpolation. Inside this request, \(columnsOf: Player.self) outputs player.*, unless Player defines a customized selection.

+ +

Now we need to build adapters.

+ +

We use the splittingRowAdapters global function, whose job is precisely to build row adapters of desired widths:

+ +

And since counting table columns require a database connection, we use the adapted(_:) request method. It allows requests to adapt themselves right before execution, when a database connection is available.

+
        return request.adapted { db in
+            let adapters = try splittingRowAdapters(columnCounts: [
+                Player.numberOfSelectedColumns(db),
+                Team.numberOfSelectedColumns(db)])
+            return ScopeAdapter([
+                Scopes.player: adapters[0],
+                Scopes.team: adapters[1]])
+        }
+    }
+
+ +
+

:point_up: Note: splittingRowAdapters returns as many adapters as necessary to fully split a row. In the example above, it returns three adapters: one for player, one for team, and one for the remaining columns.

+
+ +

And finally, we can define the fetching method:

+
    /// Fetches all player infos
+    static func fetchAll(_ db: Database) throws -> [PlayerInfo] {
+        try all().fetchAll(db)
+    }
+}
+
+ +

And when your app needs to fetch player infos, it now reads:

+
// Fetch player infos
+let playerInfos = try dbQueue.read { db in
+    try PlayerInfo.fetchAll(db)
+}
+
+ +
+

:bulb: In this chapter, we have learned:

+ +
    +
  • how to define a FetchableRecord record that consumes rows fetched from a joined query.
  • +
  • how to use SQL Interpolation and numberOfSelectedColumns in order to deal with nested record types that define custom selection.
  • +
  • how to use splittingRowAdapters in order to streamline the definition of row slices.
  • +
  • how to gather all relevant methods and constants in a record type, fully responsible of its relationship with the database.
  • +
+
+

Splitting Rows, the Codable Way

+ +

Codable Records build on top of the standard Decodable protocol in order to decode database rows.

+ +

You can consume complex joined queries with Codable records as well. As a demonstration, we’ll rewrite the above sample code:

+
struct Player: Decodable, FetchableRecord, TableRecord {
+    var id: Int64
+    var name: String
+}
+struct Team: Decodable, FetchableRecord, TableRecord {
+    var id: Int64
+    var name: String
+    var color: Color
+}
+struct PlayerInfo: Decodable, FetchableRecord {
+    var player: Player
+    var team: Team?
+    var maxScore: Int
+}
+
+extension PlayerInfo {
+    /// The request for all player infos
+    static func all() -> AdaptedFetchRequest<SQLRequest<PlayerInfo>> {
+        let request: SQLRequest<PlayerInfo> = """
+            SELECT
+                \(columnsOf: Player.self),
+                \(columnsOf: Team.self),
+                MAX(round.score) AS maxScore
+            FROM player
+            LEFT JOIN team ON ...
+            LEFT JOIN round ON ...
+            GROUP BY ...
+            """
+        return request.adapted { db in
+            let adapters = try splittingRowAdapters(columnCounts: [
+                Player.numberOfSelectedColumns(db),
+                Team.numberOfSelectedColumns(db)])
+            return ScopeAdapter([
+                CodingKeys.player.stringValue: adapters[0],
+                CodingKeys.team.stringValue: adapters[1]])
+        }
+    }
+
+    /// Fetches all player infos
+    static func fetchAll(_ db: Database) throws -> [PlayerInfo] {
+        try all().fetchAll(db)
+    }
+}
+
+// Fetch player infos
+let playerInfos = try dbQueue.read { db in
+    try PlayerInfo.fetchAll(db)
+}
+
+ +
+

:bulb: In this chapter, we have learned how to use the Decodable protocol and its associated CodingKeys enum in order to dry up our code.

+
+

Database Changes Observation

+ +

SQLite notifies its host application of changes performed to the database, as well of transaction commits and rollbacks.

+ +

GRDB puts this SQLite feature to some good use, and lets you observe the database in various ways:

+ + + +

Database observation requires that a single database queue or pool is kept open for all the duration of the database usage.

+

After Commit Hook

+ +

When your application needs to make sure a specific database transaction has been successfully committed before it executes some work, use the Database.afterNextTransactionCommit(_:) method.

+ +

Its closure argument is called right after database changes have been successfully written to disk:

+
try dbQueue.write { db in
+    db.afterNextTransactionCommit { db in
+        print("success")
+    }
+    ...
+} // prints "success"
+
+ +

The closure runs in a protected dispatch queue, serialized with all database updates.

+ +

This “after commit hook” helps synchronizing the database with other resources, such as files, or system sensors.

+ +

In the example below, a location manager starts monitoring a CLRegion if and only if it has successfully been stored in the database:

+
/// Inserts a region in the database, and start monitoring upon
+/// successful insertion.
+func startMonitoring(_ db: Database, region: CLRegion) throws {
+    // Make sure database is inside a transaction
+    try db.inSavepoint {
+
+        // Save the region in the database
+        try insert(...)
+
+        // Start monitoring if and only if the insertion is
+        // eventually committed
+        db.afterNextTransactionCommit { _ in
+            // locationManager prefers the main queue:
+            DispatchQueue.main.async {
+                locationManager.startMonitoring(for: region)
+            }
+        }
+
+        return .commit
+    }
+}
+
+ +

The method above won’t trigger the location manager if the transaction is eventually rollbacked (explicitly, or because of an error), as in the sample code below:

+
try dbQueue.write { db in
+    // success
+    try startMonitoring(db, region)
+
+    // On error, the transaction is rollbacked, the region is not inserted, and
+    // the location manager is not invoked.
+    try failableMethod(db)
+}
+
+

ValueObservation

+ +

ValueObservation tracks changes in database values. It automatically notifies your application with fresh values whenever changes are committed in the database.

+ +

Tracked changes are insertions, updates, and deletions that impact the tracked value, performed with the query interface, or raw SQL. This includes indirect changes triggered by foreign keys actions or SQL triggers.

+ +
+

:point_up: Note: Some changes are not notified: changes to internal system tables (such as sqlite\_master), and changes to WITHOUT ROWID tables.

+
+ +

ValueObservation is the preferred GRDB tool for keeping your user interface synchronized with the database. See the Demo Applications for sample code.

+ + +

ValueObservation Usage

+ +
    +
  1. Make sure that a unique database connection is kept open during the whole duration of the observation.

    + +

    ValueObservation does not notify changes performed by external connections.

  2. +
  3. Define a ValueObservation by providing a function that fetches the observed value.

    +
    let observation = ValueObservation.tracking { db in
    +    /* fetch and return the observed value */
    +}
    +
    +// For example, an observation of [Player], which tracks all players:
    +let observation = ValueObservation.tracking { db in
    +    try Player.fetchAll(db)
    +}
    +
    +// The same observation, using shorthand notation:
    +let observation = ValueObservation.tracking(Player.fetchAll)
    +
    + +

    The observation can perform multiple requests, from multiple database tables, and even use raw SQL.

    + +
    + Example of a more complex ValueObservation + +“`swift +struct HallOfFame { + var totalPlayerCount: Int + var bestPlayers: [Player] +} + +// An observation of HallOfFame +let observation = ValueObservation.tracking { db -> HallOfFame in + let totalPlayerCount = try Player.fetchCount(db) + + let bestPlayers = try Player + .order(Column("score”).desc) + .limit(10) + .fetchAll(db) + + return HallOfFame( + totalPlayerCount: totalPlayerCount, + bestPlayers: bestPlayers) +} +“` + +
    + +
    + Example of a SQL ValueObservation + +”`swift +// An observation of the maximum score +let observation = ValueObservation.tracking { db in + try Int.fetchOne(db, sql: “SELECT MAX(score) FROM player”) +} +“` + +
  4. +
  5. Start the observation in order to be notified of changes:

    +
    // Start observing the database
    +let cancellable: DatabaseCancellable = observation.start(
    +    in: dbQueue, // or dbPool
    +    onError: { error in print("players could not be fetched") },
    +    onChange: { (players: [Player]) in print("fresh players", players) })
    +
  6. +
  7. Stop the observation by calling the cancel() method on the object returned by the start method. Cancellation is automatic when the cancellable is deinitialized:

    +
    cancellable.cancel()
    +
  8. +
+ +

As a convenience, ValueObservation can be turned into a Combine publisher, or a RxSwift Observable (see Combine Support and the companion library RxGRDB):

+ +
+ Combine example + +”`swift +import Combine +import GRDB + +let observation = ValueObservation.tracking(Player.fetchAll) + +let cancellable = observation.publisher(in: dbQueue).sink( + receiveCompletion: { completion in … }, + receiveValue: { (players: [Player]) in + print(“fresh players”, players) + }) +“` + +See [Combine Support] for more information. + +
+ +
+ RxSwift example + +”`swift +import GRDB +import RxGRDB +import RxSwift + +let observation = ValueObservation.tracking(Player.fetchAll) + +let disposable = observation.rx.observe(in: dbQueue).subscribe( + onNext: { (players: [Player]) in + print(“fresh players”, players) + }, + onError: { error in … }) +“` + +See the companion library [RxGRDB] for more information. + +
+ +

Generally speaking:

+ +
    +
  • ValueObservation notifies an initial value before the eventual changes.
  • +
  • ValueObservation only notifies changes committed to disk.
  • +
  • By default, ValueObservation notifies a fresh value whenever any of its component is modified (any fetched column, row, etc.). This can be configured.
  • +
  • By default, ValueObservation notifies the initial value, as well as eventual changes and errors, on the main thread, asynchronously. This can be configured.
  • +
  • ValueObservation may coalesce subsequent changes into a single notification.
  • +
  • ValueObservation may notify consecutive identical values. You can filter out the undesired duplicates with the removeDuplicates() method.
  • +
  • The database observation stops when any of those conditions is met: + +
      +
    • The cancellable returned by the start method is cancelled or deinitialized.
    • +
    • An error occurs.
    • +
    • The database connection is closed.
    • +
  • +
+ +

Take care that there are use cases that ValueObservation is unfit for. For example, your application may need to process absolutely all changes, and avoid any coalescing. It may also need to process changes before any further modifications are performed in the database file. In those cases, you need to track individual transactions, not values. See DatabaseRegionObservation. If you need to process uncommitted changes, see TransactionObserver.

+

ValueObservation Scheduling

+ +

By default, ValueObservation notifies the initial value, as well as eventual changes and errors, on the main thread, asynchronously:

+
// The default scheduling
+let cancellable = observation.start(
+    in: dbQueue,
+    onError: { error in ... },                   // called asynchronously on the main thread
+    onChange: { value in print("fresh value") }) // called asynchronously on the main thread
+
+ +

You can change this behavior by adding a scheduling argument to the start() method.

+ +

For example, scheduling: .immediate makes sure the initial value is notified immediately when the observation starts. It helps your application update the user interface without having to wait for any asynchronous notifications:

+
class PlayersViewController: UIViewController {
+    private var cancellable: DatabaseCancellable?
+
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+
+        // Start observing the database
+        let observation = ValueObservation.tracking(Player.fetchAll)
+        cancellable = observation.start(
+            in: dbQueue,
+            scheduling: .immediate, // <- immediate scheduler
+            onError: { error in ... },
+            onChange: { [weak self] (players: [Player]) in
+                guard let self = self else { return }
+                self.updateView(players)
+            })
+        // <- Here the view has already been updated.
+    }
+
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+
+        // Stop observing the database
+        cancellable?.cancel()
+    }
+
+    private func updateView(_ players: [Player]) { ... }
+}
+
+ +

Note that the .immediate scheduling requires that the observation starts from the main thread. A fatal error is raised otherwise.

+ +

The other built-in scheduler .async(onQueue:) asynchronously schedules values and errors on the dispatch queue of your choice:

+
let queue: DispatchQueue = ...
+let cancellable = observation.start(
+    in: dbQueue,
+    scheduling: .async(onQueue: queue)
+    onError: { error in ... },                   // called asynchronously on queue
+    onChange: { value in print("fresh value") }) // called asynchronously on queue
+
+

ValueObservation Operators

+ +

Operators are methods that transform and configure value observations so that they better fit the needs of your application.

+ + + +

Debugging Operators

+ + +

ValueObservation.map

+ +

The map operator transforms the values notified by a ValueObservation.

+ +

For example:

+
// Turn an observation of Player? into an observation of UIImage?
+let observation = ValueObservation
+    .tracking { db in try Player.fetchOne(db, id: 42) }
+    .map { player in player?.image }
+
+ +

The transformation function does not block any database access. This makes the map operator a tool which helps reducing database contention.

+

ValueObservation.removeDuplicates

+ +

The removeDuplicates operator filters out consecutive equal values. The observed values must adopt the standard Equatable protocol.

+ +

For example:

+
// An observation of distinct Player?
+let observation = ValueObservation
+    .tracking { db in try Player.fetchOne(db, id: 42) }
+    .removeDuplicates()
+
+ +

:bulb: Tip: When the observed value does not adopt Equatable, you can observe distinct raw database values such as Row or DatabaseValue, before converting them to the desired type. For example, the previous observation can be rewritten as below:

+
// An observation of distinct Player?
+let request = Player.filter(id: 42)
+let observation = ValueObservation
+    .tracking { db in try Row.fetchOne(db, request) }
+    .removeDuplicates() // Row adopts Equatable
+    .map { row in row.map(Player.init(row:) }
+
+ +

This technique is also available for requests that involve Associations:

+
struct TeamInfo: Decodable, FetchableRecord {
+    var team: Team
+    var players: [Player]
+}
+
+// An observation of distinct [TeamInfo]
+let request = Team.including(all: Team.players)
+let observation = ValueObservation
+    .tracking { db in try Row.fetchAll(db, request) }
+    .removeDuplicates() // Row adopts Equatable
+    .map { rows in rows.map(TeamInfo.init(row:) }
+
+

ValueObservation.requiresWriteAccess

+ +

The requiresWriteAccess property is false by default. When true, a ValueObservation has a write access to the database, and its fetches are automatically wrapped in a savepoint:

+
var observation = ValueObservation.tracking { db in
+    // write access allowed
+    ...
+}
+observation.requiresWriteAccess = true
+
+ +

When you use a database pool, this flag has a performance hit.

+

ValueObservation.handleEvents

+ +

The handleEvents operator lets your application observe the lifetime of a ValueObservation:

+
let observation = ValueObservation
+    .tracking { db in ... }
+    .handleEvents(
+        willStart: {
+            // The observation starts.
+        },
+        willFetch: {
+            // The observation will perform a database fetch.
+        },
+        willTrackRegion: { databaseRegion in
+            // The observation starts tracking a database region.
+        },
+        databaseDidChange: {
+            // The observation was impacted by a database change.
+        },
+        didReceiveValue: { value in
+            // A fresh value was observed.
+            // NOTE: This closure runs on an unspecified DispatchQueue.
+        },
+        didFail: { error in
+            // The observation completes with an error.
+        },
+        didCancel: {
+            // The observation was cancelled.
+        })
+
+ +

See also ValueObservation.print.

+

ValueObservation.print

+ +

The print operator logs messages for all ValueObservation events.

+
let observation = ValueObservation
+    .tracking { db in ... }
+    .print()
+
+ +

See also ValueObservation.handleEvents.

+

ValueObservation Sharing

+ +

:fire: EXPERIMENTAL

+ +

Sharing a ValueObservation allows several components of your app to be notified of database changes, in an efficient way.

+ +

A shared observation spares database resources. For example, when a database change happens, a fresh value is fetched only once, and then notified to all subscriptions.

+ +

Usage:

+
// SharedValueObservation<[Player]>
+let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue)
+//  ~~~~~~~~~~~~~~~~~~~~
+
+let cancellable = try sharedObservation.start(
+    onError: { error in ... },
+    onChange: { players: [Player] in
+        print("fresh players: \(players)")
+    })
+
+ +

The sharing only applies if you start observing the database from the same SharedValueObservation instance:

+
// NOT shared
+let cancellable1 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+let cancellable2 = ValueObservation.tracking { db in ... }.shared(in: dbQueue).start(...)
+
+// Shared
+let sharedObservation = ValueObservation.tracking { db in ... }.shared(in: dbQueue)
+let cancellable1 = sharedObservation.start(...)
+let cancellable2 = sharedObservation.start(...)
+
+ +

By default, fresh values are dispatched asynchronously on the main queue. You can change this behavior (see ValueObservation Scheduling for more information):

+
let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue, scheduling: .immediate)
+//                       ~~~~~~~~~~~~~~~~~~~~~~
+
+ +

A shared observation starts observing the database as soon as it is subscribed. You can choose if database observation should stop, or not, when its number of subscriptions drops down to zero, with the extent parameter:

+
// The default: stops observing the database when the number of subscriptions 
+// drops down to zero, and restart database observation on the next subscription.
+//
+// Database errors can be recovered by resubscribing to the shared observation.
+let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue, extent: .whileObserved)
+//                       ~~~~~~~~~~~~~~~~~~~~~~
+
+// Only stops observing the database when the shared observation is deinitialized,
+// and all subscriptions are cancelled.
+//
+// This extent prevents the shared observation from recovering from database
+// errors. To recover from database errors, create a new shared
+// SharedValueObservation instance.
+let sharedObservation = ValueObservation
+    .tracking { db in try Player.fetchAll(db) }
+    .shared(in: dbQueue, extent: .observationLifetime)
+//                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ +
+

:point_up: Note: ValueObservation and SharedValueObservation are nearly identical, but there are a few differences you should be aware of:

+ +
    +
  • SharedValueObservation has no operator such as map. As a replacement, you may use Combine apis:

    +
    let sharedObservation = ValueObservation.tracking { ... }.shared(in: dbQueue)
    +let cancellable = try sharedObservation
    +    .publisher() // Turn shared observation into a Combine Publisher
    +    .map { ... } // The map operator from Combine
    +    .sink(...)
    +
  • +
  • Unlike ValueObservation, SharedValueObservation retains the database connection. As long as there exists a SharedValueObservation instance, or an active suscription to a shared observation, the database connection won’t be deinitialized.

  • +
+
+

Specifying the Region Tracked by ValueObservation

+ +

While the standard ValueObservation.tracking { db in ... } method lets you track changes to a fetched value and receive any changes to it, sometimes your use case might require more granular control.

+ +

Consider a scenario where you’d like to get a specific Player’s row, but only when their score column changes. You can use tracking(region:fetch:) to do just that:

+
let observation = ValueObservation.tracking(
+    // Define what database region constitutes a "change"
+    region: Player.select(Column("score")).filter(id: 1),
+    // Define what to fetch upon such change
+    fetch: { db in try Player.fetchOne(db, id: 1) }
+)
+
+ +

This overload of ValueObservation lets you entirely separate the observed region from the fetched value itself, providing utmost flexibility. See DatabaseRegionConvertible for more information.

+

ValueObservation Performance

+ +

This chapter further describes runtime aspects of ValueObservation, and provides some optimization tips for demanding applications.

+ +

ValueObservation is triggered by database transactions that may modify the tracked value.

+ +

For example, if you track the maximum score of players, all transactions that impact the score column of the player database table (any update, insertion, or deletion) trigger the observation, even if the maximum score itself is not changed.

+ +

You can filter out undesired duplicate notifications with the removeDuplicates() method.

+ +

ValueObservation can create database contention. In other words, active observations take a toll on the constrained database resources. When triggered by impactful transactions, observations fetch fresh values, and can delay read and write database accesses of other application components.

+ +

When needed, you can help GRDB optimize observations and reduce database contention:

+ +
    +
  1. :bulb: Tip: Stop observations when possible.

    + +

    For example, if a UIViewController needs to display database values, it can start the observation in viewWillAppear, and stop it in viewWillDisappear. Check the sample code above.

  2. +
  3. :bulb: Tip: Share observations when possible.

    + +

    Each call to ValueObservation.start method triggers independent values refreshes. When several components of your app are interested in the same value, consider sharing the observation.

  4. +
  5. :bulb: Tip: Use a database pool, because it can perform multi-threaded database accesses.

  6. +
  7. :bulb: Tip: When the observation processes some raw fetched values, use the map operator:

    +
    // Plain observation
    +let observation = ValueObservation.tracking { db -> MyValue in
    +    let players = try Player.fetchAll(db)
    +    return computeMyValue(players)
    +}
    +
    +// Optimized observation
    +let observation = ValueObservation
    +    .tracking { db try Player.fetchAll(db) }
    +    .map { players in computeMyValue(players) }
    +
    + +

    The map operator helps reducing database contention because it performs its job without blocking concurrent database reads.

  8. +
  9. :bulb: Tip: When the observation tracks a constant database region, create an optimized observation with the ValueObservation.trackingConstantRegion(_:) method.

    + +

    The optimization only kicks in when the observation is started from a database pool: fresh values are fetched concurrently, and do not block database writes.

    + +

    The ValueObservation.trackingConstantRegion(_:) has a precondition: the observed requests must fetch from a single and constant database region. The tracked region is made of tables, columns, and, when possible, rowids of individual rows. All changes that happen outside of this region do not impact the observation.

    + +

    For example:

    +
    // Tracks the full 'player' table (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> [Player] in
    +    try Player.fetchAll(db)
    +}
    +
    +// Tracks the row with id 42 in the 'player' table (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> Player? in
    +    try Player.fetchOne(db, id: 42)
    +}
    +
    +// Tracks the 'score' column in the 'player' table (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> Int? in
    +    try Player.select(max(Column("score"))).fetchOne(db)
    +}
    +
    +// Tracks both the 'player' and 'team' tables (only)
    +let observation = ValueObservation.trackingConstantRegion { db -> ([Team], [Player]) in
    +    let teams = try Team.fetchAll(db)
    +    let players = try Player.fetchAll(db)
    +    return (teams, players)
    +}
    +
    + +

    When you want to observe a varying database region, make sure you use the plain ValueObservation.tracking(_:) method instead, or else some changes will not be notified.

    + +

    For example, consider those three observations below that depend on some user preference. They all track a varying region, and must use ValueObservation.tracking(_:):

    +
    // Does not always track the same row in the player table.
    +let observation = ValueObservation.tracking { db -> Player? in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    return try Player.fetchOne(db, id: pref.favoritePlayerId)
    +}
    +
    +// Only tracks the 'user' table if there are some blocked emails.
    +let observation = ValueObservation.tracking { db -> [User] in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    let blockedEmails = pref.blockedEmails
    +    return try User.filter(blockedEmails.contains(Column("email"))).fetchAll(db)
    +}
    +
    +// Sometimes tracks the 'food' table, and sometimes the 'beverage' table.
    +let observation = ValueObservation.tracking { db -> Int in
    +    let pref = try Preference.fetchOne(db) ?? .default
    +    switch pref.selection {
    +    case .food: return try Food.fetchCount(db)
    +    case .beverage: return try Beverage.fetchCount(db)
    +    }
    +}
    +
    + +

    When you are in doubt, add the print() method to your observation before starting it, and look in your application logs for lines that start with tracked region. Make sure the printed database region covers the changes you expect to be tracked.

    + +

    + Examples of tracked regions

  10. +
+
- `empty`: The empty region, which tracks nothing and never triggers the observation.
+- `player(*)`: The full `player` table
+- `player(id,name)`: The `id` and `name` columns of the `player` table
+- `player(id,name)[1]`: The `id` and `name` columns of the row with id 1 in the `player` table
+- `player(*),preference(*)`: Both the full `player` and `preference` tables
+
+</details>
+
+

DatabaseRegionObservation

+ +

DatabaseRegionObservation tracks changes in database requests, and notifies each impactful transaction.

+ +

Tracked changes are insertions, updates, and deletions that impact the tracked requests, performed with the query interface, or raw SQL. This includes indirect changes triggered by foreign keys actions or SQL triggers.

+ +
+

:point_up: Note: Some changes are not notified: changes to internal system tables (such as sqlite_master), and changes to WITHOUT ROWID tables.

+
+ +

DatabaseRegionObservation calls your application right after changes have been committed in the database, and before any other thread had any opportunity to perform further changes. This is a pretty strong guarantee, that most applications do not really need. Instead, most applications prefer to be notified with fresh values: make sure you check ValueObservation before using DatabaseRegionObservation.

+

DatabaseRegionObservation Usage

+ +

Define an observation by providing one or several requests to track:

+
// Track all players
+let observation = DatabaseRegionObservation(tracking: Player.all())
+
+ +

Then start the observation from a database queue or pool:

+
let observer = try observation.start(in: dbQueue) { (db: Database) in
+    print("Players were changed")
+}
+
+ +

And enjoy the changes notifications:

+
try dbQueue.write { db in
+    try Player(name: "Arthur").insert(db)
+}
+// Prints "Players were changed"
+
+ +

By default, the observation lasts until the observer returned by the start method is deinitialized. See DatabaseRegionObservation.extent for more details.

+ +

You can also feed DatabaseRegionObservation with DatabaseRegion, or any type which conforms to the DatabaseRegionConvertible protocol. For example:

+
// Observe the full database
+let observation = DatabaseRegionObservation(tracking: DatabaseRegion.fullDatabase)
+let observer = try observation.start(in: dbQueue) { (db: Database) in
+    print("Database was changed")
+}
+
+

DatabaseRegionObservation.extent

+ +

The extent property lets you specify the duration of the observation. See Observation Extent for more details:

+
// This observation lasts until the database connection is closed
+var observation = DatabaseRegionObservation...
+observation.extent = .databaseLifetime
+_ = try observation.start(in: dbQueue) { db in ... }
+
+ +

The default extent is .observerLifetime: the observation stops when the observer returned by start is deinitialized.

+ +

Regardless of the extent of an observation, you can always stop observation with the remove(transactionObserver:) method:

+
// Start
+let observer = try observation.start(in: dbQueue) { db in ... }
+
+// Stop
+dbQueue.remove(transactionObserver: observer)
+
+

TransactionObserver Protocol

+ +

The TransactionObserver protocol lets you observe individual database changes and transactions:

+
protocol TransactionObserver : class {
+    /// Notifies a database change:
+    /// - event.kind (insert, update, or delete)
+    /// - event.tableName
+    /// - event.rowID
+    ///
+    /// For performance reasons, the event is only valid for the duration of
+    /// this method call. If you need to keep it longer, store a copy:
+    /// event.copy().
+    func databaseDidChange(with event: DatabaseEvent)
+
+    /// Filters the database changes that should be notified to the
+    /// `databaseDidChange(with:)` method.
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool
+
+    /// An opportunity to rollback pending changes by throwing an error.
+    func databaseWillCommit() throws
+
+    /// Database changes have been committed.
+    func databaseDidCommit(_ db: Database)
+
+    /// Database changes have been rollbacked.
+    func databaseDidRollback(_ db: Database)
+}
+
+ + +

Activate a Transaction Observer

+ +

To activate a transaction observer, add it to the database queue or pool:

+
let observer = MyObserver()
+dbQueue.add(transactionObserver: observer)
+
+ +

By default, database holds weak references to its transaction observers: they are not retained, and stop getting notifications after they are deinitialized. See Observation Extent for more options.

+

Database Changes And Transactions

+ +

A transaction observer is notified of all database changes: inserts, updates and deletes. This includes indirect changes triggered by ON DELETE and ON UPDATE actions associated to foreign keys, and SQL triggers.

+ +
+

:point_up: Note: Some changes are not notified: changes to internal system tables (such as sqlite_master), changes to WITHOUT ROWID tables, and the deletion of duplicate rows triggered by ON CONFLICT REPLACE clauses (this last exception might change in a future release of SQLite).

+
+ +

Notified changes are not actually written to disk until the transaction commits, and the databaseDidCommit callback is called. On the other side, databaseDidRollback confirms their invalidation:

+
try dbQueue.write { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange
+    try db.execute(sql: "UPDATE ...") // 2. didChange
+}                                     // 3. willCommit, 4. didCommit
+
+try dbQueue.inTransaction { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange
+    try db.execute(sql: "UPDATE ...") // 2. didChange
+    return .rollback                  // 3. didRollback
+}
+
+try dbQueue.write { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange
+    throw SomeError()
+}                                     // 2. didRollback
+
+ +

Database statements that are executed outside of any transaction do not drop off the radar:

+
try dbQueue.inDatabase { db in
+    try db.execute(sql: "INSERT ...") // 1. didChange, 2. willCommit, 3. didCommit
+    try db.execute(sql: "UPDATE ...") // 4. didChange, 5. willCommit, 6. didCommit
+}
+
+ +

Changes that are on hold because of a savepoint are only notified after the savepoint has been released. This makes sure that notified events are only events that have an opportunity to be committed:

+
try dbQueue.inTransaction { db in
+    try db.execute(sql: "INSERT ...")            // 1. didChange
+
+    try db.execute(sql: "SAVEPOINT foo")
+    try db.execute(sql: "UPDATE ...")            // delayed
+    try db.execute(sql: "UPDATE ...")            // delayed
+    try db.execute(sql: "RELEASE SAVEPOINT foo") // 2. didChange, 3. didChange
+
+    try db.execute(sql: "SAVEPOINT foo")
+    try db.execute(sql: "UPDATE ...")            // not notified
+    try db.execute(sql: "ROLLBACK TO SAVEPOINT foo")
+
+    return .commit                               // 4. willCommit, 5. didCommit
+}
+
+ +

Eventual errors thrown from databaseWillCommit are exposed to the application code:

+
do {
+    try dbQueue.inTransaction { db in
+        ...
+        return .commit           // 1. willCommit (throws), 2. didRollback
+    }
+} catch {
+    // 3. The error thrown by the transaction observer.
+}
+
+ +
+

:point_up: Note: all callbacks are called in a protected dispatch queue, and serialized with all database updates.

+ +

:point_up: Note: the databaseDidChange(with:) and databaseWillCommit() callbacks must not touch the SQLite database. This limitation does not apply to databaseDidCommit and databaseDidRollback which can use their database argument.

+
+ +

DatabaseRegionObservation and ValueObservation are based on the TransactionObserver protocol.

+ +

See also TableChangeObserver.swift, which shows a transaction observer that notifies of modified database tables with NSNotificationCenter.

+

Filtering Database Events

+ +

Transaction observers can avoid being notified of database changes they are not interested in.

+ +

The filtering happens in the observes(eventsOfKind:) method, which tells whether the observer wants notification of specific kinds of changes, or not. For example, here is how an observer can focus on the changes that happen on the "player” database table:

+
class PlayerObserver: TransactionObserver {
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        // Only observe changes to the "player" table.
+        return eventKind.tableName == "player"
+    }
+
+    func databaseDidChange(with event: DatabaseEvent) {
+        // This method is only called for changes that happen to
+        // the "player" table.
+    }
+}
+
+ +

Generally speaking, the observes(eventsOfKind:) method can distinguish insertions from deletions and updates, and is also able to inspect the columns that are about to be changed:

+
class PlayerScoreObserver: TransactionObserver {
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        // Only observe changes to the "score" column of the "player" table.
+        switch eventKind {
+        case .insert(let tableName):
+            return tableName == "player"
+        case .delete(let tableName):
+            return tableName == "player"
+        case .update(let tableName, let columnNames):
+            return tableName == "player" && columnNames.contains("score")
+        }
+    }
+}
+
+ +

When the observes(eventsOfKind:) method returns false for all event kinds, the observer is still notified of commits and rollbacks:

+
class PureTransactionObserver: TransactionObserver {
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        // Ignore all individual changes
+        return false
+    }
+
+    func databaseDidChange(with event: DatabaseEvent) { /* Never called */ }
+    func databaseWillCommit() throws { /* Called before commit */ }
+    func databaseDidRollback(_ db: Database) { /* Called on rollback */ }
+    func databaseDidCommit(_ db: Database) { /* Called on commit */ }
+}
+
+ +

For more information about event filtering, see DatabaseRegion.

+

Observation Extent

+ +

You can specify how long an observer is notified of database changes and transactions.

+ +

The remove(transactionObserver:) method explicitly stops notifications, at any time:

+
// From a database queue or pool:
+dbQueue.remove(transactionObserver: observer)
+
+// From a database connection:
+dbQueue.inDatabase { db in
+    db.remove(transactionObserver: observer)
+}
+
+ +

Alternatively, use the extent parameter of the add(transactionObserver:extent:) method:

+
let observer = MyObserver()
+
+// On a database queue or pool:
+dbQueue.add(transactionObserver: observer) // default extent
+dbQueue.add(transactionObserver: observer, extent: .observerLifetime)
+dbQueue.add(transactionObserver: observer, extent: .nextTransaction)
+dbQueue.add(transactionObserver: observer, extent: .databaseLifetime)
+
+// On a database connection:
+dbQueue.inDatabase { db in
+    db.add(transactionObserver: ...)
+}
+
+ +
    +
  • The default extent is .observerLifetime: the database holds a weak reference to the observer, and the observation automatically ends when the observer is deinitialized. Meanwhile, observer is notified of all changes and transactions.

  • +
  • .nextTransaction activates the observer until the current or next transaction completes. The database keeps a strong reference to the observer until its databaseDidCommit or databaseDidRollback method is eventually called. Hereafter the observer won’t get any further notification.

  • +
  • .databaseLifetime has the database retain and notify the observer until the database connection is closed.

  • +
+ +

Finally, an observer may ignore all database changes until the end of the current transaction:

+
class PlayerObserver: TransactionObserver {
+    var playerTableWasModified = false
+
+    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool {
+        eventKind.tableName == "player"
+    }
+
+    func databaseDidChange(with event: DatabaseEvent) {
+        playerTableWasModified = true
+
+        // It is pointless to keep on tracking further changes:
+        stopObservingDatabaseChangesUntilNextTransaction()
+    }
+}
+
+ +

After stopObservingDatabaseChangesUntilNextTransaction(), the databaseDidChange(with:) method will not be notified of any change for the remaining duration of the current transaction. This helps GRDB optimize database observation.

+

DatabaseRegion

+ +

A DatabaseRegion is a reunion of database tables, and combination of columns and rows (identified by their rowid):

+
|Table1 |   |Table2 |   |Table3 |   |Table4 |   |Table5 |
+|-------|   |-------|   |-------|   |-------|   |-------|
+|x|x|x|x|   |x| | | |   |x|x|x|x|   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | |x| | |
+|x|x|x|x|   |x| | | |   | | | | |   |x|x| |x|   | | | | |
+|x|x|x|x|   |x| | | |   | | | | |   | | | | |   | | | | |
+
+ +

DatabaseRegion helps ValueObservation and DatabaseRegionObservation track changes in the database through the TransactionObserver protocol.

+ +

Note that observing a database region spots potential changes, not actual changes in the results of a request. A change is notified if and only if a statement has actually modified the tracked tables and columns by inserting, updating, or deleting a row.

+ +

For example, if you observe the region of Player.select(max(Column("score"))), then you’ll get be notified of all changes performed on the score column of the player table (updates, insertions and deletions), even if they do not modify the value of the maximum score. However, you will not get any notification for changes performed on other database tables, or updates to other columns of the player table.

+ +

For more details, see the reference.

+

The DatabaseRegionConvertible Protocol

+ +

DatabaseRegionConvertible is a protocol for all types that can turn into a DatabaseRegion:

+
protocol DatabaseRegionConvertible {
+    func databaseRegion(_ db: Database) throws -> DatabaseRegion
+}
+
+ +

All requests adopt this protocol, and this allows them to be observed with DatabaseRegionObservation and ValueObservation.

+ +

For example:

+
// 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"))
+
+ +

Note that specifying a region as a request does not run the request. In the above example, Player.filter(id: 1) and SELECT score FROM player are never executed. They are only compiled by SQLite, so that GRDB understands the tables, rows, and columns that constitute the database region.

+

Support for SQLite Pre-Update Hooks

+ +

When SQLite is built with the SQLITE_ENABLE_PREUPDATE_HOOK option, TransactionObserverType gets an extra callback which lets you observe individual column values in the rows modified by a transaction:

+
protocol TransactionObserverType : class {
+    #if SQLITE_ENABLE_PREUPDATE_HOOK
+    /// Notifies before a database change (insert, update, or delete)
+    /// with change information (initial / final values for the row's
+    /// columns).
+    ///
+    /// The event is only valid for the duration of this method call. If you
+    /// need to keep it longer, store a copy: event.copy().
+    func databaseWillChange(with event: DatabasePreUpdateEvent)
+    #endif
+}
+
+ +

This extra API can be activated in two ways:

+ +
    +
  1. Use the GRDB.swift CocoaPod with a custom compilation option, as below. It uses the system SQLite, which is compiled with SQLITE_ENABLE_PREUPDATE_HOOK support, but only on iOS 11.0+ (we don’t know the minimum version of macOS, tvOS, watchOS):

    +
    pod 'GRDB.swift'
    +platform :ios, '11.0' # or above
    +
    +post_install do |installer|
    +  installer.pods_project.targets.select { |target| target.name == "GRDB.swift" }.each do |target|
    +    target.build_configurations.each do |config|
    +      # Enable extra GRDB APIs
    +      config.build_settings['OTHER_SWIFT_FLAGS'] = "$(inherited) -D SQLITE_ENABLE_PREUPDATE_HOOK"
    +      # Enable extra SQLite APIs
    +      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = "$(inherited) GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1"
    +    end
    +  end
    +end
    +
    + +
    +

    :warning: Warning: make sure you use the right platform version! You will get runtime errors on devices with a lower version.

    + +

    :point_up: Note: the GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1 option in GCC_PREPROCESSOR_DEFINITIONS defines some C function prototypes that are lacking from the system <sqlite3.h> header. When Xcode eventually ships with an SDK that includes a complete header, you may get a compiler error about duplicate function definitions. When this happens, just remove this GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1 option.

    +
  2. +
  3. Use a custom SQLite build and activate the SQLITE_ENABLE_PREUPDATE_HOOK compilation option.

  4. +
+

Encryption

+ +

GRDB can encrypt your database with SQLCipher v3.4+.

+ +

Use CocoaPods, and specify in your Podfile:

+
# GRDB with SQLCipher 4
+pod 'GRDB.swift/SQLCipher'
+pod 'SQLCipher', '~> 4.0'
+
+# GRDB with SQLCipher 3
+pod 'GRDB.swift/SQLCipher'
+pod 'SQLCipher', '~> 3.4'
+
+ + +

Creating or Opening an Encrypted Database

+ +

You create and open an encrypted database by providing a passphrase to your database connection:

+
var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

It is also in prepareDatabase that you perform other SQLCipher configuration steps that must happen early in the lifetime of a SQLCipher connection. For example:

+
var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+    try db.execute(sql: "PRAGMA cipher_page_size = ...")
+    try db.execute(sql: "PRAGMA kdf_iter = ...")
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

When you want to open an existing SQLCipher 3 database with SQLCipher 4, you may want to run the cipher_compatibility pragma:

+
// Open an SQLCipher 3 database with SQLCipher 4
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+    try db.execute(sql: "PRAGMA cipher_compatibility = 3")
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

See SQLCipher 4.0.0 Release and Upgrading to SQLCipher 4 for more information.

+

Changing the Passphrase of an Encrypted Database

+ +

You can change the passphrase of an already encrypted database.

+ +

When you use a database queue, open the database with the old passphrase, and then apply the new passphrase:

+
try dbQueue.write { db in
+    try db.changePassphrase("newSecret")
+}
+
+ +

When you use a database pool, make sure that no concurrent read can happen by changing the passphrase within the barrierWriteWithoutTransaction block. You must also ensure all future reads open a new database connection by calling the invalidateReadOnlyConnections method:

+
try dbPool.barrierWriteWithoutTransaction { db in
+    try db.changePassphrase("newSecret")
+    dbPool.invalidateReadOnlyConnections()
+}
+
+ +
+

:point_up: Note: When an application wants to keep on using a database queue or pool after the passphrase has changed, it is responsible for providing the correct passphrase to the usePassphrase method called in the database preparation function. Consider:

+
// WRONG: this won't work across a passphrase change
+let passphrase = try getPassphrase()
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase(passphrase)
+}
+
+// CORRECT: get the latest passphrase when it is needed
+var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try getPassphrase()
+    try db.usePassphrase(passphrase)
+}
+
+ +

:point_up: Note: The DatabasePool.barrierWriteWithoutTransaction method does not prevent database snapshots from accessing the database during the passphrase change, or after the new passphrase has been applied to the database. Those database accesses may throw errors. Applications should provide their own mechanism for invalidating open snapshots before the passphrase is changed.

+ +

:point_up: Note: Instead of changing the passphrase “in place” as described here, you can also export the database in a new encrypted database that uses the new passphrase. See Exporting a Database to an Encrypted Database.

+
+

Exporting a Database to an Encrypted Database

+ +

Providing a passphrase won’t encrypt a clear-text database that already exists, though. SQLCipher can’t do that, and you will get an error instead: SQLite error 26: file is encrypted or is not a database.

+ +

Instead, create a new encrypted database, at a distinct location, and export the content of the existing database. This can both encrypt a clear-text database, or change the passphrase of an encrypted database.

+ +

The technique to do that is documented by SQLCipher.

+ +

With GRDB, it gives:

+
// The existing database
+let existingDBQueue = try DatabaseQueue(path: "/path/to/existing.db")
+
+// The new encrypted database, at some distinct location:
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase("secret")
+}
+let newDBQueue = try DatabaseQueue(path: "/path/to/new.db", configuration: config)
+
+try existingDBQueue.inDatabase { db in
+    try db.execute(
+        sql: """
+            ATTACH DATABASE ? AS encrypted KEY ?;
+            SELECT sqlcipher_export('encrypted');
+            DETACH DATABASE encrypted;
+            """,
+        arguments: [newDBQueue.path, "secret"])
+}
+
+// Now the export is completed, and the existing database can be deleted.
+
+

Security Considerations

+

Managing the lifetime of the passphrase string

+ +

It is recommended to avoid keeping the passphrase in memory longer than necessary. To do this, make sure you load the passphrase from the prepareDatabase method:

+
// NOT RECOMMENDED: this keeps the passphrase in memory longer than necessary
+let passphrase = try getPassphrase()
+var config = Configuration()
+config.prepareDatabase { db in
+    try db.usePassphrase(passphrase)
+}
+
+// RECOMMENDED: only load the passphrase when it is needed
+var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try getPassphrase()
+    try db.usePassphrase(passphrase)
+}
+
+ +

This technique helps manages the lifetime of the passphrase, although keep in mind that the content of a String may remain intact in memory long after the object has been released.

+ +

For even better control over the lifetime of the passphrase in memory, use a Data object which natively provides the resetBytes function.

+
// RECOMMENDED: only load the passphrase when it is needed and reset its content immediately after use
+var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try getPassphraseData() // Data
+    defer {
+        passphrase.resetBytes(in: 0..<data.count)
+    }
+    try db.usePassphrase(passphrase)
+}
+
+ +

Some demanding users will want to go further, and manage the lifetime of the raw passphrase bytes. See below.

+

Managing the lifetime of the passphrase bytes

+ +

GRDB offers convenience methods for providing the database passphrases as Swift strings: usePassphrase(_:) and changePassphrase(_:). Those methods don’t keep the passphrase String in memory longer than necessary. But they are as secure as the standard String type: the lifetime of actual passphrase bytes in memory is not under control.

+ +

When you want to precisely manage the passphrase bytes, talk directly to SQLCipher, using its raw C functions.

+ +

For example:

+
var config = Configuration()
+config.prepareDatabase { db in
+    ... // Carefully load passphrase bytes
+    let code = sqlite3_key(db.sqliteConnection, /* passphrase bytes */)
+    ... // Carefully dispose passphrase bytes
+    guard code == SQLITE_OK else {
+        throw DatabaseError(
+            resultCode: ResultCode(rawValue: code), 
+            message: db.lastErrorMessage)
+    }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+

Passphrase availability vs. Database availability

+ +

When the passphrase is securely stored in the system keychain, your application can protect it using the kSecAttrAccessible attribute.

+ +

Such protection prevents GRDB from creating SQLite connections when the passphrase is not available:

+
var config = Configuration()
+config.prepareDatabase { db in
+    let passphrase = try loadPassphraseFromSystemKeychain()
+    try db.usePassphrase(passphrase)
+}
+
+// Success if and only if the passphrase is available
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

For the same reason, database pools, which open SQLite connections on demand, may fail at any time as soon as the passphrase becomes unavailable:

+
// Success if and only if the passphrase is available
+let dbPool = try DatabasePool(path: dbPath, configuration: config)
+
+// May fail if passphrase has turned unavailable
+try dbPool.read { ... }
+
+// May trigger value observation failure if passphrase has turned unavailable
+try dbPool.write { ... }
+
+ +

Because DatabasePool maintains a pool of long-lived SQLite connections, some database accesses will use an existing connection, and succeed. And some other database accesses will fail, as soon as the pool wants to open a new connection. It is impossible to predict which accesses will succeed or fail.

+ +

For the same reason, a database queue, which also maintains a long-lived SQLite connection, will remain available even after the passphrase has turned unavailable.

+ +

Applications are thus responsible for protecting database accesses when the passphrase is unavailable. To this end, they can use Data Protection. They can also destroy their instances of database queue or pool when the passphrase becomes unavailable.

+

Backup

+ +

You can backup (copy) a database into another.

+ +

Backups can for example help you copying an in-memory database to and from a database file when you implement NSDocument subclasses.

+
let source: DatabaseQueue = ...      // or DatabasePool
+let destination: DatabaseQueue = ... // or DatabasePool
+try source.backup(to: destination)
+
+ +

The backup method blocks the current thread until the destination database contains the same contents as the source database.

+ +

When the source is a database pool, concurrent writes can happen during the backup. Those writes may, or may not, be reflected in the backup, but they won’t trigger any error.

+

Interrupt a Database

+ +

The interrupt() method causes any pending database operation to abort and return at its earliest opportunity.

+ +

It can be called from any thread.

+
dbQueue.interrupt()
+dbPool.interrupt()
+
+ +

A call to interrupt() that occurs when there are no running SQL statements is a no-op and has no effect on SQL statements that are started after interrupt() returns.

+ +

A database operation that is interrupted will throw a DatabaseError with code SQLITE_INTERRUPT. If the interrupted SQL operation is an INSERT, UPDATE, or DELETE that is inside an explicit transaction, then the entire transaction will be rolled back automatically. If the rolled back transaction was started by a transaction-wrapping method such as DatabaseWriter.write or Database.inTransaction, then all database accesses will throw a DatabaseError with code SQLITE_ABORT until the wrapping method returns.

+ +

For example:

+
try dbQueue.write { db in
+    try Player(...).insert(db)     // throws SQLITE_INTERRUPT
+    try Player(...).insert(db)     // not executed
+}                                  // throws SQLITE_INTERRUPT
+
+try dbQueue.write { db in
+    do {
+        try Player(...).insert(db) // throws SQLITE_INTERRUPT
+    } catch { }
+}                                  // throws SQLITE_ABORT
+
+try dbQueue.write { db in
+    do {
+        try Player(...).insert(db) // throws SQLITE_INTERRUPT
+    } catch { }
+    try Player(...).insert(db)     // throws SQLITE_ABORT
+}                                  // throws SQLITE_ABORT
+
+ +

You can catch both SQLITE_INTERRUPT and SQLITE_ABORT errors:

+
do {
+    try dbPool.write { db in ... }
+} catch DatabaseError.SQLITE_INTERRUPT, DatabaseError.SQLITE_ABORT {
+    // Oops, the database was interrupted.
+}
+
+ +

For more information, see Interrupt A Long-Running Query.

+

Avoiding SQL Injection

+ +

SQL injection is a technique that lets an attacker nuke your database.

+ +
+

XKCD: Exploits of a Mom

+ +

https://xkcd.com/327/

+
+ +

Here is an example of code that is vulnerable to SQL injection:

+
// BAD BAD BAD
+let id = 1
+let name = textField.text
+try dbQueue.write { db in
+    try db.execute(sql: "UPDATE students SET name = '\(name)' WHERE id = \(id)")
+}
+
+ +

If the user enters a funny string like Robert'; DROP TABLE students; --, SQLite will see the following SQL, and drop your database table instead of updating a name as intended:

+
UPDATE students SET name = 'Robert';
+DROP TABLE students;
+--' WHERE id = 1
+
+ +

To avoid those problems, never embed raw values in your SQL queries. The only correct technique is to provide arguments to your raw SQL queries:

+
let name = textField.text
+try dbQueue.write { db in
+    // Good
+    try db.execute(
+        sql: "UPDATE students SET name = ? WHERE id = ?",
+        arguments: [name, id])
+
+    // Just as good
+    try db.execute(
+        sql: "UPDATE students SET name = :name WHERE id = :id",
+        arguments: ["name": name, "id": id])
+}
+
+ +

When you use records and the query interface, GRDB always prevents SQL injection for you:

+
let id = 1
+let name = textField.text
+try dbQueue.write { db in
+    if var student = try Student.fetchOne(db, id: id) {
+        student.name = name
+        try student.update(db)
+    }
+}
+
+

Error Handling

+ +

GRDB can throw DatabaseError, PersistenceError, or crash your program with a fatal error.

+ +

Considering that a local database is not some JSON loaded from a remote server, GRDB focuses on trusted databases. Dealing with untrusted databases requires extra care.

+ + +

DatabaseError

+ +

DatabaseError are thrown on SQLite errors:

+
do {
+    try Pet(masterId: 1, name: "Bobby").insert(db)
+} catch let error as DatabaseError {
+    // The SQLite error code: 19 (SQLITE_CONSTRAINT)
+    error.resultCode
+
+    // The extended error code: 787 (SQLITE_CONSTRAINT_FOREIGNKEY)
+    error.extendedResultCode
+
+    // The eventual SQLite message: FOREIGN KEY constraint failed
+    error.message
+
+    // The eventual erroneous SQL query
+    // "INSERT INTO pet (masterId, name) VALUES (?, ?)"
+    error.sql
+
+    // The eventual SQL arguments
+    // [1, "Bobby"]
+    error.arguments
+
+    // Full error description:
+    // "SQLite error 19 with statement `INSERT INTO pet (masterId, name)
+    //  VALUES (?, ?)` arguments [1, "Bobby"]: FOREIGN KEY constraint failed""
+    error.description
+}
+
+ +

SQLite uses results codes to distinguish between various errors.

+ +

You can catch a DatabaseError and match on result codes:

+
do {
+    try ...
+} catch let error as DatabaseError {
+    switch error {
+    case DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY:
+        // foreign key constraint error
+    case DatabaseError.SQLITE_CONSTRAINT:
+        // any other constraint error
+    default:
+        // any other database error
+    }
+}
+
+ +

You can also directly match errors on result codes:

+
do {
+    try ...
+} catch DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY {
+    // foreign key constraint error
+} catch DatabaseError.SQLITE_CONSTRAINT {
+    // any other constraint error
+} catch {
+    // any other database error
+}
+
+ +

Each DatabaseError has two codes: an extendedResultCode (see extended result code), and a less precise resultCode (see primary result code). Extended result codes are refinements of primary result codes, as SQLITE_CONSTRAINT_FOREIGNKEY is to SQLITE_CONSTRAINT, for example.

+ +
+

:warning: Warning: SQLite has progressively introduced extended result codes across its versions. The SQLite release notes are unfortunately not quite clear about that: write your handling of extended result codes with care.

+
+

PersistenceError

+ +

PersistenceError is thrown by the PersistableRecord protocol, in a single case: when the update method could not find any row to update:

+
do {
+    try player.update(db)
+} catch let PersistenceError.recordNotFound(databaseTableName: table, key: key) {
+    print("Key \(key) was not found in table \(table).")
+}
+
+

Fatal Errors

+ +

Fatal errors notify that the program, or the database, has to be changed.

+ +

They uncover programmer errors, false assumptions, and prevent misuses. Here are a few examples:

+ +
    +
  • The code asks for a non-optional value, when the database contains NULL:

    +
    // fatal error: could not convert NULL to String.
    +let name: String = row["name"]
    +
    + +

    Solution: fix the contents of the database, use NOT NULL constraints, or load an optional:

    +
    let name: String? = row["name"]
    +
  • +
  • Conversion from database value to Swift type fails:

    +
    // fatal error: could not convert "Mom’s birthday" to Date.
    +let date: Date = row["date"]
    +
    +// fatal error: could not convert "" to URL.
    +let url: URL = row["url"]
    +
    + +

    Solution: fix the contents of the database, or use DatabaseValue to handle all possible cases:

    +
    let dbValue: DatabaseValue = row["date"]
    +if dbValue.isNull {
    +    // Handle NULL
    +} else if let date = Date.fromDatabaseValue(dbValue) {
    +    // Handle valid date
    +} else {
    +    // Handle invalid date
    +}
    +
  • +
  • The database can’t guarantee that the code does what it says:

    +
    // fatal error: table player has no unique index on column email
    +try Player.deleteOne(db, key: ["email": "arthur@example.com"])
    +
    + +

    Solution: add a unique index to the player.email column, or use the deleteAll method to make it clear that you may delete more than one row:

    +
    try Player.filter(Column("email") == "arthur@example.com").deleteAll(db)
    +
  • +
  • Database connections are not reentrant:

    +
    // fatal error: Database methods are not reentrant.
    +dbQueue.write { db in
    +    dbQueue.write { db in
    +        ...
    +    }
    +}
    +
    + +

    Solution: avoid reentrancy, and instead pass a database connection along.

  • +
+

How to Deal with Untrusted Inputs

+ +

Let’s consider the code below:

+
let sql = "SELECT ..."
+
+// Some untrusted arguments for the query
+let arguments: [String: Any] = ...
+let rows = try Row.fetchCursor(db, sql: sql, arguments: StatementArguments(arguments))
+
+while let row = try rows.next() {
+    // Some untrusted database value:
+    let date: Date? = row[0]
+}
+
+ +

It has two opportunities to throw fatal errors:

+ +
    +
  • Untrusted arguments: The dictionary may contain values that do not conform to the DatabaseValueConvertible protocol, or may miss keys required by the statement.
  • +
  • Untrusted database content: The row may contain a non-null value that can’t be turned into a date.
  • +
+ +

In such a situation, you can still avoid fatal errors by exposing and handling each failure point, one level down in the GRDB API:

+
// Untrusted arguments
+if let arguments = StatementArguments(arguments) {
+    let statement = try db.makeStatement(sql: sql)
+    try statement.setArguments(arguments)
+
+    var cursor = try Row.fetchCursor(statement)
+    while let row = try iterator.next() {
+        // Untrusted database content
+        let dbValue: DatabaseValue = row[0]
+        if dbValue.isNull {
+            // Handle NULL
+        if let date = Date.fromDatabaseValue(dbValue) {
+            // Handle valid date
+        } else {
+            // Handle invalid date
+        }
+    }
+}
+
+ +

See prepared statements and DatabaseValue for more information.

+

Error Log

+ +

SQLite can be configured to invoke a callback function containing an error code and a terse error message whenever anomalies occur.

+ +

This global error callback must be configured early in the lifetime of your application:

+
Database.logError = { (resultCode, message) in
+    NSLog("%@", "SQLite error \(resultCode): \(message)")
+}
+
+ +
+

:warning: Warning: Database.logError must be set before any database connection is opened. This includes the connections that your application opens with GRDB, but also connections opened by other tools, such as third-party libraries. Setting it after a connection has been opened is an SQLite misuse, and has no effect.

+
+ +

See The Error And Warning Log for more information.

+

Unicode

+ +

SQLite lets you store unicode strings in the database.

+ +

However, SQLite does not provide any unicode-aware string transformations or comparisons.

+

Unicode functions

+ +

The UPPER and LOWER built-in SQLite functions are not unicode-aware:

+
// "JéRôME"
+try String.fetchOne(db, sql: "SELECT UPPER('Jérôme')")
+
+ +

GRDB extends SQLite with SQL functions that call the Swift built-in string functions capitalized, lowercased, uppercased, localizedCapitalized, localizedLowercased and localizedUppercased:

+
// "JÉRÔME"
+let uppercased = DatabaseFunction.uppercase
+try String.fetchOne(db, sql: "SELECT \(uppercased.name)('Jérôme')")
+
+ +

Those unicode-aware string functions are also readily available in the query interface:

+
Player.select(nameColumn.uppercased)
+
+

String Comparison

+ +

SQLite compares strings in many occasions: when you sort rows according to a string column, or when you use a comparison operator such as = and <=.

+ +

The comparison result comes from a collating function, or collation. SQLite comes with three built-in collations that do not support Unicode: binary, nocase, and rtrim.

+ +

GRDB comes with five extra collations that leverage unicode-aware comparisons based on the standard Swift String comparison functions and operators:

+ +
    +
  • unicodeCompare (uses the built-in <= and == Swift operators)
  • +
  • caseInsensitiveCompare
  • +
  • localizedCaseInsensitiveCompare
  • +
  • localizedCompare
  • +
  • localizedStandardCompare
  • +
+ +

A collation can be applied to a table column. All comparisons involving this column will then automatically trigger the comparison function:

+
try db.create(table: "player") { t in
+    // Guarantees case-insensitive email unicity
+    t.column("email", .text).unique().collate(.nocase)
+
+    // Sort names in a localized case insensitive way
+    t.column("name", .text).collate(.localizedCaseInsensitiveCompare)
+}
+
+// Players are sorted in a localized case insensitive way:
+let players = try Player.order(nameColumn).fetchAll(db)
+
+ +
+

:warning: Warning: SQLite requires host applications to provide the definition of any collation other than binary, nocase and rtrim. When a database file has to be shared or migrated to another SQLite library of platform (such as the Android version of your application), make sure you provide a compatible collation.

+
+ +

If you can’t or don’t want to define the comparison behavior of a column (see warning above), you can still use an explicit collation in SQL requests and in the query interface:

+
let collation = DatabaseCollation.localizedCaseInsensitiveCompare
+let players = try Player.fetchAll(db,
+    sql: "SELECT * FROM player ORDER BY name COLLATE \(collation.name))")
+let players = try Player.order(nameColumn.collating(collation)).fetchAll(db)
+
+ +

You can also define your own collations:

+
let collation = DatabaseCollation("customCollation") { (lhs, rhs) -> NSComparisonResult in
+    // return the comparison of lhs and rhs strings.
+}
+
+// Make the collation available to a database connection
+var config = Configuration()
+config.prepareDatabase { db in
+    db.add(collation: collation)
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+

Memory Management

+ +

Both SQLite and GRDB use non-essential memory that help them perform better.

+ +

You can reclaim this memory with the releaseMemory method:

+
// Release as much memory as possible.
+dbQueue.releaseMemory()
+dbPool.releaseMemory()
+
+ +

This method blocks the current thread until all current database accesses are completed, and the memory collected.

+

Memory Management on iOS

+ +

The iOS operating system likes applications that do not consume much memory.

+ +

Database queues and pools automatically call the releaseMemory method when the application receives a memory warning, and when the application enters background.

+

Data Protection

+ +

Data Protection lets you protect files so that they are encrypted and unavailable until the device is unlocked.

+ +

Data protection can be enabled globally for all files created by an application.

+ +

You can also explicitly protect a database, by configuring its enclosing directory. This will not only protect the database file, but also all temporary files created by SQLite (including the persistent .shm and .wal files created by database pools).

+ +

For example, to explicitly use complete protection:

+
// Paths
+let fileManager = FileManager.default
+let directoryURL = try fileManager
+    .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+    .appendingPathComponent("database", isDirectory: true)
+let databaseURL = directoryURL.appendingPathComponent("db.sqlite")
+
+// Create directory if needed
+var isDirectory: ObjCBool = false
+if !fileManager.fileExists(atPath: directoryURL.path, isDirectory: &isDirectory) {
+    try fileManager.createDirectory(atPath: directoryURL.path, withIntermediateDirectories: false)
+} else if !isDirectory.boolValue {
+    throw NSError(domain: NSCocoaErrorDomain, code: NSFileWriteFileExistsError, userInfo: nil)
+}
+
+// Enable data protection
+try fileManager.setAttributes([.protectionKey : FileProtectionType.complete], ofItemAtPath: directoryURL.path)
+
+// Open database
+let dbQueue = try DatabaseQueue(path: databaseURL.path)
+
+ +

When a database is protected, an application that runs in the background on a locked device won’t be able to read or write from it. Instead, it will get DatabaseError with code SQLITE_IOERR (10) “disk I/O error”, or SQLITE_AUTH (23) “not authorized”.

+ +

You can catch those errors and wait for UIApplicationDelegate.applicationProtectedDataDidBecomeAvailable(_:) or UIApplicationProtectedDataDidBecomeAvailable notification in order to retry the failed database operation.

+

FAQ

+ +

FAQ: Opening Connections

+ + + +

FAQ: SQL

+ + + +

FAQ: General

+ + + +

FAQ: Associations

+ + + +

FAQ: ValueObservation

+ + + +

FAQ: Errors

+ + +

FAQ: Opening Connections

+ + +

How do I create a database in my application?

+ +

This question assumes that your application has to create a new database from scratch. If your app has to open an existing database that is embedded inside your application as a resource, see How do I open a database stored as a resource of my application? instead.

+ +

The database has to be stored in a valid place where it can be created and modified. For example, in the Application Support directory:

+
let databaseURL = try FileManager.default
+    .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+    .appendingPathComponent("db.sqlite")
+let dbQueue = try DatabaseQueue(path: databaseURL.path)
+
+

How do I open a database stored as a resource of my application?

+ +

If your application does not need to modify the database, open a read-only connection to your resource:

+
var config = Configuration()
+config.readonly = true
+let dbPath = Bundle.main.path(forResource: "db", ofType: "sqlite")!
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

If the application should modify the database, you need to copy it to a place where it can be modified. For example, in the Application Support directory. Only then, open a connection:

+
let fileManager = FileManager.default
+let dbPath = try fileManager
+    .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+    .appendingPathComponent("db.sqlite")
+    .path
+if !fileManager.fileExists(atPath: dbPath) {
+    let dbResourcePath = Bundle.main.path(forResource: "db", ofType: "sqlite")!
+    try fileManager.copyItem(atPath: dbResourcePath, toPath: dbPath)
+}
+let dbQueue = try DatabaseQueue(path: dbPath)
+
+

How do I close a database connection?

+ +

Database connections are automatically closed when they are deinitialized.

+ +

When the correct execution of your program depends on precise database closing, use the close() method:

+
try dbQueue.close()
+
+ +

This explicit close() may fail with an error. See the inline documentation of this method for more information. Generally speaking, you should not call this method: rely on automatic closing instead.

+

FAQ: SQL

+ + +

How do I print a request as SQL?

+ +

When you want to debug a request that does not deliver the expected results, you may want to print the SQL that is actually executed.

+ +

You can compile the request into a prepared statement:

+
try dbQueue.read { db in
+    let request = Player.filter(Column("name") == "O'Brien")
+    let statement = try request.makePreparedRequest(db).statement
+    print(statement) // SQL: SELECT * FROM player WHERE name = ?, Arguments: ["O'Brien"]
+}
+
+ +

Another option is to setup a tracing function that prints out the executed SQL requests. For example, provide a tracing function when you connect to the database:

+
// Prints all SQL statements
+var config = Configuration()
+config.prepareDatabase { db in
+    db.trace { print($0) }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    let players = try Player.filter(Column("name") == "O'Brien").fetchAll(db)
+    // Prints SELECT * FROM player WHERE name = 'O''Brien'
+}
+
+ +

If you want to hide values such as 'O''Brien' from the logged statements, adapt the tracing function as below:

+
db.trace { event in
+    if case let .statement(statement) = event {
+        // Prints SELECT * FROM player WHERE name = ?
+        print(statement.sql)
+    }
+}
+
+ +
+

:point_up: Note: the generated SQL may change between GRDB releases, without notice: don’t have your application rely on any specific SQL output.

+
+

FAQ: General

+ + +

How do I monitor the duration of database statements execution?

+ +

Use the trace(options:_:) method, with the .profile option:

+
var config = Configuration()
+config.prepareDatabase { db in
+    db.trace(options: .profile) { event in
+        // Prints all SQL statements with their duration
+        print(event)
+
+        // Access to detailed profiling information
+        if case let .profile(statement, duration) = event, duration > 0.5 {
+            print("Slow query: \(statement.sql)")
+        }
+    }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+try dbQueue.read { db in
+    let players = try Player.filter(Column("name") == "O'Brien").fetchAll(db)
+    // Prints "0.003s SELECT * FROM player WHERE name = 'O''Brien'"
+}
+
+

What Are Experimental Features?

+ +

Since GRDB 1.0, all backwards compatibility guarantees of semantic versioning apply: no breaking change will happen until the next major version of the library.

+ +

There is an exception, though: experimental features, marked with the “:fire: EXPERIMENTAL” badge. Those are advanced features that are too young, or lack user feedback. They are not stabilized yet.

+ +

Those experimental features are not protected by semantic versioning, and may break between two minor releases of the library. To help them becoming stable, your feedback is greatly appreciated.

+

Does GRDB support library evolution and ABI stability?

+ +

No, GRDB does not support library evolution and ABI stability. The only promise is API stability according to semantic versioning, with an exception for experimental features.

+ +

Yet, GRDB can be built with the “Build Libraries for Distribution” Xcode option (BUILD_LIBRARY_FOR_DISTRIBUTION), so that you can build binary frameworks at your convenience.

+

FAQ: Associations

+ + +

How do I filter records and only keep those that are associated to another record?

+ +

Let’s say you have two record types, Book and Author, and you want to only fetch books that have an author, and discard anonymous books.

+ +

We start by defining the association between books and authors:

+
struct Book: TableRecord {
+    ...
+    static let author = belongsTo(Author.self)
+}
+
+struct Author: TableRecord {
+    ...
+}
+
+ +

And then we can write our request and only fetch books that have an author, discarding anonymous ones:

+
let books: [Book] = try dbQueue.read { db in
+    // SELECT book.* FROM book 
+    // JOIN author ON author.id = book.authorID
+    let request = Book.joining(required: Book.author)
+    return try request.fetchAll(db)
+}
+
+ +

Note how this request does not use the filter method. Indeed, we don’t have any condition to express on any column. Instead, we just need to “require that a book can be joined to its author”.

+ +

See How do I filter records and only keep those that are NOT associated to another record? below for the opposite question.

+

How do I filter records and only keep those that are NOT associated to another record?

+ +

Let’s say you have two record types, Book and Author, and you want to only fetch anonymous books that do not have any author.

+ +

We start by defining the association between books and authors:

+
struct Book: TableRecord {
+    ...
+    static let author = belongsTo(Author.self)
+}
+
+struct Author: TableRecord {
+    ...
+}
+
+ +

And then we can write our request and only fetch anonymous books that don’t have any author:

+
let books: [Book] = try dbQueue.read { db in
+    // SELECT book.* FROM book
+    // LEFT JOIN author ON author.id = book.authorID
+    // WHERE author.id IS NULL
+    let authorAlias = TableAlias()
+    let request = Book
+        .joining(optional: Book.author.aliased(authorAlias))
+        .filter(!authorAlias.exists)
+    return try request.fetchAll(db)
+}
+
+ +

This request uses a TableAlias in order to be able to filter on the eventual associated author. We make sure that the Author.primaryKey is nil, which is another way to say it does not exist: the book has no author.

+ +

See How do I filter records and only keep those that are associated to another record? above for the opposite question.

+

How do I select only one column of an associated record?

+ +

Let’s say you have two record types, Book and Author, and you want to fetch all books with their author name, but not the full associated author records.

+ +

We start by defining the association between books and authors:

+
struct Book: Decodable, TableRecord {
+    ...
+    static let author = belongsTo(Author.self)
+}
+
+struct Author: Decodable, TableRecord {
+    ...
+    enum Columns {
+        static let name = Column(CodingKeys.name)
+    }
+}
+
+ +

And then we can write our request and the ad-hoc record that decodes it:

+
struct BookInfo: Decodable, FetchableRecord {
+    var book: Book
+    var authorName: String? // nil when the book is anonymous
+
+    static func all() -> QueryInterfaceRequest<BookInfo> {
+        // SELECT book.*, author.name AS authorName
+        // FROM book
+        // LEFT JOIN author ON author.id = book.authorID
+        let authorName = Author.Columns.name.forKey(CodingKeys.authorName)
+        return Book
+            .annotated(withOptional: Book.author.select(authorName))
+            .asRequest(of: BookInfo.self)
+    }
+}
+
+let bookInfos: [BookInfo] = try dbQueue.read { db in
+    BookInfo.all().fetchAll(db)
+}
+
+ +

By defining the request as a static method of BookInfo, you have access to the private CodingKeys.authorName, and a compiler-checked SQL column name.

+ +

By using the annotated(withOptional:) method, you append the author name to the top-level selection that can be decoded by the ad-hoc record.

+ +

By using asRequest(of:), you enhance the type-safety of your request.

+

FAQ: ValueObservation

+ + +

Why is ValueObservation not publishing value changes?

+ +

Sometimes it looks that a ValueObservation does not notify the changes you expect.

+ +

There may be four possible reasons for this:

+ +
    +
  1. The expected changes were not committed into the database.
  2. +
  3. The expected changes were committed into the database, but were quickly overwritten.
  4. +
  5. The observation was stopped.
  6. +
  7. The observation does not track the expected database region.
  8. +
+ +

To answer the first two questions, look at SQL statements executed by the database. This is done when you open the database connection:

+
// Prints all SQL statements
+var config = Configuration()
+config.prepareDatabase { db in
+    db.trace { print("SQL: \($0)") }
+}
+let dbQueue = try DatabaseQueue(path: dbPath, configuration: config)
+
+ +

If, after that, you are convinced that the expected changes were committed into the database, and not overwritten soon after, trace observation events:

+
let observation = ValueObservation
+    .tracking { db in ... }
+    .print() // <- trace observation events
+let cancellable = observation.start(...)
+
+ +

Look at the observation logs which start with cancel or failure: maybe the observation was cancelled by your app, or did fail with an error.

+ +

Look at the observation logs which start with value: make sure, again, that the expected value was not actually notified, then overwritten.

+ +

Finally, look at the observation logs which start with tracked region. Does the printed database region cover the expected changes?

+ +

For example:

+ +
    +
  • empty: The empty region, which tracks nothing and never triggers the observation.
  • +
  • player(*): The full player table
  • +
  • player(id,name): The id and name columns of the player table
  • +
  • player(id,name)[1]: The id and name columns of the row with id 1 in the player table
  • +
  • player(*),team(*): Both the full player and team tables
  • +
+ +

If you happen to use the ValueObservation.trackingConstantRegion(_:) method and see a mismatch between the tracked region and your expectation, then change the definition of your observation by using tracking(_:). You should witness that the logs which start with tracked region now evolve in order to include the expected changes, and that you get the expected notifications.

+ +

If after all those steps (thanks you!), your observation is still failing you, please open an issue and provide a minimal reproducible example!

+

FAQ: Errors

+ + +

Generic parameter ‘T’ could not be inferred

+ +

You may get this error when using the read and write methods of database queues and pools:

+
// Generic parameter 'T' could not be inferred
+let string = try dbQueue.read { db in
+    let result = try String.fetchOne(db, ...)
+    return result
+}
+
+ +

This is a limitation of the Swift compiler.

+ +

The general workaround is to explicitly declare the type of the closure result:

+
// General Workaround
+let string = try dbQueue.read { db -> String? in
+    let result = try String.fetchOne(db, ...)
+    return result
+}
+
+ +

You can also, when possible, write a single-line closure:

+
// Single-line closure workaround:
+let string = try dbQueue.read { db in
+    try String.fetchOne(db, ...)
+}
+
+

SQLite error 1 “no such column”

+ +

This error message is self-explanatory: do check for misspelled or non-existing column names.

+ +

However, sometimes this error only happens when an app runs on a recent operating system (iOS 14+, Big Sur+, etc.) The error does not happen with previous ones.

+ +

When this is the case, there are two possible explanations:

+ +
    +
  1. Maybe a column name is really misspelled or missing from the database schema.

    + +

    To find it, check the SQL statement that comes with the DatabaseError.

  2. +
  3. Maybe the application is using the character " instead of the single quote ' as the delimiter for string literals in raw SQL queries. Recent versions of SQLite have learned to tell about this deviation from the SQL standard, and this is why you are seeing this error.

    + +

    For example: this is not standard SQL: UPDATE player SET name = "Arthur".

    + +

    The standard version is: UPDATE player SET name = 'Arthur'.

    + +

    It just happens that old versions of SQLite used to accept the former, non-standard version. Newer versions are able to reject it with an error.

    + +

    The fix is to change the SQL statements run by the application: replace " with ' in your string literals.

    + +

    It may also be time to learn about statement arguments and SQL injection:

    +
    let name: String = ...
    +
    +// NOT STANDARD (double quote)
    +try db.execute(sql: """
    +    UPDATE player SET name = "\(name)"
    +    """)
    +
    +// STANDARD, BUT STILL NOT RECOMMENDED (single quote)
    +try db.execute(sql: "UPDATE player SET name = '\(name)'")
    +
    +// STANDARD, AND RECOMMENDED (statement arguments)
    +try db.execute(sql: "UPDATE player SET name = ?", arguments: [name])
    +
  4. +
+ +

For more information, see Double-quoted String Literals Are Accepted, and Configuration.acceptsDoubleQuotedStringLiterals.

+

SQLite error 10 “disk I/O error”, SQLite error 23 “not authorized”

+ +

Those errors may be the sign that SQLite can’t access the database due to data protection.

+ +

When your application should be able to run in the background on a locked device, it has to catch this error, and, for example, wait for UIApplicationDelegate.applicationProtectedDataDidBecomeAvailable(_:) or UIApplicationProtectedDataDidBecomeAvailable notification and retry the failed database operation.

+
do {
+    try ...
+} catch DatabaseError.SQLITE_IOERR, DatabaseError.SQLITE_AUTH {
+    // Handle possible data protection error
+}
+
+ +

This error can also be prevented altogether by using a more relaxed file protection.

+

SQLite error 21 “wrong number of statement arguments” with LIKE queries

+ +

You may get the error “wrong number of statement arguments” when executing a LIKE query similar to:

+
let name = textField.text
+let players = try dbQueue.read { db in
+    try Player.fetchAll(db, sql: "SELECT * FROM player WHERE name LIKE '%?%'", arguments: [name])
+}
+
+ +

The problem lies in the '%?%' pattern.

+ +

SQLite only interprets ? as a parameter when it is a placeholder for a whole value (int, double, string, blob, null). In this incorrect query, ? is just a character in the '%?%' string: it is not a query parameter, and is not processed in any way. See https://www.sqlite.org/lang_expr.html#varparam for more information about SQLite parameters.

+ +

To fix the error, you can feed the request with the pattern itself, instead of the name:

+
let name = textField.text
+let players: [Player] = try dbQueue.read { db in
+    let pattern = "%\(name)%"
+    return try Player.fetchAll(db, sql: "SELECT * FROM player WHERE name LIKE ?", arguments: [pattern])
+}
+
+

Sample Code

+ + + +
+ +

Thanks

+ + + +
+ +

URIs don’t change: people change them.

+

Changes Tracking

+ +

This chapter has been renamed Record Comparison.

+

Customized Decoding of Database Rows

+ +

This chapter has been renamed Beyond FetchableRecord.

+

Dealing with External Connections

+ +

This chapter has been superseded by the Sharing a Database guide.

+

Enabling FTS5 Support

+ +

This chapter has moved.

+

FetchedRecordsController

+ +

FetchedRecordsController has been removed in GRDB 5.

+ +

The Database Observation chapter describes the other ways to observe the database.

+ + +

This chapter has moved.

+

Migrations

+ +

This chapter has moved.

+

NSNumber and NSDecimalNumber

+ +

This chapter has moved

+

Persistable Protocol

+ +

This protocol has been renamed PersistableRecord in GRDB 3.0.

+

RowConvertible Protocol

+ +

This protocol has been renamed FetchableRecord in GRDB 3.0.

+

TableMapping Protocol

+ +

This protocol has been renamed TableRecord in GRDB 3.0.

+

ValueObservation and DatabaseRegionObservation

+ +

This chapter has been superseded by ValueObservation and DatabaseRegionObservation.

+

Concurrency

+ +

This chapter has moved.

+

Guarantees and Rules

+ +

This chapter is now split into Concurrency Rules and Safe and Unsafe Database Accesses.

+

Differences between Database Queues and Pools

+ +

This chapter has moved.

+

Advanced DatabasePool

+ +

This chapter has moved.

+

Database Snapshots

+ +

This chapter has moved.

+

DatabaseWriter and DatabaseReader Protocols

+ +

This chapter was removed. See the references of DatabaseReader and DatabaseWriter.

+

Asynchronous APIs

+ +

This chapter has moved.

+

Unsafe Concurrency APIs

+ +

This chapter has moved.

+ +
+
+ +
+
+ + diff --git a/docs/5.16/js/jazzy.js b/docs/5.16/js/jazzy.js new file mode 100755 index 000000000..198441660 --- /dev/null +++ b/docs/5.16/js/jazzy.js @@ -0,0 +1,74 @@ +// Jazzy - https://github.com/realm/jazzy +// Copyright Realm Inc. +// SPDX-License-Identifier: MIT + +window.jazzy = {'docset': false} +if (typeof window.dash != 'undefined') { + document.documentElement.className += ' dash' + window.jazzy.docset = true +} +if (navigator.userAgent.match(/xcode/i)) { + document.documentElement.className += ' xcode' + window.jazzy.docset = true +} + +function toggleItem($link, $content) { + var animationDuration = 300; + $link.toggleClass('token-open'); + $content.slideToggle(animationDuration); +} + +function itemLinkToContent($link) { + return $link.parent().parent().next(); +} + +// On doc load + hash-change, open any targetted item +function openCurrentItemIfClosed() { + if (window.jazzy.docset) { + return; + } + var $link = $(`a[name="${location.hash.substring(1)}"]`).nextAll('.token'); + $content = itemLinkToContent($link); + if ($content.is(':hidden')) { + toggleItem($link, $content); + } +} + +$(openCurrentItemIfClosed); +$(window).on('hashchange', openCurrentItemIfClosed); + +// On item link ('token') click, toggle its discussion +$('.token').on('click', function(event) { + if (window.jazzy.docset) { + return; + } + var $link = $(this); + toggleItem($link, itemLinkToContent($link)); + + // Keeps the document from jumping to the hash. + var href = $link.attr('href'); + if (history.pushState) { + history.pushState({}, '', href); + } else { + location.hash = href; + } + event.preventDefault(); +}); + +// Clicks on links to the current, closed, item need to open the item +$("a:not('.token')").on('click', function() { + if (location == this.href) { + openCurrentItemIfClosed(); + } +}); + +// KaTeX rendering +if ("katex" in window) { + $($('.math').each( (_, element) => { + katex.render(element.textContent, element, { + displayMode: $(element).hasClass('m-block'), + throwOnError: false, + trust: true + }); + })) +} diff --git a/docs/5.16/js/jazzy.search.js b/docs/5.16/js/jazzy.search.js new file mode 100644 index 000000000..359cdbb8b --- /dev/null +++ b/docs/5.16/js/jazzy.search.js @@ -0,0 +1,74 @@ +// Jazzy - https://github.com/realm/jazzy +// Copyright Realm Inc. +// SPDX-License-Identifier: MIT + +$(function(){ + var $typeahead = $('[data-typeahead]'); + var $form = $typeahead.parents('form'); + var searchURL = $form.attr('action'); + + function displayTemplate(result) { + return result.name; + } + + function suggestionTemplate(result) { + var t = '
'; + t += '' + result.name + ''; + if (result.parent_name) { + t += '' + result.parent_name + ''; + } + t += '
'; + return t; + } + + $typeahead.one('focus', function() { + $form.addClass('loading'); + + $.getJSON(searchURL).then(function(searchData) { + const searchIndex = lunr(function() { + this.ref('url'); + this.field('name'); + this.field('abstract'); + for (const [url, doc] of Object.entries(searchData)) { + this.add({url: url, name: doc.name, abstract: doc.abstract}); + } + }); + + $typeahead.typeahead( + { + highlight: true, + minLength: 3, + autoselect: true + }, + { + limit: 10, + display: displayTemplate, + templates: { suggestion: suggestionTemplate }, + source: function(query, sync) { + const lcSearch = query.toLowerCase(); + const results = searchIndex.query(function(q) { + q.term(lcSearch, { boost: 100 }); + q.term(lcSearch, { + boost: 10, + wildcard: lunr.Query.wildcard.TRAILING + }); + }).map(function(result) { + var doc = searchData[result.ref]; + doc.url = result.ref; + return doc; + }); + sync(results); + } + } + ); + $form.removeClass('loading'); + $typeahead.trigger('focus'); + }); + }); + + var baseURL = searchURL.slice(0, -"search.json".length); + + $typeahead.on('typeahead:select', function(e, result) { + window.location = baseURL + result.url; + }); +}); diff --git a/docs/5.16/js/jquery.min.js b/docs/5.16/js/jquery.min.js new file mode 100644 index 000000000..c4c6022f2 --- /dev/null +++ b/docs/5.16/js/jquery.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 00){var c=e.utils.clone(r)||{};c.position=[a,l],c.index=s.length,s.push(new e.Token(i.slice(a,o),c))}a=o+1}}return s},e.tokenizer.separator=/[\s\-]+/,e.Pipeline=function(){this._stack=[]},e.Pipeline.registeredFunctions=Object.create(null),e.Pipeline.registerFunction=function(t,r){r in this.registeredFunctions&&e.utils.warn("Overwriting existing registered function: "+r),t.label=r,e.Pipeline.registeredFunctions[t.label]=t},e.Pipeline.warnIfFunctionNotRegistered=function(t){var r=t.label&&t.label in this.registeredFunctions;r||e.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",t)},e.Pipeline.load=function(t){var r=new e.Pipeline;return t.forEach(function(t){var i=e.Pipeline.registeredFunctions[t];if(!i)throw new Error("Cannot load unregistered function: "+t);r.add(i)}),r},e.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(t){e.Pipeline.warnIfFunctionNotRegistered(t),this._stack.push(t)},this)},e.Pipeline.prototype.after=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,r)},e.Pipeline.prototype.before=function(t,r){e.Pipeline.warnIfFunctionNotRegistered(r);var i=this._stack.indexOf(t);if(i==-1)throw new Error("Cannot find existingFn");this._stack.splice(i,0,r)},e.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);t!=-1&&this._stack.splice(t,1)},e.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r1&&(se&&(r=n),s!=e);)i=r-t,n=t+Math.floor(i/2),s=this.elements[2*n];return s==e?2*n:s>e?2*n:sa?l+=2:o==a&&(t+=r[u+1]*i[l+1],u+=2,l+=2);return t},e.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},e.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t0){var o,a=s.str.charAt(0);a in s.node.edges?o=s.node.edges[a]:(o=new e.TokenSet,s.node.edges[a]=o),1==s.str.length&&(o["final"]=!0),n.push({node:o,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(0!=s.editsRemaining){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new e.TokenSet;s.node.edges["*"]=u}if(0==s.str.length&&(u["final"]=!0),n.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&n.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),1==s.str.length&&(s.node["final"]=!0),s.str.length>=1){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new e.TokenSet;s.node.edges["*"]=l}1==s.str.length&&(l["final"]=!0),n.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var c,h=s.str.charAt(0),d=s.str.charAt(1);d in s.node.edges?c=s.node.edges[d]:(c=new e.TokenSet,s.node.edges[d]=c),1==s.str.length&&(c["final"]=!0),n.push({node:c,editsRemaining:s.editsRemaining-1,str:h+s.str.slice(2)})}}}return i},e.TokenSet.fromString=function(t){for(var r=new e.TokenSet,i=r,n=0,s=t.length;n=e;t--){var r=this.uncheckedNodes[t],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r["char"]]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}},e.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},e.Index.prototype.search=function(t){return this.query(function(r){var i=new e.QueryParser(t,r);i.parse()})},e.Index.prototype.query=function(t){for(var r=new e.Query(this.fields),i=Object.create(null),n=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),u=0;u1?this._b=1:this._b=e},e.Builder.prototype.k1=function(e){this._k1=e},e.Builder.prototype.add=function(t,r){var i=t[this._ref],n=Object.keys(this._fields);this._documents[i]=r||{},this.documentCount+=1;for(var s=0;s=this.length)return e.QueryLexer.EOS;var t=this.str.charAt(this.pos);return this.pos+=1,t},e.QueryLexer.prototype.width=function(){return this.pos-this.start},e.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},e.QueryLexer.prototype.backup=function(){this.pos-=1},e.QueryLexer.prototype.acceptDigitRun=function(){var t,r;do t=this.next(),r=t.charCodeAt(0);while(r>47&&r<58);t!=e.QueryLexer.EOS&&this.backup()},e.QueryLexer.prototype.more=function(){return this.pos1&&(t.backup(),t.emit(e.QueryLexer.TERM)),t.ignore(),t.more())return e.QueryLexer.lexText},e.QueryLexer.lexEditDistance=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.EDIT_DISTANCE),e.QueryLexer.lexText},e.QueryLexer.lexBoost=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.BOOST),e.QueryLexer.lexText},e.QueryLexer.lexEOS=function(t){t.width()>0&&t.emit(e.QueryLexer.TERM)},e.QueryLexer.termSeparator=e.tokenizer.separator,e.QueryLexer.lexText=function(t){for(;;){var r=t.next();if(r==e.QueryLexer.EOS)return e.QueryLexer.lexEOS;if(92!=r.charCodeAt(0)){if(":"==r)return e.QueryLexer.lexField;if("~"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexEditDistance;if("^"==r)return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexBoost;if("+"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if("-"==r&&1===t.width())return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if(r.match(e.QueryLexer.termSeparator))return e.QueryLexer.lexTerm}else t.escapeCharacter()}},e.QueryParser=function(t,r){this.lexer=new e.QueryLexer(t),this.query=r,this.currentClause={},this.lexemeIdx=0},e.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var t=e.QueryParser.parseClause;t;)t=t(this);return this.query},e.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},e.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},e.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},e.QueryParser.parseClause=function(t){var r=t.peekLexeme();if(void 0!=r)switch(r.type){case e.QueryLexer.PRESENCE:return e.QueryParser.parsePresence;case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expected either a field or a term, found "+r.type;throw r.str.length>=1&&(i+=" with value '"+r.str+"'"),new e.QueryParseError(i,r.start,r.end)}},e.QueryParser.parsePresence=function(t){var r=t.consumeLexeme();if(void 0!=r){switch(r.str){case"-":t.currentClause.presence=e.Query.presence.PROHIBITED;break;case"+":t.currentClause.presence=e.Query.presence.REQUIRED;break;default:var i="unrecognised presence operator'"+r.str+"'";throw new e.QueryParseError(i,r.start,r.end)}var n=t.peekLexeme();if(void 0==n){var i="expecting term or field, found nothing";throw new e.QueryParseError(i,r.start,r.end)}switch(n.type){case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var i="expecting term or field, found '"+n.type+"'";throw new e.QueryParseError(i,n.start,n.end)}}},e.QueryParser.parseField=function(t){var r=t.consumeLexeme();if(void 0!=r){if(t.query.allFields.indexOf(r.str)==-1){var i=t.query.allFields.map(function(e){return"'"+e+"'"}).join(", "),n="unrecognised field '"+r.str+"', possible fields: "+i;throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.fields=[r.str];var s=t.peekLexeme();if(void 0==s){var n="expecting term, found nothing";throw new e.QueryParseError(n,r.start,r.end)}switch(s.type){case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var n="expecting term, found '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseTerm=function(t){var r=t.consumeLexeme();if(void 0!=r){t.currentClause.term=r.str.toLowerCase(),r.str.indexOf("*")!=-1&&(t.currentClause.usePipeline=!1);var i=t.peekLexeme();if(void 0==i)return void t.nextClause();switch(i.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+i.type+"'";throw new e.QueryParseError(n,i.start,i.end)}}},e.QueryParser.parseEditDistance=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="edit distance must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.editDistance=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},e.QueryParser.parseBoost=function(t){var r=t.consumeLexeme();if(void 0!=r){var i=parseInt(r.str,10);if(isNaN(i)){var n="boost must be numeric";throw new e.QueryParseError(n,r.start,r.end)}t.currentClause.boost=i;var s=t.peekLexeme();if(void 0==s)return void t.nextClause();switch(s.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+s.type+"'";throw new e.QueryParseError(n,s.start,s.end)}}},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.lunr=t()}(this,function(){return e})}(); diff --git a/docs/5.16/js/typeahead.jquery.js b/docs/5.16/js/typeahead.jquery.js new file mode 100644 index 000000000..3a2d2ab03 --- /dev/null +++ b/docs/5.16/js/typeahead.jquery.js @@ -0,0 +1,1694 @@ +/*! + * typeahead.js 1.3.1 + * https://github.com/corejavascript/typeahead.js + * Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT + */ + + +(function(root, factory) { + if (typeof define === "function" && define.amd) { + define([ "jquery" ], function(a0) { + return factory(a0); + }); + } else if (typeof module === "object" && module.exports) { + module.exports = factory(require("jquery")); + } else { + factory(root["jQuery"]); + } +})(this, function($) { + var _ = function() { + "use strict"; + return { + isMsie: function() { + return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false; + }, + isBlankString: function(str) { + return !str || /^\s*$/.test(str); + }, + escapeRegExChars: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + isString: function(obj) { + return typeof obj === "string"; + }, + isNumber: function(obj) { + return typeof obj === "number"; + }, + isArray: $.isArray, + isFunction: $.isFunction, + isObject: $.isPlainObject, + isUndefined: function(obj) { + return typeof obj === "undefined"; + }, + isElement: function(obj) { + return !!(obj && obj.nodeType === 1); + }, + isJQuery: function(obj) { + return obj instanceof $; + }, + toStr: function toStr(s) { + return _.isUndefined(s) || s === null ? "" : s + ""; + }, + bind: $.proxy, + each: function(collection, cb) { + $.each(collection, reverseArgs); + function reverseArgs(index, value) { + return cb(value, index); + } + }, + map: $.map, + filter: $.grep, + every: function(obj, test) { + var result = true; + if (!obj) { + return result; + } + $.each(obj, function(key, val) { + if (!(result = test.call(null, val, key, obj))) { + return false; + } + }); + return !!result; + }, + some: function(obj, test) { + var result = false; + if (!obj) { + return result; + } + $.each(obj, function(key, val) { + if (result = test.call(null, val, key, obj)) { + return false; + } + }); + return !!result; + }, + mixin: $.extend, + identity: function(x) { + return x; + }, + clone: function(obj) { + return $.extend(true, {}, obj); + }, + getIdGenerator: function() { + var counter = 0; + return function() { + return counter++; + }; + }, + templatify: function templatify(obj) { + return $.isFunction(obj) ? obj : template; + function template() { + return String(obj); + } + }, + defer: function(fn) { + setTimeout(fn, 0); + }, + debounce: function(func, wait, immediate) { + var timeout, result; + return function() { + var context = this, args = arguments, later, callNow; + later = function() { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + } + }; + callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + } + return result; + }; + }, + throttle: function(func, wait) { + var context, args, timeout, result, previous, later; + previous = 0; + later = function() { + previous = new Date(); + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date(), remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }, + stringify: function(val) { + return _.isString(val) ? val : JSON.stringify(val); + }, + guid: function() { + function _p8(s) { + var p = (Math.random().toString(16) + "000000000").substr(2, 8); + return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p; + } + return "tt-" + _p8() + _p8(true) + _p8(true) + _p8(); + }, + noop: function() {} + }; + }(); + var WWW = function() { + "use strict"; + var defaultClassNames = { + wrapper: "twitter-typeahead", + input: "tt-input", + hint: "tt-hint", + menu: "tt-menu", + dataset: "tt-dataset", + suggestion: "tt-suggestion", + selectable: "tt-selectable", + empty: "tt-empty", + open: "tt-open", + cursor: "tt-cursor", + highlight: "tt-highlight" + }; + return build; + function build(o) { + var www, classes; + classes = _.mixin({}, defaultClassNames, o); + www = { + css: buildCss(), + classes: classes, + html: buildHtml(classes), + selectors: buildSelectors(classes) + }; + return { + css: www.css, + html: www.html, + classes: www.classes, + selectors: www.selectors, + mixin: function(o) { + _.mixin(o, www); + } + }; + } + function buildHtml(c) { + return { + wrapper: '', + menu: '
' + }; + } + function buildSelectors(classes) { + var selectors = {}; + _.each(classes, function(v, k) { + selectors[k] = "." + v; + }); + return selectors; + } + function buildCss() { + var css = { + wrapper: { + position: "relative", + display: "inline-block" + }, + hint: { + position: "absolute", + top: "0", + left: "0", + borderColor: "transparent", + boxShadow: "none", + opacity: "1" + }, + input: { + position: "relative", + verticalAlign: "top", + backgroundColor: "transparent" + }, + inputWithNoHint: { + position: "relative", + verticalAlign: "top" + }, + menu: { + position: "absolute", + top: "100%", + left: "0", + zIndex: "100", + display: "none" + }, + ltr: { + left: "0", + right: "auto" + }, + rtl: { + left: "auto", + right: " 0" + } + }; + if (_.isMsie()) { + _.mixin(css.input, { + backgroundImage: "url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)" + }); + } + return css; + } + }(); + var EventBus = function() { + "use strict"; + var namespace, deprecationMap; + namespace = "typeahead:"; + deprecationMap = { + render: "rendered", + cursorchange: "cursorchanged", + select: "selected", + autocomplete: "autocompleted" + }; + function EventBus(o) { + if (!o || !o.el) { + $.error("EventBus initialized without el"); + } + this.$el = $(o.el); + } + _.mixin(EventBus.prototype, { + _trigger: function(type, args) { + var $e = $.Event(namespace + type); + this.$el.trigger.call(this.$el, $e, args || []); + return $e; + }, + before: function(type) { + var args, $e; + args = [].slice.call(arguments, 1); + $e = this._trigger("before" + type, args); + return $e.isDefaultPrevented(); + }, + trigger: function(type) { + var deprecatedType; + this._trigger(type, [].slice.call(arguments, 1)); + if (deprecatedType = deprecationMap[type]) { + this._trigger(deprecatedType, [].slice.call(arguments, 1)); + } + } + }); + return EventBus; + }(); + var EventEmitter = function() { + "use strict"; + var splitter = /\s+/, nextTick = getNextTick(); + return { + onSync: onSync, + onAsync: onAsync, + off: off, + trigger: trigger + }; + function on(method, types, cb, context) { + var type; + if (!cb) { + return this; + } + types = types.split(splitter); + cb = context ? bindContext(cb, context) : cb; + this._callbacks = this._callbacks || {}; + while (type = types.shift()) { + this._callbacks[type] = this._callbacks[type] || { + sync: [], + async: [] + }; + this._callbacks[type][method].push(cb); + } + return this; + } + function onAsync(types, cb, context) { + return on.call(this, "async", types, cb, context); + } + function onSync(types, cb, context) { + return on.call(this, "sync", types, cb, context); + } + function off(types) { + var type; + if (!this._callbacks) { + return this; + } + types = types.split(splitter); + while (type = types.shift()) { + delete this._callbacks[type]; + } + return this; + } + function trigger(types) { + var type, callbacks, args, syncFlush, asyncFlush; + if (!this._callbacks) { + return this; + } + types = types.split(splitter); + args = [].slice.call(arguments, 1); + while ((type = types.shift()) && (callbacks = this._callbacks[type])) { + syncFlush = getFlush(callbacks.sync, this, [ type ].concat(args)); + asyncFlush = getFlush(callbacks.async, this, [ type ].concat(args)); + syncFlush() && nextTick(asyncFlush); + } + return this; + } + function getFlush(callbacks, context, args) { + return flush; + function flush() { + var cancelled; + for (var i = 0, len = callbacks.length; !cancelled && i < len; i += 1) { + cancelled = callbacks[i].apply(context, args) === false; + } + return !cancelled; + } + } + function getNextTick() { + var nextTickFn; + if (window.setImmediate) { + nextTickFn = function nextTickSetImmediate(fn) { + setImmediate(function() { + fn(); + }); + }; + } else { + nextTickFn = function nextTickSetTimeout(fn) { + setTimeout(function() { + fn(); + }, 0); + }; + } + return nextTickFn; + } + function bindContext(fn, context) { + return fn.bind ? fn.bind(context) : function() { + fn.apply(context, [].slice.call(arguments, 0)); + }; + } + }(); + var highlight = function(doc) { + "use strict"; + var defaults = { + node: null, + pattern: null, + tagName: "strong", + className: null, + wordsOnly: false, + caseSensitive: false, + diacriticInsensitive: false + }; + var accented = { + A: "[AaªÀ-Åà-åĀ-ąǍǎȀ-ȃȦȧᴬᵃḀḁẚẠ-ảₐ℀℁℻⒜Ⓐⓐ㍱-㍴㎀-㎄㎈㎉㎩-㎯㏂㏊㏟㏿Aa]", + B: "[BbᴮᵇḂ-ḇℬ⒝Ⓑⓑ㍴㎅-㎇㏃㏈㏔㏝Bb]", + C: "[CcÇçĆ-čᶜ℀ℂ℃℅℆ℭⅭⅽ⒞Ⓒⓒ㍶㎈㎉㎝㎠㎤㏄-㏇Cc]", + D: "[DdĎďDŽ-džDZ-dzᴰᵈḊ-ḓⅅⅆⅮⅾ⒟Ⓓⓓ㋏㍲㍷-㍹㎗㎭-㎯㏅㏈Dd]", + E: "[EeÈ-Ëè-ëĒ-ěȄ-ȇȨȩᴱᵉḘ-ḛẸ-ẽₑ℡ℯℰⅇ⒠Ⓔⓔ㉐㋍㋎Ee]", + F: "[FfᶠḞḟ℉ℱ℻⒡Ⓕⓕ㎊-㎌㎙ff-fflFf]", + G: "[GgĜ-ģǦǧǴǵᴳᵍḠḡℊ⒢Ⓖⓖ㋌㋍㎇㎍-㎏㎓㎬㏆㏉㏒㏿Gg]", + H: "[HhĤĥȞȟʰᴴḢ-ḫẖℋ-ℎ⒣Ⓗⓗ㋌㍱㎐-㎔㏊㏋㏗Hh]", + I: "[IiÌ-Ïì-ïĨ-İIJijǏǐȈ-ȋᴵᵢḬḭỈ-ịⁱℐℑℹⅈⅠ-ⅣⅥ-ⅨⅪⅫⅰ-ⅳⅵ-ⅸⅺⅻ⒤Ⓘⓘ㍺㏌㏕fiffiIi]", + J: "[JjIJ-ĵLJ-njǰʲᴶⅉ⒥ⒿⓙⱼJj]", + K: "[KkĶķǨǩᴷᵏḰ-ḵK⒦Ⓚⓚ㎄㎅㎉㎏㎑㎘㎞㎢㎦㎪㎸㎾㏀㏆㏍-㏏Kk]", + L: "[LlĹ-ŀLJ-ljˡᴸḶḷḺ-ḽℒℓ℡Ⅼⅼ⒧Ⓛⓛ㋏㎈㎉㏐-㏓㏕㏖㏿flfflLl]", + M: "[MmᴹᵐḾ-ṃ℠™ℳⅯⅿ⒨Ⓜⓜ㍷-㍹㎃㎆㎎㎒㎖㎙-㎨㎫㎳㎷㎹㎽㎿㏁㏂㏎㏐㏔-㏖㏘㏙㏞㏟Mm]", + N: "[NnÑñŃ-ʼnNJ-njǸǹᴺṄ-ṋⁿℕ№⒩Ⓝⓝ㎁㎋㎚㎱㎵㎻㏌㏑Nn]", + O: "[OoºÒ-Öò-öŌ-őƠơǑǒǪǫȌ-ȏȮȯᴼᵒỌ-ỏₒ℅№ℴ⒪Ⓞⓞ㍵㏇㏒㏖Oo]", + P: "[PpᴾᵖṔ-ṗℙ⒫Ⓟⓟ㉐㍱㍶㎀㎊㎩-㎬㎰㎴㎺㏋㏗-㏚Pp]", + Q: "[Qqℚ⒬Ⓠⓠ㏃Qq]", + R: "[RrŔ-řȐ-ȓʳᴿᵣṘ-ṛṞṟ₨ℛ-ℝ⒭Ⓡⓡ㋍㍴㎭-㎯㏚㏛Rr]", + S: "[SsŚ-šſȘșˢṠ-ṣ₨℁℠⒮Ⓢⓢ㎧㎨㎮-㎳㏛㏜stSs]", + T: "[TtŢ-ťȚțᵀᵗṪ-ṱẗ℡™⒯Ⓣⓣ㉐㋏㎔㏏ſtstTt]", + U: "[UuÙ-Üù-üŨ-ųƯưǓǔȔ-ȗᵁᵘᵤṲ-ṷỤ-ủ℆⒰Ⓤⓤ㍳㍺Uu]", + V: "[VvᵛᵥṼ-ṿⅣ-Ⅷⅳ-ⅷ⒱Ⓥⓥⱽ㋎㍵㎴-㎹㏜㏞Vv]", + W: "[WwŴŵʷᵂẀ-ẉẘ⒲Ⓦⓦ㎺-㎿㏝Ww]", + X: "[XxˣẊ-ẍₓ℻Ⅸ-Ⅻⅸ-ⅻ⒳Ⓧⓧ㏓Xx]", + Y: "[YyÝýÿŶ-ŸȲȳʸẎẏẙỲ-ỹ⒴Ⓨⓨ㏉Yy]", + Z: "[ZzŹ-žDZ-dzᶻẐ-ẕℤℨ⒵Ⓩⓩ㎐-㎔Zz]" + }; + return function hightlight(o) { + var regex; + o = _.mixin({}, defaults, o); + if (!o.node || !o.pattern) { + return; + } + o.pattern = _.isArray(o.pattern) ? o.pattern : [ o.pattern ]; + regex = getRegex(o.pattern, o.caseSensitive, o.wordsOnly, o.diacriticInsensitive); + traverse(o.node, hightlightTextNode); + function hightlightTextNode(textNode) { + var match, patternNode, wrapperNode; + if (match = regex.exec(textNode.data)) { + wrapperNode = doc.createElement(o.tagName); + o.className && (wrapperNode.className = o.className); + patternNode = textNode.splitText(match.index); + patternNode.splitText(match[0].length); + wrapperNode.appendChild(patternNode.cloneNode(true)); + textNode.parentNode.replaceChild(wrapperNode, patternNode); + } + return !!match; + } + function traverse(el, hightlightTextNode) { + var childNode, TEXT_NODE_TYPE = 3; + for (var i = 0; i < el.childNodes.length; i++) { + childNode = el.childNodes[i]; + if (childNode.nodeType === TEXT_NODE_TYPE) { + i += hightlightTextNode(childNode) ? 1 : 0; + } else { + traverse(childNode, hightlightTextNode); + } + } + } + }; + function accent_replacer(chr) { + return accented[chr.toUpperCase()] || chr; + } + function getRegex(patterns, caseSensitive, wordsOnly, diacriticInsensitive) { + var escapedPatterns = [], regexStr; + for (var i = 0, len = patterns.length; i < len; i++) { + var escapedWord = _.escapeRegExChars(patterns[i]); + if (diacriticInsensitive) { + escapedWord = escapedWord.replace(/\S/g, accent_replacer); + } + escapedPatterns.push(escapedWord); + } + regexStr = wordsOnly ? "\\b(" + escapedPatterns.join("|") + ")\\b" : "(" + escapedPatterns.join("|") + ")"; + return caseSensitive ? new RegExp(regexStr) : new RegExp(regexStr, "i"); + } + }(window.document); + var Input = function() { + "use strict"; + var specialKeyCodeMap; + specialKeyCodeMap = { + 9: "tab", + 27: "esc", + 37: "left", + 39: "right", + 13: "enter", + 38: "up", + 40: "down" + }; + function Input(o, www) { + var id; + o = o || {}; + if (!o.input) { + $.error("input is missing"); + } + www.mixin(this); + this.$hint = $(o.hint); + this.$input = $(o.input); + this.$menu = $(o.menu); + id = this.$input.attr("id") || _.guid(); + this.$menu.attr("id", id + "_listbox"); + this.$hint.attr({ + "aria-hidden": true + }); + this.$input.attr({ + "aria-owns": id + "_listbox", + role: "combobox", + "aria-autocomplete": "list", + "aria-expanded": false + }); + this.query = this.$input.val(); + this.queryWhenFocused = this.hasFocus() ? this.query : null; + this.$overflowHelper = buildOverflowHelper(this.$input); + this._checkLanguageDirection(); + if (this.$hint.length === 0) { + this.setHint = this.getHint = this.clearHint = this.clearHintIfInvalid = _.noop; + } + this.onSync("cursorchange", this._updateDescendent); + } + Input.normalizeQuery = function(str) { + return _.toStr(str).replace(/^\s*/g, "").replace(/\s{2,}/g, " "); + }; + _.mixin(Input.prototype, EventEmitter, { + _onBlur: function onBlur() { + this.resetInputValue(); + this.trigger("blurred"); + }, + _onFocus: function onFocus() { + this.queryWhenFocused = this.query; + this.trigger("focused"); + }, + _onKeydown: function onKeydown($e) { + var keyName = specialKeyCodeMap[$e.which || $e.keyCode]; + this._managePreventDefault(keyName, $e); + if (keyName && this._shouldTrigger(keyName, $e)) { + this.trigger(keyName + "Keyed", $e); + } + }, + _onInput: function onInput() { + this._setQuery(this.getInputValue()); + this.clearHintIfInvalid(); + this._checkLanguageDirection(); + }, + _managePreventDefault: function managePreventDefault(keyName, $e) { + var preventDefault; + switch (keyName) { + case "up": + case "down": + preventDefault = !withModifier($e); + break; + + default: + preventDefault = false; + } + preventDefault && $e.preventDefault(); + }, + _shouldTrigger: function shouldTrigger(keyName, $e) { + var trigger; + switch (keyName) { + case "tab": + trigger = !withModifier($e); + break; + + default: + trigger = true; + } + return trigger; + }, + _checkLanguageDirection: function checkLanguageDirection() { + var dir = (this.$input.css("direction") || "ltr").toLowerCase(); + if (this.dir !== dir) { + this.dir = dir; + this.$hint.attr("dir", dir); + this.trigger("langDirChanged", dir); + } + }, + _setQuery: function setQuery(val, silent) { + var areEquivalent, hasDifferentWhitespace; + areEquivalent = areQueriesEquivalent(val, this.query); + hasDifferentWhitespace = areEquivalent ? this.query.length !== val.length : false; + this.query = val; + if (!silent && !areEquivalent) { + this.trigger("queryChanged", this.query); + } else if (!silent && hasDifferentWhitespace) { + this.trigger("whitespaceChanged", this.query); + } + }, + _updateDescendent: function updateDescendent(event, id) { + this.$input.attr("aria-activedescendant", id); + }, + bind: function() { + var that = this, onBlur, onFocus, onKeydown, onInput; + onBlur = _.bind(this._onBlur, this); + onFocus = _.bind(this._onFocus, this); + onKeydown = _.bind(this._onKeydown, this); + onInput = _.bind(this._onInput, this); + this.$input.on("blur.tt", onBlur).on("focus.tt", onFocus).on("keydown.tt", onKeydown); + if (!_.isMsie() || _.isMsie() > 9) { + this.$input.on("input.tt", onInput); + } else { + this.$input.on("keydown.tt keypress.tt cut.tt paste.tt", function($e) { + if (specialKeyCodeMap[$e.which || $e.keyCode]) { + return; + } + _.defer(_.bind(that._onInput, that, $e)); + }); + } + return this; + }, + focus: function focus() { + this.$input.focus(); + }, + blur: function blur() { + this.$input.blur(); + }, + getLangDir: function getLangDir() { + return this.dir; + }, + getQuery: function getQuery() { + return this.query || ""; + }, + setQuery: function setQuery(val, silent) { + this.setInputValue(val); + this._setQuery(val, silent); + }, + hasQueryChangedSinceLastFocus: function hasQueryChangedSinceLastFocus() { + return this.query !== this.queryWhenFocused; + }, + getInputValue: function getInputValue() { + return this.$input.val(); + }, + setInputValue: function setInputValue(value) { + this.$input.val(value); + this.clearHintIfInvalid(); + this._checkLanguageDirection(); + }, + resetInputValue: function resetInputValue() { + this.setInputValue(this.query); + }, + getHint: function getHint() { + return this.$hint.val(); + }, + setHint: function setHint(value) { + this.$hint.val(value); + }, + clearHint: function clearHint() { + this.setHint(""); + }, + clearHintIfInvalid: function clearHintIfInvalid() { + var val, hint, valIsPrefixOfHint, isValid; + val = this.getInputValue(); + hint = this.getHint(); + valIsPrefixOfHint = val !== hint && hint.indexOf(val) === 0; + isValid = val !== "" && valIsPrefixOfHint && !this.hasOverflow(); + !isValid && this.clearHint(); + }, + hasFocus: function hasFocus() { + return this.$input.is(":focus"); + }, + hasOverflow: function hasOverflow() { + var constraint = this.$input.width() - 2; + this.$overflowHelper.text(this.getInputValue()); + return this.$overflowHelper.width() >= constraint; + }, + isCursorAtEnd: function() { + var valueLength, selectionStart, range; + valueLength = this.$input.val().length; + selectionStart = this.$input[0].selectionStart; + if (_.isNumber(selectionStart)) { + return selectionStart === valueLength; + } else if (document.selection) { + range = document.selection.createRange(); + range.moveStart("character", -valueLength); + return valueLength === range.text.length; + } + return true; + }, + destroy: function destroy() { + this.$hint.off(".tt"); + this.$input.off(".tt"); + this.$overflowHelper.remove(); + this.$hint = this.$input = this.$overflowHelper = $("
"); + }, + setAriaExpanded: function setAriaExpanded(value) { + this.$input.attr("aria-expanded", value); + } + }); + return Input; + function buildOverflowHelper($input) { + return $('').css({ + position: "absolute", + visibility: "hidden", + whiteSpace: "pre", + fontFamily: $input.css("font-family"), + fontSize: $input.css("font-size"), + fontStyle: $input.css("font-style"), + fontVariant: $input.css("font-variant"), + fontWeight: $input.css("font-weight"), + wordSpacing: $input.css("word-spacing"), + letterSpacing: $input.css("letter-spacing"), + textIndent: $input.css("text-indent"), + textRendering: $input.css("text-rendering"), + textTransform: $input.css("text-transform") + }).insertAfter($input); + } + function areQueriesEquivalent(a, b) { + return Input.normalizeQuery(a) === Input.normalizeQuery(b); + } + function withModifier($e) { + return $e.altKey || $e.ctrlKey || $e.metaKey || $e.shiftKey; + } + }(); + var Dataset = function() { + "use strict"; + var keys, nameGenerator; + keys = { + dataset: "tt-selectable-dataset", + val: "tt-selectable-display", + obj: "tt-selectable-object" + }; + nameGenerator = _.getIdGenerator(); + function Dataset(o, www) { + o = o || {}; + o.templates = o.templates || {}; + o.templates.notFound = o.templates.notFound || o.templates.empty; + if (!o.source) { + $.error("missing source"); + } + if (!o.node) { + $.error("missing node"); + } + if (o.name && !isValidName(o.name)) { + $.error("invalid dataset name: " + o.name); + } + www.mixin(this); + this.highlight = !!o.highlight; + this.name = _.toStr(o.name || nameGenerator()); + this.limit = o.limit || 5; + this.displayFn = getDisplayFn(o.display || o.displayKey); + this.templates = getTemplates(o.templates, this.displayFn); + this.source = o.source.__ttAdapter ? o.source.__ttAdapter() : o.source; + this.async = _.isUndefined(o.async) ? this.source.length > 2 : !!o.async; + this._resetLastSuggestion(); + this.$el = $(o.node).attr("role", "presentation").addClass(this.classes.dataset).addClass(this.classes.dataset + "-" + this.name); + } + Dataset.extractData = function extractData(el) { + var $el = $(el); + if ($el.data(keys.obj)) { + return { + dataset: $el.data(keys.dataset) || "", + val: $el.data(keys.val) || "", + obj: $el.data(keys.obj) || null + }; + } + return null; + }; + _.mixin(Dataset.prototype, EventEmitter, { + _overwrite: function overwrite(query, suggestions) { + suggestions = suggestions || []; + if (suggestions.length) { + this._renderSuggestions(query, suggestions); + } else if (this.async && this.templates.pending) { + this._renderPending(query); + } else if (!this.async && this.templates.notFound) { + this._renderNotFound(query); + } else { + this._empty(); + } + this.trigger("rendered", suggestions, false, this.name); + }, + _append: function append(query, suggestions) { + suggestions = suggestions || []; + if (suggestions.length && this.$lastSuggestion.length) { + this._appendSuggestions(query, suggestions); + } else if (suggestions.length) { + this._renderSuggestions(query, suggestions); + } else if (!this.$lastSuggestion.length && this.templates.notFound) { + this._renderNotFound(query); + } + this.trigger("rendered", suggestions, true, this.name); + }, + _renderSuggestions: function renderSuggestions(query, suggestions) { + var $fragment; + $fragment = this._getSuggestionsFragment(query, suggestions); + this.$lastSuggestion = $fragment.children().last(); + this.$el.html($fragment).prepend(this._getHeader(query, suggestions)).append(this._getFooter(query, suggestions)); + }, + _appendSuggestions: function appendSuggestions(query, suggestions) { + var $fragment, $lastSuggestion; + $fragment = this._getSuggestionsFragment(query, suggestions); + $lastSuggestion = $fragment.children().last(); + this.$lastSuggestion.after($fragment); + this.$lastSuggestion = $lastSuggestion; + }, + _renderPending: function renderPending(query) { + var template = this.templates.pending; + this._resetLastSuggestion(); + template && this.$el.html(template({ + query: query, + dataset: this.name + })); + }, + _renderNotFound: function renderNotFound(query) { + var template = this.templates.notFound; + this._resetLastSuggestion(); + template && this.$el.html(template({ + query: query, + dataset: this.name + })); + }, + _empty: function empty() { + this.$el.empty(); + this._resetLastSuggestion(); + }, + _getSuggestionsFragment: function getSuggestionsFragment(query, suggestions) { + var that = this, fragment; + fragment = document.createDocumentFragment(); + _.each(suggestions, function getSuggestionNode(suggestion) { + var $el, context; + context = that._injectQuery(query, suggestion); + $el = $(that.templates.suggestion(context)).data(keys.dataset, that.name).data(keys.obj, suggestion).data(keys.val, that.displayFn(suggestion)).addClass(that.classes.suggestion + " " + that.classes.selectable); + fragment.appendChild($el[0]); + }); + this.highlight && highlight({ + className: this.classes.highlight, + node: fragment, + pattern: query + }); + return $(fragment); + }, + _getFooter: function getFooter(query, suggestions) { + return this.templates.footer ? this.templates.footer({ + query: query, + suggestions: suggestions, + dataset: this.name + }) : null; + }, + _getHeader: function getHeader(query, suggestions) { + return this.templates.header ? this.templates.header({ + query: query, + suggestions: suggestions, + dataset: this.name + }) : null; + }, + _resetLastSuggestion: function resetLastSuggestion() { + this.$lastSuggestion = $(); + }, + _injectQuery: function injectQuery(query, obj) { + return _.isObject(obj) ? _.mixin({ + _query: query + }, obj) : obj; + }, + update: function update(query) { + var that = this, canceled = false, syncCalled = false, rendered = 0; + this.cancel(); + this.cancel = function cancel() { + canceled = true; + that.cancel = $.noop; + that.async && that.trigger("asyncCanceled", query, that.name); + }; + this.source(query, sync, async); + !syncCalled && sync([]); + function sync(suggestions) { + if (syncCalled) { + return; + } + syncCalled = true; + suggestions = (suggestions || []).slice(0, that.limit); + rendered = suggestions.length; + that._overwrite(query, suggestions); + if (rendered < that.limit && that.async) { + that.trigger("asyncRequested", query, that.name); + } + } + function async(suggestions) { + suggestions = suggestions || []; + if (!canceled && rendered < that.limit) { + that.cancel = $.noop; + var idx = Math.abs(rendered - that.limit); + rendered += idx; + that._append(query, suggestions.slice(0, idx)); + that.async && that.trigger("asyncReceived", query, that.name); + } + } + }, + cancel: $.noop, + clear: function clear() { + this._empty(); + this.cancel(); + this.trigger("cleared"); + }, + isEmpty: function isEmpty() { + return this.$el.is(":empty"); + }, + destroy: function destroy() { + this.$el = $("
"); + } + }); + return Dataset; + function getDisplayFn(display) { + display = display || _.stringify; + return _.isFunction(display) ? display : displayFn; + function displayFn(obj) { + return obj[display]; + } + } + function getTemplates(templates, displayFn) { + return { + notFound: templates.notFound && _.templatify(templates.notFound), + pending: templates.pending && _.templatify(templates.pending), + header: templates.header && _.templatify(templates.header), + footer: templates.footer && _.templatify(templates.footer), + suggestion: templates.suggestion ? userSuggestionTemplate : suggestionTemplate + }; + function userSuggestionTemplate(context) { + var template = templates.suggestion; + return $(template(context)).attr("id", _.guid()); + } + function suggestionTemplate(context) { + return $('
').attr("id", _.guid()).text(displayFn(context)); + } + } + function isValidName(str) { + return /^[_a-zA-Z0-9-]+$/.test(str); + } + }(); + var Menu = function() { + "use strict"; + function Menu(o, www) { + var that = this; + o = o || {}; + if (!o.node) { + $.error("node is required"); + } + www.mixin(this); + this.$node = $(o.node); + this.query = null; + this.datasets = _.map(o.datasets, initializeDataset); + function initializeDataset(oDataset) { + var node = that.$node.find(oDataset.node).first(); + oDataset.node = node.length ? node : $("
").appendTo(that.$node); + return new Dataset(oDataset, www); + } + } + _.mixin(Menu.prototype, EventEmitter, { + _onSelectableClick: function onSelectableClick($e) { + this.trigger("selectableClicked", $($e.currentTarget)); + }, + _onRendered: function onRendered(type, dataset, suggestions, async) { + this.$node.toggleClass(this.classes.empty, this._allDatasetsEmpty()); + this.trigger("datasetRendered", dataset, suggestions, async); + }, + _onCleared: function onCleared() { + this.$node.toggleClass(this.classes.empty, this._allDatasetsEmpty()); + this.trigger("datasetCleared"); + }, + _propagate: function propagate() { + this.trigger.apply(this, arguments); + }, + _allDatasetsEmpty: function allDatasetsEmpty() { + return _.every(this.datasets, _.bind(function isDatasetEmpty(dataset) { + var isEmpty = dataset.isEmpty(); + this.$node.attr("aria-expanded", !isEmpty); + return isEmpty; + }, this)); + }, + _getSelectables: function getSelectables() { + return this.$node.find(this.selectors.selectable); + }, + _removeCursor: function _removeCursor() { + var $selectable = this.getActiveSelectable(); + $selectable && $selectable.removeClass(this.classes.cursor); + }, + _ensureVisible: function ensureVisible($el) { + var elTop, elBottom, nodeScrollTop, nodeHeight; + elTop = $el.position().top; + elBottom = elTop + $el.outerHeight(true); + nodeScrollTop = this.$node.scrollTop(); + nodeHeight = this.$node.height() + parseInt(this.$node.css("paddingTop"), 10) + parseInt(this.$node.css("paddingBottom"), 10); + if (elTop < 0) { + this.$node.scrollTop(nodeScrollTop + elTop); + } else if (nodeHeight < elBottom) { + this.$node.scrollTop(nodeScrollTop + (elBottom - nodeHeight)); + } + }, + bind: function() { + var that = this, onSelectableClick; + onSelectableClick = _.bind(this._onSelectableClick, this); + this.$node.on("click.tt", this.selectors.selectable, onSelectableClick); + this.$node.on("mouseover", this.selectors.selectable, function() { + that.setCursor($(this)); + }); + this.$node.on("mouseleave", function() { + that._removeCursor(); + }); + _.each(this.datasets, function(dataset) { + dataset.onSync("asyncRequested", that._propagate, that).onSync("asyncCanceled", that._propagate, that).onSync("asyncReceived", that._propagate, that).onSync("rendered", that._onRendered, that).onSync("cleared", that._onCleared, that); + }); + return this; + }, + isOpen: function isOpen() { + return this.$node.hasClass(this.classes.open); + }, + open: function open() { + this.$node.scrollTop(0); + this.$node.addClass(this.classes.open); + }, + close: function close() { + this.$node.attr("aria-expanded", false); + this.$node.removeClass(this.classes.open); + this._removeCursor(); + }, + setLanguageDirection: function setLanguageDirection(dir) { + this.$node.attr("dir", dir); + }, + selectableRelativeToCursor: function selectableRelativeToCursor(delta) { + var $selectables, $oldCursor, oldIndex, newIndex; + $oldCursor = this.getActiveSelectable(); + $selectables = this._getSelectables(); + oldIndex = $oldCursor ? $selectables.index($oldCursor) : -1; + newIndex = oldIndex + delta; + newIndex = (newIndex + 1) % ($selectables.length + 1) - 1; + newIndex = newIndex < -1 ? $selectables.length - 1 : newIndex; + return newIndex === -1 ? null : $selectables.eq(newIndex); + }, + setCursor: function setCursor($selectable) { + this._removeCursor(); + if ($selectable = $selectable && $selectable.first()) { + $selectable.addClass(this.classes.cursor); + this._ensureVisible($selectable); + } + }, + getSelectableData: function getSelectableData($el) { + return $el && $el.length ? Dataset.extractData($el) : null; + }, + getActiveSelectable: function getActiveSelectable() { + var $selectable = this._getSelectables().filter(this.selectors.cursor).first(); + return $selectable.length ? $selectable : null; + }, + getTopSelectable: function getTopSelectable() { + var $selectable = this._getSelectables().first(); + return $selectable.length ? $selectable : null; + }, + update: function update(query) { + var isValidUpdate = query !== this.query; + if (isValidUpdate) { + this.query = query; + _.each(this.datasets, updateDataset); + } + return isValidUpdate; + function updateDataset(dataset) { + dataset.update(query); + } + }, + empty: function empty() { + _.each(this.datasets, clearDataset); + this.query = null; + this.$node.addClass(this.classes.empty); + function clearDataset(dataset) { + dataset.clear(); + } + }, + destroy: function destroy() { + this.$node.off(".tt"); + this.$node = $("
"); + _.each(this.datasets, destroyDataset); + function destroyDataset(dataset) { + dataset.destroy(); + } + } + }); + return Menu; + }(); + var Status = function() { + "use strict"; + function Status(options) { + this.$el = $("", { + role: "status", + "aria-live": "polite" + }).css({ + position: "absolute", + padding: "0", + border: "0", + height: "1px", + width: "1px", + "margin-bottom": "-1px", + "margin-right": "-1px", + overflow: "hidden", + clip: "rect(0 0 0 0)", + "white-space": "nowrap" + }); + options.$input.after(this.$el); + _.each(options.menu.datasets, _.bind(function(dataset) { + if (dataset.onSync) { + dataset.onSync("rendered", _.bind(this.update, this)); + dataset.onSync("cleared", _.bind(this.cleared, this)); + } + }, this)); + } + _.mixin(Status.prototype, { + update: function update(event, suggestions) { + var length = suggestions.length; + var words; + if (length === 1) { + words = { + result: "result", + is: "is" + }; + } else { + words = { + result: "results", + is: "are" + }; + } + this.$el.text(length + " " + words.result + " " + words.is + " available, use up and down arrow keys to navigate."); + }, + cleared: function() { + this.$el.text(""); + } + }); + return Status; + }(); + var DefaultMenu = function() { + "use strict"; + var s = Menu.prototype; + function DefaultMenu() { + Menu.apply(this, [].slice.call(arguments, 0)); + } + _.mixin(DefaultMenu.prototype, Menu.prototype, { + open: function open() { + !this._allDatasetsEmpty() && this._show(); + return s.open.apply(this, [].slice.call(arguments, 0)); + }, + close: function close() { + this._hide(); + return s.close.apply(this, [].slice.call(arguments, 0)); + }, + _onRendered: function onRendered() { + if (this._allDatasetsEmpty()) { + this._hide(); + } else { + this.isOpen() && this._show(); + } + return s._onRendered.apply(this, [].slice.call(arguments, 0)); + }, + _onCleared: function onCleared() { + if (this._allDatasetsEmpty()) { + this._hide(); + } else { + this.isOpen() && this._show(); + } + return s._onCleared.apply(this, [].slice.call(arguments, 0)); + }, + setLanguageDirection: function setLanguageDirection(dir) { + this.$node.css(dir === "ltr" ? this.css.ltr : this.css.rtl); + return s.setLanguageDirection.apply(this, [].slice.call(arguments, 0)); + }, + _hide: function hide() { + this.$node.hide(); + }, + _show: function show() { + this.$node.css("display", "block"); + } + }); + return DefaultMenu; + }(); + var Typeahead = function() { + "use strict"; + function Typeahead(o, www) { + var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged; + o = o || {}; + if (!o.input) { + $.error("missing input"); + } + if (!o.menu) { + $.error("missing menu"); + } + if (!o.eventBus) { + $.error("missing event bus"); + } + www.mixin(this); + this.eventBus = o.eventBus; + this.minLength = _.isNumber(o.minLength) ? o.minLength : 1; + this.input = o.input; + this.menu = o.menu; + this.enabled = true; + this.autoselect = !!o.autoselect; + this.active = false; + this.input.hasFocus() && this.activate(); + this.dir = this.input.getLangDir(); + this._hacks(); + this.menu.bind().onSync("selectableClicked", this._onSelectableClicked, this).onSync("asyncRequested", this._onAsyncRequested, this).onSync("asyncCanceled", this._onAsyncCanceled, this).onSync("asyncReceived", this._onAsyncReceived, this).onSync("datasetRendered", this._onDatasetRendered, this).onSync("datasetCleared", this._onDatasetCleared, this); + onFocused = c(this, "activate", "open", "_onFocused"); + onBlurred = c(this, "deactivate", "_onBlurred"); + onEnterKeyed = c(this, "isActive", "isOpen", "_onEnterKeyed"); + onTabKeyed = c(this, "isActive", "isOpen", "_onTabKeyed"); + onEscKeyed = c(this, "isActive", "_onEscKeyed"); + onUpKeyed = c(this, "isActive", "open", "_onUpKeyed"); + onDownKeyed = c(this, "isActive", "open", "_onDownKeyed"); + onLeftKeyed = c(this, "isActive", "isOpen", "_onLeftKeyed"); + onRightKeyed = c(this, "isActive", "isOpen", "_onRightKeyed"); + onQueryChanged = c(this, "_openIfActive", "_onQueryChanged"); + onWhitespaceChanged = c(this, "_openIfActive", "_onWhitespaceChanged"); + this.input.bind().onSync("focused", onFocused, this).onSync("blurred", onBlurred, this).onSync("enterKeyed", onEnterKeyed, this).onSync("tabKeyed", onTabKeyed, this).onSync("escKeyed", onEscKeyed, this).onSync("upKeyed", onUpKeyed, this).onSync("downKeyed", onDownKeyed, this).onSync("leftKeyed", onLeftKeyed, this).onSync("rightKeyed", onRightKeyed, this).onSync("queryChanged", onQueryChanged, this).onSync("whitespaceChanged", onWhitespaceChanged, this).onSync("langDirChanged", this._onLangDirChanged, this); + } + _.mixin(Typeahead.prototype, { + _hacks: function hacks() { + var $input, $menu; + $input = this.input.$input || $("
"); + $menu = this.menu.$node || $("
"); + $input.on("blur.tt", function($e) { + var active, isActive, hasActive; + active = document.activeElement; + isActive = $menu.is(active); + hasActive = $menu.has(active).length > 0; + if (_.isMsie() && (isActive || hasActive)) { + $e.preventDefault(); + $e.stopImmediatePropagation(); + _.defer(function() { + $input.focus(); + }); + } + }); + $menu.on("mousedown.tt", function($e) { + $e.preventDefault(); + }); + }, + _onSelectableClicked: function onSelectableClicked(type, $el) { + this.select($el); + }, + _onDatasetCleared: function onDatasetCleared() { + this._updateHint(); + }, + _onDatasetRendered: function onDatasetRendered(type, suggestions, async, dataset) { + this._updateHint(); + if (this.autoselect) { + var cursorClass = this.selectors.cursor.substr(1); + this.menu.$node.find(this.selectors.suggestion).first().addClass(cursorClass); + } + this.eventBus.trigger("render", suggestions, async, dataset); + }, + _onAsyncRequested: function onAsyncRequested(type, dataset, query) { + this.eventBus.trigger("asyncrequest", query, dataset); + }, + _onAsyncCanceled: function onAsyncCanceled(type, dataset, query) { + this.eventBus.trigger("asynccancel", query, dataset); + }, + _onAsyncReceived: function onAsyncReceived(type, dataset, query) { + this.eventBus.trigger("asyncreceive", query, dataset); + }, + _onFocused: function onFocused() { + this._minLengthMet() && this.menu.update(this.input.getQuery()); + }, + _onBlurred: function onBlurred() { + if (this.input.hasQueryChangedSinceLastFocus()) { + this.eventBus.trigger("change", this.input.getQuery()); + } + }, + _onEnterKeyed: function onEnterKeyed(type, $e) { + var $selectable; + if ($selectable = this.menu.getActiveSelectable()) { + if (this.select($selectable)) { + $e.preventDefault(); + $e.stopPropagation(); + } + } else if (this.autoselect) { + if (this.select(this.menu.getTopSelectable())) { + $e.preventDefault(); + $e.stopPropagation(); + } + } + }, + _onTabKeyed: function onTabKeyed(type, $e) { + var $selectable; + if ($selectable = this.menu.getActiveSelectable()) { + this.select($selectable) && $e.preventDefault(); + } else if (this.autoselect) { + if ($selectable = this.menu.getTopSelectable()) { + this.autocomplete($selectable) && $e.preventDefault(); + } + } + }, + _onEscKeyed: function onEscKeyed() { + this.close(); + }, + _onUpKeyed: function onUpKeyed() { + this.moveCursor(-1); + }, + _onDownKeyed: function onDownKeyed() { + this.moveCursor(+1); + }, + _onLeftKeyed: function onLeftKeyed() { + if (this.dir === "rtl" && this.input.isCursorAtEnd()) { + this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable()); + } + }, + _onRightKeyed: function onRightKeyed() { + if (this.dir === "ltr" && this.input.isCursorAtEnd()) { + this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable()); + } + }, + _onQueryChanged: function onQueryChanged(e, query) { + this._minLengthMet(query) ? this.menu.update(query) : this.menu.empty(); + }, + _onWhitespaceChanged: function onWhitespaceChanged() { + this._updateHint(); + }, + _onLangDirChanged: function onLangDirChanged(e, dir) { + if (this.dir !== dir) { + this.dir = dir; + this.menu.setLanguageDirection(dir); + } + }, + _openIfActive: function openIfActive() { + this.isActive() && this.open(); + }, + _minLengthMet: function minLengthMet(query) { + query = _.isString(query) ? query : this.input.getQuery() || ""; + return query.length >= this.minLength; + }, + _updateHint: function updateHint() { + var $selectable, data, val, query, escapedQuery, frontMatchRegEx, match; + $selectable = this.menu.getTopSelectable(); + data = this.menu.getSelectableData($selectable); + val = this.input.getInputValue(); + if (data && !_.isBlankString(val) && !this.input.hasOverflow()) { + query = Input.normalizeQuery(val); + escapedQuery = _.escapeRegExChars(query); + frontMatchRegEx = new RegExp("^(?:" + escapedQuery + ")(.+$)", "i"); + match = frontMatchRegEx.exec(data.val); + match && this.input.setHint(val + match[1]); + } else { + this.input.clearHint(); + } + }, + isEnabled: function isEnabled() { + return this.enabled; + }, + enable: function enable() { + this.enabled = true; + }, + disable: function disable() { + this.enabled = false; + }, + isActive: function isActive() { + return this.active; + }, + activate: function activate() { + if (this.isActive()) { + return true; + } else if (!this.isEnabled() || this.eventBus.before("active")) { + return false; + } else { + this.active = true; + this.eventBus.trigger("active"); + return true; + } + }, + deactivate: function deactivate() { + if (!this.isActive()) { + return true; + } else if (this.eventBus.before("idle")) { + return false; + } else { + this.active = false; + this.close(); + this.eventBus.trigger("idle"); + return true; + } + }, + isOpen: function isOpen() { + return this.menu.isOpen(); + }, + open: function open() { + if (!this.isOpen() && !this.eventBus.before("open")) { + this.input.setAriaExpanded(true); + this.menu.open(); + this._updateHint(); + this.eventBus.trigger("open"); + } + return this.isOpen(); + }, + close: function close() { + if (this.isOpen() && !this.eventBus.before("close")) { + this.input.setAriaExpanded(false); + this.menu.close(); + this.input.clearHint(); + this.input.resetInputValue(); + this.eventBus.trigger("close"); + } + return !this.isOpen(); + }, + setVal: function setVal(val) { + this.input.setQuery(_.toStr(val)); + }, + getVal: function getVal() { + return this.input.getQuery(); + }, + select: function select($selectable) { + var data = this.menu.getSelectableData($selectable); + if (data && !this.eventBus.before("select", data.obj, data.dataset)) { + this.input.setQuery(data.val, true); + this.eventBus.trigger("select", data.obj, data.dataset); + this.close(); + return true; + } + return false; + }, + autocomplete: function autocomplete($selectable) { + var query, data, isValid; + query = this.input.getQuery(); + data = this.menu.getSelectableData($selectable); + isValid = data && query !== data.val; + if (isValid && !this.eventBus.before("autocomplete", data.obj, data.dataset)) { + this.input.setQuery(data.val); + this.eventBus.trigger("autocomplete", data.obj, data.dataset); + return true; + } + return false; + }, + moveCursor: function moveCursor(delta) { + var query, $candidate, data, suggestion, datasetName, cancelMove, id; + query = this.input.getQuery(); + $candidate = this.menu.selectableRelativeToCursor(delta); + data = this.menu.getSelectableData($candidate); + suggestion = data ? data.obj : null; + datasetName = data ? data.dataset : null; + id = $candidate ? $candidate.attr("id") : null; + this.input.trigger("cursorchange", id); + cancelMove = this._minLengthMet() && this.menu.update(query); + if (!cancelMove && !this.eventBus.before("cursorchange", suggestion, datasetName)) { + this.menu.setCursor($candidate); + if (data) { + if (typeof data.val === "string") { + this.input.setInputValue(data.val); + } + } else { + this.input.resetInputValue(); + this._updateHint(); + } + this.eventBus.trigger("cursorchange", suggestion, datasetName); + return true; + } + return false; + }, + destroy: function destroy() { + this.input.destroy(); + this.menu.destroy(); + } + }); + return Typeahead; + function c(ctx) { + var methods = [].slice.call(arguments, 1); + return function() { + var args = [].slice.call(arguments); + _.each(methods, function(method) { + return ctx[method].apply(ctx, args); + }); + }; + } + }(); + (function() { + "use strict"; + var old, keys, methods; + old = $.fn.typeahead; + keys = { + www: "tt-www", + attrs: "tt-attrs", + typeahead: "tt-typeahead" + }; + methods = { + initialize: function initialize(o, datasets) { + var www; + datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1); + o = o || {}; + www = WWW(o.classNames); + return this.each(attach); + function attach() { + var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu, eventBus, input, menu, status, typeahead, MenuConstructor; + _.each(datasets, function(d) { + d.highlight = !!o.highlight; + }); + $input = $(this); + $wrapper = $(www.html.wrapper); + $hint = $elOrNull(o.hint); + $menu = $elOrNull(o.menu); + defaultHint = o.hint !== false && !$hint; + defaultMenu = o.menu !== false && !$menu; + defaultHint && ($hint = buildHintFromInput($input, www)); + defaultMenu && ($menu = $(www.html.menu).css(www.css.menu)); + $hint && $hint.val(""); + $input = prepInput($input, www); + if (defaultHint || defaultMenu) { + $wrapper.css(www.css.wrapper); + $input.css(defaultHint ? www.css.input : www.css.inputWithNoHint); + $input.wrap($wrapper).parent().prepend(defaultHint ? $hint : null).append(defaultMenu ? $menu : null); + } + MenuConstructor = defaultMenu ? DefaultMenu : Menu; + eventBus = new EventBus({ + el: $input + }); + input = new Input({ + hint: $hint, + input: $input, + menu: $menu + }, www); + menu = new MenuConstructor({ + node: $menu, + datasets: datasets + }, www); + status = new Status({ + $input: $input, + menu: menu + }); + typeahead = new Typeahead({ + input: input, + menu: menu, + eventBus: eventBus, + minLength: o.minLength, + autoselect: o.autoselect + }, www); + $input.data(keys.www, www); + $input.data(keys.typeahead, typeahead); + } + }, + isEnabled: function isEnabled() { + var enabled; + ttEach(this.first(), function(t) { + enabled = t.isEnabled(); + }); + return enabled; + }, + enable: function enable() { + ttEach(this, function(t) { + t.enable(); + }); + return this; + }, + disable: function disable() { + ttEach(this, function(t) { + t.disable(); + }); + return this; + }, + isActive: function isActive() { + var active; + ttEach(this.first(), function(t) { + active = t.isActive(); + }); + return active; + }, + activate: function activate() { + ttEach(this, function(t) { + t.activate(); + }); + return this; + }, + deactivate: function deactivate() { + ttEach(this, function(t) { + t.deactivate(); + }); + return this; + }, + isOpen: function isOpen() { + var open; + ttEach(this.first(), function(t) { + open = t.isOpen(); + }); + return open; + }, + open: function open() { + ttEach(this, function(t) { + t.open(); + }); + return this; + }, + close: function close() { + ttEach(this, function(t) { + t.close(); + }); + return this; + }, + select: function select(el) { + var success = false, $el = $(el); + ttEach(this.first(), function(t) { + success = t.select($el); + }); + return success; + }, + autocomplete: function autocomplete(el) { + var success = false, $el = $(el); + ttEach(this.first(), function(t) { + success = t.autocomplete($el); + }); + return success; + }, + moveCursor: function moveCursoe(delta) { + var success = false; + ttEach(this.first(), function(t) { + success = t.moveCursor(delta); + }); + return success; + }, + val: function val(newVal) { + var query; + if (!arguments.length) { + ttEach(this.first(), function(t) { + query = t.getVal(); + }); + return query; + } else { + ttEach(this, function(t) { + t.setVal(_.toStr(newVal)); + }); + return this; + } + }, + destroy: function destroy() { + ttEach(this, function(typeahead, $input) { + revert($input); + typeahead.destroy(); + }); + return this; + } + }; + $.fn.typeahead = function(method) { + if (methods[method]) { + return methods[method].apply(this, [].slice.call(arguments, 1)); + } else { + return methods.initialize.apply(this, arguments); + } + }; + $.fn.typeahead.noConflict = function noConflict() { + $.fn.typeahead = old; + return this; + }; + function ttEach($els, fn) { + $els.each(function() { + var $input = $(this), typeahead; + (typeahead = $input.data(keys.typeahead)) && fn(typeahead, $input); + }); + } + function buildHintFromInput($input, www) { + return $input.clone().addClass(www.classes.hint).removeData().css(www.css.hint).css(getBackgroundStyles($input)).prop({ + readonly: true, + required: false + }).removeAttr("id name placeholder").removeClass("required").attr({ + spellcheck: "false", + tabindex: -1 + }); + } + function prepInput($input, www) { + $input.data(keys.attrs, { + dir: $input.attr("dir"), + autocomplete: $input.attr("autocomplete"), + spellcheck: $input.attr("spellcheck"), + style: $input.attr("style") + }); + $input.addClass(www.classes.input).attr({ + spellcheck: false + }); + try { + !$input.attr("dir") && $input.attr("dir", "auto"); + } catch (e) {} + return $input; + } + function getBackgroundStyles($el) { + return { + backgroundAttachment: $el.css("background-attachment"), + backgroundClip: $el.css("background-clip"), + backgroundColor: $el.css("background-color"), + backgroundImage: $el.css("background-image"), + backgroundOrigin: $el.css("background-origin"), + backgroundPosition: $el.css("background-position"), + backgroundRepeat: $el.css("background-repeat"), + backgroundSize: $el.css("background-size") + }; + } + function revert($input) { + var www, $wrapper; + www = $input.data(keys.www); + $wrapper = $input.parent().filter(www.selectors.wrapper); + _.each($input.data(keys.attrs), function(val, key) { + _.isUndefined(val) ? $input.removeAttr(key) : $input.attr(key, val); + }); + $input.removeData(keys.typeahead).removeData(keys.www).removeData(keys.attr).removeClass(www.classes.input); + if ($wrapper.length) { + $input.detach().insertAfter($wrapper); + $wrapper.remove(); + } + } + function $elOrNull(obj) { + var isValid, $el; + isValid = _.isJQuery(obj) || _.isElement(obj); + $el = isValid ? $(obj).first() : []; + return $el.length ? $el : null; + } + })(); +}); \ No newline at end of file diff --git a/docs/5.16/search.json b/docs/5.16/search.json new file mode 100644 index 000000000..d7091f8c2 --- /dev/null +++ b/docs/5.16/search.json @@ -0,0 +1 @@ +{"Typealiases.html#/s:4GRDB16SQLiteConnectiona":{"name":"SQLiteConnection","abstract":"

A raw SQLite connection, suitable for the SQLite C API.

"},"Typealiases.html#/s:4GRDB15SQLiteStatementa":{"name":"SQLiteStatement","abstract":"

A raw SQLite statement, suitable for the SQLite C API.

"},"Typealiases.html#/s:4GRDB15SelectStatementa":{"name":"SelectStatement","abstract":"

Undocumented

"},"Typealiases.html#/s:4GRDB15UpdateStatementa":{"name":"UpdateStatement","abstract":"

Undocumented

"},"Typealiases.html#/FTS5TokenCallback":{"name":"FTS5TokenCallback","abstract":"

A low-level SQLite function that lets FTS5Tokenizer notify tokens.

"},"Typealiases.html#/FTS5WrapperTokenCallback":{"name":"FTS5WrapperTokenCallback","abstract":"

A function that lets FTS5WrapperTokenizer notify tokens.

"},"Typealiases.html#/s:4GRDB10SQLLiterala":{"name":"SQLLiteral","abstract":"

Undocumented

"},"Typealiases.html#/s:4GRDB9SQLiterala":{"name":"SQLiteral","abstract":"

Undocumented

"},"Typealiases.html#/s:4GRDB28SQLAssociativeBinaryOperatora":{"name":"SQLAssociativeBinaryOperator","abstract":"

Undocumented

"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV19requiresWriteAccessSbvp":{"name":"requiresWriteAccess","abstract":"

Default is false. Set this property to true when the observation","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV6shared2in10scheduling6extentAA06SharedbC0Cy0B0QzGAA14DatabaseReader_p_AA0bC9SchedulerCAA0hbC6ExtentOtF":{"name":"shared(in:scheduling:extent:)","abstract":"

Returns a shared value observation that shares a single underlying","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV5start2in10scheduling7onError0G6ChangeAA19DatabaseCancellable_pAA0J6Reader_p_AA0bC9SchedulerCys0H0_pcy0B0QzctF":{"name":"start(in:scheduling:onError:onChange:)","abstract":"

Starts the value observation in the provided database reader (such as","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV12handleEvents9willStart0F5Fetch0F11TrackRegion17databaseDidChange010didReceiveB00N4Fail0N6CancelACyAA0B8ReducersO5TraceVy_xGGyycSg_ARyAA08DatabaseJ0VcSgARy0B0QzcSgys5Error_pcSgARtF":{"name":"handleEvents(willStart:willFetch:willTrackRegion:databaseDidChange:didReceiveValue:didFail:didCancel:)","abstract":"

Performs the specified closures when ValueObservation events occur.

","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV5print_2toACyAA0B8ReducersO5TraceVy_xGGSS_s16TextOutputStream_pSgtF":{"name":"print(_:to:)","abstract":"

Prints log messages for all ValueObservation events.

","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV9publisher2in10schedulingAA18DatabasePublishersO0B0Vy_AIQzGAA0G6Reader_p_AA0bC9SchedulerCtF":{"name":"publisher(in:scheduling:)","abstract":"

Creates a publisher which tracks changes in database values.

","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationV3mapyACyAA0B8ReducersO3MapVy_xqd__GGqd__0B0QzclF":{"name":"map(_:)","abstract":"

Returns a ValueObservation which notifies the results of calling the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE22trackingConstantRegionyACyAE5FetchVy_qd__GGqd__AA8DatabaseCKclFZ":{"name":"trackingConstantRegion(_:)","abstract":"

Creates an optimized ValueObservation that notifies the values","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE8tracking6region5fetchACyAE5FetchVy_qd__GGAA25DatabaseRegionConvertible_pd_qd__AA0J0CKctlFZ":{"name":"tracking(region:fetch:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE8tracking7regions5fetchACyAE5FetchVy_qd__GGSayAA25DatabaseRegionConvertible_pG_qd__AA0J0CKctlFZ":{"name":"tracking(regions:fetch:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE8trackingyACyAE5FetchVy_qd__GGqd__AA8DatabaseCKclFZ":{"name":"tracking(_:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVA2A0B8ReducersO4AutoORszrlE21trackingVaryingRegionyACyAE5FetchVy_qd__GGqd__AA8DatabaseCKclFZ":{"name":"trackingVaryingRegion(_:)","abstract":"

Creates a ValueObservation that notifies the values returned by the","parent_name":"ValueObservation"},"Structs/ValueObservation.html#/s:4GRDB16ValueObservationVAASQ0B0RpzrlE16removeDuplicatesACyAA0B8ReducersO06RemoveE0Vy_xGGyF":{"name":"removeDuplicates()","abstract":"

Returns a ValueObservation which filters out consecutive equal values.

","parent_name":"ValueObservation"},"Structs/Inflections.html#/s:4GRDB11InflectionsVACycfc":{"name":"init()","abstract":"

Undocumented

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV6plural_7options_ySS_So26NSRegularExpressionOptionsVSStF":{"name":"plural(_:options:_:)","abstract":"

Appends a pluralization rule.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV8singular_7options_ySS_So26NSRegularExpressionOptionsVSStF":{"name":"singular(_:options:_:)","abstract":"

Appends a singularization rule.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV16uncountableWordsyySaySSGF":{"name":"uncountableWords(_:)","abstract":"

Appends uncountable words.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV15irregularSuffixyySS_SStF":{"name":"irregularSuffix(_:_:)","abstract":"

Appends an irregular singular/plural pair.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV9pluralizeyS2SF":{"name":"pluralize(_:)","abstract":"

Returns a pluralized string.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV11singularizeyS2SF":{"name":"singularize(_:)","abstract":"

Returns a singularized string.

","parent_name":"Inflections"},"Structs/Inflections.html#/s:4GRDB11InflectionsV7defaultACvpZ":{"name":"default","abstract":"

The default inflections

","parent_name":"Inflections"},"Structs/PersistenceConflictPolicy.html#/s:4GRDB25PersistenceConflictPolicyV27conflictResolutionForInsertAA8DatabaseC0cF0Ovp":{"name":"conflictResolutionForInsert","abstract":"

The conflict resolution algorithm for insertions

","parent_name":"PersistenceConflictPolicy"},"Structs/PersistenceConflictPolicy.html#/s:4GRDB25PersistenceConflictPolicyV27conflictResolutionForUpdateAA8DatabaseC0cF0Ovp":{"name":"conflictResolutionForUpdate","abstract":"

The conflict resolution algorithm for updates

","parent_name":"PersistenceConflictPolicy"},"Structs/PersistenceConflictPolicy.html#/s:4GRDB25PersistenceConflictPolicyV6insert6updateAcA8DatabaseC0C10ResolutionO_AItcfc":{"name":"init(insert:update:)","abstract":"

Creates a policy

","parent_name":"PersistenceConflictPolicy"},"Structs/Table.html#/s:4GRDB5TableV9tableNameSSvp":{"name":"tableName","abstract":"

The table name

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVyACyxGSScfc":{"name":"init(_:)","abstract":"

Create a Table

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB25DatabaseRegionConvertibleP08databaseC0yAA0bC0VAA0B0CKF":{"name":"databaseRegion(_:)","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV3allAA21QueryInterfaceRequestVyxGyF":{"name":"all()","abstract":"

Creates a request for all rows of the table.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV4noneAA21QueryInterfaceRequestVyxGyF":{"name":"none()","abstract":"

Creates a request which fetches no row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6selectyAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tF":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6selectyAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pGF":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtF":{"name":"select(sql:arguments:)","abstract":"

Creates a request which selects sql.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tF":{"name":"select(literal:)","abstract":"

Creates a request which selects an SQL literal.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select_2asAA21QueryInterfaceRequestVyqd__GSayAA13SQLSelectable_pG_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select_2asAA21QueryInterfaceRequestVyqd__GAA13SQLSelectable_pd_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select3sql9arguments2asAA21QueryInterfaceRequestVyqd__GSS_AA18StatementArgumentsVqd__mtlF":{"name":"select(sql:arguments:as:)","abstract":"

Creates a request which selects sql, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6select7literal2asAA21QueryInterfaceRequestVyqd__GAA3SQLV_qd__mtlF":{"name":"select(literal:as:)","abstract":"

Creates a request which selects an SQL literal, and fetches values of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pG_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filteryAA21QueryInterfaceRequestVyxGAA22SQLSpecificExpressible_pF":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter3keyAA21QueryInterfaceRequestVyxGqd__Sg_tAA24DatabaseValueConvertibleRd__lF":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter4keysAA21QueryInterfaceRequestVyxGqd___tSTRd__AA24DatabaseValueConvertible7ElementRpd__lF":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter3keyAA21QueryInterfaceRequestVyxGSDySSAA24DatabaseValueConvertible_pSgGSg_tF":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter4keysAA21QueryInterfaceRequestVyxGSaySDySSAA24DatabaseValueConvertible_pSgGG_tF":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtF":{"name":"filter(sql:arguments:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6filter7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tF":{"name":"filter(literal:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5orderyAA21QueryInterfaceRequestVyxGAA15SQLOrderingTerm_pd_tF":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5orderyAA21QueryInterfaceRequestVyxGSayAA15SQLOrderingTerm_pGF":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV17orderByPrimaryKeyAA21QueryInterfaceRequestVyxGyF":{"name":"orderByPrimaryKey()","abstract":"

Creates a request sorted by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5order3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtF":{"name":"order(sql:arguments:)","abstract":"

Creates a request sorted according to sql.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5order7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tF":{"name":"order(literal:)","abstract":"

Creates a request sorted according to an SQL literal.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV5limit_6offsetAA21QueryInterfaceRequestVyxGSi_SiSgtF":{"name":"limit(_:offset:)","abstract":"

Creates a request which fetches limit rows, starting at","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7aliasedyAA21QueryInterfaceRequestVyxGAA0B5AliasCF":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV4withyAA21QueryInterfaceRequestVyxGAA06CommonB10ExpressionVyqd__GlF":{"name":"with(_:)","abstract":"

Returns a request which embeds the common table expression.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","abstract":"

The number of rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9belongsTo_3key5usingAA07BelongsD11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAA0B6RecordRd__lF":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7hasMany_3key5usingAA03HasD11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAA0B6RecordRd__lF":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination type,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6hasOne_3key5usingAA03HasD11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAA0B6RecordRd__lF":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination type,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9belongsTo_3key5usingAA07BelongsD11AssociationVyxqd__GACyqd__G_SSSgAA10ForeignKeyVSgtlF":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7hasMany_3key5usingAA03HasD11AssociationVyxqd__GACyqd__G_SSSgAA10ForeignKeyVSgtlF":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination table,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6hasOne_3key5usingAA03HasD11AssociationVyxqd__GACyqd__G_SSSgAA10ForeignKeyVSgtlF":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination table,","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV11association2to2onAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_AA14SQLExpressible_pAA0B5AliasC_AOtctlF":{"name":"association(to:on:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV11association2toAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_tlF":{"name":"association(to:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7hasMany_7through5using3keyAA03HasD18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginkL0Qyd__RszAA0J0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lF":{"name":"hasMany(_:through:using:key:)","abstract":"

Creates a “Has Many Through” association between Self and the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6hasOne_7through5using3keyAA03HasD18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginkL0Qyd__RszAA0j2ToD0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lF":{"name":"hasOne(_:through:using:key:)","abstract":"

Creates a “Has One Through” association between Self and the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9including3allAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA17AssociationToManyRd__lF":{"name":"including(all:)","abstract":"

Creates a request that prefetches an association.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9including8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"including(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9including8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"including(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7joining8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"joining(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV7joining8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"joining(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated12withOptionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"annotated(withOptional:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated12withRequiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lF":{"name":"annotated(withRequired:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGd_tF":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9annotated4withAA21QueryInterfaceRequestVyxGSayAA20AssociationAggregateVyxGG_tF":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6havingyAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGF":{"name":"having(_:)","abstract":"

Creates a request with the provided aggregate predicate.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteAllySiAA8DatabaseCKF":{"name":"deleteAll(_:)","abstract":"

Deletes all rows; returns the number of deleted rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6exists_3keySbAA8DatabaseC_qd__tKAA0E16ValueConvertibleRd__lF":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV6exists_3keySbAA8DatabaseC_SDySSAA0E16ValueConvertible_pSgGtKF":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this unique key (primary key or any key","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteAll_4keysSiAA8DatabaseC_qd__tKSTRd__AA0F16ValueConvertible7ElementRpd__lF":{"name":"deleteAll(_:keys:)","abstract":"

Delete rows identified by their primary keys; returns the number of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteOne_3keySbAA8DatabaseC_qd__SgtKAA0F16ValueConvertibleRd__lF":{"name":"deleteOne(_:key:)","abstract":"

Delete a row, identified by its primary key; returns whether a","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteAll_4keysSiAA8DatabaseC_SaySDySSAA0F16ValueConvertible_pSgGGtKF":{"name":"deleteAll(_:keys:)","abstract":"

Delete rows identified by the provided unique keys (primary key or","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9deleteOne_3keySbAA8DatabaseC_SDySSAA0F16ValueConvertible_pSgGtKF":{"name":"deleteOne(_:key:)","abstract":"

Delete a row, identified by a unique key (the primary key or any key","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9updateAll_10onConflict_SiAA8DatabaseC_AG0F10ResolutionOSgSayAA16ColumnAssignmentVGtKF":{"name":"updateAll(_:onConflict:_:)","abstract":"

Updates all rows; returns the number of updated rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableV9updateAll_10onConflict__SiAA8DatabaseC_AG0F10ResolutionOSgAA16ColumnAssignmentVALdtKF":{"name":"updateAll(_:onConflict:_:_:)","abstract":"

Updates all rows; returns the number of updated rows.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlEyACyAEGSScfc":{"name":"init(_:)","abstract":"

Create a Table of Row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE6filter2idAA21QueryInterfaceRequestVyxGAG_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__7ElementQyd__AGRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE06selectG0AA21QueryInterfaceRequestVyAGGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE6filter2idAA21QueryInterfaceRequestVyxGAK_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__AaH7ElementRpd__AkRRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE06selectF0AA21QueryInterfaceRequestVyAKGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzlE11fetchCursoryAA0dF0CyxGAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all records fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzlE8fetchAllySayxGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of all records fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzlE8fetchOneyxSgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first found record.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A15FetchableRecordRzSHRzlE8fetchSetyShyxGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of all records fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE11fetchCursoryAA0cE0CAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all rows fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE8fetchAllySayAEGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of all rows fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE8fetchOneyAESgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first found row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A3RowCRszlE8fetchSetyShyAEGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of all rows fetched from the database.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzlE11fetchCursoryAA0cdG0CyxGAA0C0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzlE8fetchAllySayxGAA0C0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzlE8fetchOneyxSgAA0C0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzSHRzlE8fetchSetyShyxGAA0C0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzlE11fetchCursoryAA08NullableefJ0CyAGGAA0E0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzlE8fetchAllySayAGSgGAA0E0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzlE8fetchOneyAGSgAA0E0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzSHAGRQlE8fetchSetyShyAGSgGAA0E0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzlE11fetchCursoryAA04FastcdI0CyxGAA0C0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzlE8fetchAllySayxGAA0C0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzlE8fetchOneyxSgAA0C0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A24DatabaseValueConvertibleRzAA015StatementColumnE0RzSHRzlE8fetchSetyShyxGAA0C0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQlE11fetchCursoryAA012FastNullableefL0CyAGGAA0E0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQlE8fetchAllySayAGSgGAA0E0CKF":{"name":"fetchAll(_:)","abstract":"

An array of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQlE8fetchOneyAGSgAA0E0CKF":{"name":"fetchOne(_:)","abstract":"

The value from the leftmost column of the first row.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVA2A17_OptionalProtocolRzAA24DatabaseValueConvertible7WrappedRpzAA015StatementColumnG0AGRQSHAGRQlE8fetchSetyShyAGSgGAA0E0CKF":{"name":"fetchSet(_:)","abstract":"

A set of all values fetched from the leftmost column.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE6exists_2idSbAA0D0C_AGtKF":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE6exists_2idSbAA0G0C_AKtKF":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE9deleteAll_3idsSiAA0D0C_qd__tKSlRd__7ElementQyd__AGRSlF":{"name":"deleteAll(_:ids:)","abstract":"

Delete rows identified by their primary keys; returns the number of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE9deleteOne_2idSbAA0D0C_AGtKF":{"name":"deleteOne(_:id:)","abstract":"

Delete a row, identified by its primary key; returns whether a","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE9deleteAll_3idsSiAA0G0C_qd__tKSlRd__AaH7ElementRpd__AkQRSlF":{"name":"deleteAll(_:ids:)","abstract":"

Delete rows identified by their primary keys; returns the number of","parent_name":"Table"},"Structs/Table.html#/s:4GRDB5TableVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE9deleteOne_2idSbAA0G0C_AKtKF":{"name":"deleteOne(_:id:)","abstract":"

Delete a row, identified by its primary key; returns whether a","parent_name":"Table"},"Structs/SQLSubquery.html#/s:4GRDB11SQLSubqueryV11sqlSubqueryACvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"SQLSubquery"},"Structs/AllColumns.html#/s:4GRDB10AllColumnsVACycfc":{"name":"init()","abstract":"

The * selection.

","parent_name":"AllColumns"},"Structs/AllColumns.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"AllColumns"},"Structs/SQLSelection.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"SQLSelection"},"Structs/PersistenceContainer.html#/s:4GRDB20PersistenceContainerVyAA24DatabaseValueConvertible_pSgSScip":{"name":"subscript(_:)","abstract":"

Accesses the value associated with the given column.

","parent_name":"PersistenceContainer"},"Structs/PersistenceContainer.html#/s:4GRDB20PersistenceContainerVyAA24DatabaseValueConvertible_pSgxcAA16ColumnExpressionRzluip":{"name":"subscript(_:)","abstract":"

Accesses the value associated with the given column.

","parent_name":"PersistenceContainer"},"Structs/SQLOrdering.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","parent_name":"SQLOrdering"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV3addAEvpZ":{"name":"add","abstract":"

The + binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV8multiplyAEvpZ":{"name":"multiply","abstract":"

The * binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV3andAEvpZ":{"name":"and","abstract":"

The AND binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV2orAEvpZ":{"name":"or","abstract":"

The OR binary operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html#/s:4GRDB13SQLExpressionV25AssociativeBinaryOperatorV6concatAEvpZ":{"name":"concat","abstract":"

The || string concatenation operator

","parent_name":"AssociativeBinaryOperator"},"Structs/SQLExpression/AssociativeBinaryOperator.html":{"name":"AssociativeBinaryOperator","abstract":"

AssociativeBinaryOperator is an associative binary operator,","parent_name":"SQLExpression"},"Structs/SQLExpression.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"SQLExpression"},"Structs/Column.html#/s:4GRDB6ColumnV5rowIDACvpZ":{"name":"rowID","abstract":"

The hidden rowID column

","parent_name":"Column"},"Structs/Column.html#/s:4GRDB6ColumnV4nameSSvp":{"name":"name","abstract":"

The name of the column

","parent_name":"Column"},"Structs/Column.html#/s:4GRDB6ColumnVyACSScfc":{"name":"init(_:)","abstract":"

Creates a column given its name.

","parent_name":"Column"},"Structs/Column.html#/s:4GRDB6ColumnVyACs9CodingKey_pcfc":{"name":"init(_:)","abstract":"

Creates a column given a CodingKey.

","parent_name":"Column"},"Structs/Column.html#/s:SQ2eeoiySbx_xtFZ":{"name":"==(_:_:)","parent_name":"Column"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6selectyACyxGSayAA13SQLSelectable_pGAA8DatabaseCKcF":{"name":"select(_:)","abstract":"

Creates a request which selects selection promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select_2asACyqd__GSayAA13SQLSelectable_pG_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select_2asACyqd__GAA13SQLSelectable_pd_qd__mtlF":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select3sql9arguments2asACyqd__GSS_AA18StatementArgumentsVqd__mtlF":{"name":"select(sql:arguments:as:)","abstract":"

Creates a request which selects sql, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6select7literal2asACyqd__GAA3SQLV_qd__mtlF":{"name":"select(literal:as:)","abstract":"

Creates a request which selects an SQL literal, and fetches values of","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9annotated4withACyxGSayAA13SQLSelectable_pGAA8DatabaseCKc_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6filteryACyxGAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV5orderyACyxGSayAA15SQLOrderingTerm_pGAA8DatabaseCKcF":{"name":"order(_:)","abstract":"

Creates a request with the provided orderings promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV8reversedACyxGyF":{"name":"reversed()","abstract":"

Creates a request that reverses applied orderings.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9unorderedACyxGyF":{"name":"unordered()","abstract":"

Creates a request without any ordering.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV5groupyACyxGSayAA14SQLExpressible_pGAA8DatabaseCKcF":{"name":"group(_:)","abstract":"

Creates a request grouped according to expressions promise.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV6havingyACyxGAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"having(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV7aliasedyACyxGAA10TableAliasCF":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB16DerivableRequestP8distinctxyF":{"name":"distinct()","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV5limit_6offsetACyxGSi_SiSgtF":{"name":"limit(_:offset:)","abstract":"

Creates a request which fetches limit rows, starting at offset.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB16DerivableRequestP4withyxAA21CommonTableExpressionVyqd__GlF":{"name":"with(_:)","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV02asD02ofACyqd__Gqd__m_tlF":{"name":"asRequest(of:)","abstract":"

Creates a request bound to type RowDecoder.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV7isEmptyySbAA8DatabaseCKF":{"name":"isEmpty(_:)","abstract":"

Returns true if the request matches no row in the database.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9deleteAllySiAA8DatabaseCKF":{"name":"deleteAll(_:)","abstract":"

Deletes matching rows; returns the number of deleted rows.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9updateAll_10onConflict_SiAA8DatabaseC_AG0H10ResolutionOSgSayAA16ColumnAssignmentVGtKF":{"name":"updateAll(_:onConflict:_:)","abstract":"

Updates matching rows; returns the number of updated rows.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestV9updateAll_10onConflict__SiAA8DatabaseC_AG0H10ResolutionOSgAA16ColumnAssignmentVALdtKF":{"name":"updateAll(_:onConflict:_:_:)","abstract":"

Updates matching rows; returns the number of updated rows.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestVAAs12IdentifiableRzAA24DatabaseValueConvertible2IDRpzlE06selectI0ACyAGGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"QueryInterfaceRequest"},"Structs/QueryInterfaceRequest.html#/s:4GRDB21QueryInterfaceRequestVAAs12IdentifiableRzAA17_OptionalProtocol2IDRpzAA24DatabaseValueConvertibleAF_7WrappedAaEPRPzlE06selectH0ACyAKGyF":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"QueryInterfaceRequest"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9tableNameSSvp":{"name":"tableName","abstract":"

The table name of the common table expression.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9recursive5named7columns7requestACyxGSb_SSSaySSGSgqd__tcAA15SQLSubqueryableRd__lufc":{"name":"init(recursive:named:columns:request:)","abstract":"

Creates a common table expression from a request.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9recursive5named7columns3sql9argumentsACyxGSb_SSSaySSGSgSSAA18StatementArgumentsVtcfc":{"name":"init(recursive:named:columns:sql:arguments:)","abstract":"

Creates a common table expression from an SQL string and","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV9recursive5named7columns7literalACyxGSb_SSSaySSGSgAA3SQLVtcfc":{"name":"init(recursive:named:columns:literal:)","abstract":"

Creates a common table expression from an SQL literal.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV3allAA21QueryInterfaceRequestVyxGyF":{"name":"all()","abstract":"

Creates a request for all rows of the common table expression.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV8containsyAA13SQLExpressionVAA14SQLExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2to2onAA15JoinAssociationVyxqd__GACyqd__G_AA14SQLExpressible_pAA0C5AliasC_AMtctlF":{"name":"association(to:on:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2toAA15JoinAssociationVyxqd__GACyqd__G_tlF":{"name":"association(to:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2to2onAA15JoinAssociationVyxqd__Gqd__m_AA14SQLExpressible_pAA0C5AliasC_ALtctAA0C6RecordRd__lF":{"name":"association(to:on:)","abstract":"

Creates an association to a table record that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2toAA15JoinAssociationVyxqd__Gqd__m_tAA0C6RecordRd__lF":{"name":"association(to:)","abstract":"

Creates an association to a table record that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2to2onAA15JoinAssociationVyxqd__GAA0C0Vyqd__G_AA14SQLExpressible_pAA0C5AliasC_AOtctlF":{"name":"association(to:on:)","abstract":"

Creates an association to a table that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionV11association2toAA15JoinAssociationVyxqd__GAA0C0Vyqd__G_tlF":{"name":"association(to:)","abstract":"

Creates an association to a table that you can join","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionVA2A3RowCRszlE9recursive5named7columns7requestACyAEGSb_SSSaySSGSgqd__tcAA15SQLSubqueryableRd__lufc":{"name":"init(recursive:named:columns:request:)","abstract":"

Creates a common table expression from a request.

","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionVA2A3RowCRszlE9recursive5named7columns3sql9argumentsACyAEGSb_SSSaySSGSgSSAA18StatementArgumentsVtcfc":{"name":"init(recursive:named:columns:sql:arguments:)","abstract":"

Creates a common table expression from an SQL string and","parent_name":"CommonTableExpression"},"Structs/CommonTableExpression.html#/s:4GRDB21CommonTableExpressionVA2A3RowCRszlE9recursive5named7columns7literalACyAEGSb_SSSaySSGSgAA3SQLVtcfc":{"name":"init(recursive:named:columns:literal:)","abstract":"

Creates a common table expression from an SQL literal.

","parent_name":"CommonTableExpression"},"Structs/AssociationAggregate.html#/s:4GRDB20AssociationAggregateV6forKeyyACyxGSSF":{"name":"forKey(_:)","abstract":"

Returns an aggregate that is selected in a column with the given name.

","parent_name":"AssociationAggregate"},"Structs/AssociationAggregate.html#/s:4GRDB20AssociationAggregateV6forKeyyACyxGs06CodingE0_pF":{"name":"forKey(_:)","abstract":"

Returns an aggregate that is selected in a column named like the given","parent_name":"AssociationAggregate"},"Structs/ForeignKey.html#/s:4GRDB10ForeignKeyV_2toACSaySSG_AESgtcfc":{"name":"init(_:to:)","abstract":"

Creates a ForeignKey intended to define a record association.

","parent_name":"ForeignKey"},"Structs/ForeignKey.html#/s:4GRDB10ForeignKeyV_2toACSayAA16ColumnExpression_pG_AFSgtcfc":{"name":"init(_:to:)","abstract":"

Creates a ForeignKey intended to define a record association.

","parent_name":"ForeignKey"},"Structs/DatabaseMigrator/ForeignKeyChecks.html#/s:4GRDB16DatabaseMigratorV16ForeignKeyChecksO8deferredyA2EmF":{"name":"deferred","abstract":"

The migration runs with disabled foreign keys, until foreign keys","parent_name":"ForeignKeyChecks"},"Structs/DatabaseMigrator/ForeignKeyChecks.html#/s:4GRDB16DatabaseMigratorV16ForeignKeyChecksO9immediateyA2EmF":{"name":"immediate","abstract":"

The migration runs for foreign keys on.

","parent_name":"ForeignKeyChecks"},"Structs/DatabaseMigrator/ForeignKeyChecks.html":{"name":"ForeignKeyChecks","abstract":"

Controls how migrations handle foreign keys constraints.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV05eraseB14OnSchemaChangeSbvp":{"name":"eraseDatabaseOnSchemaChange","abstract":"

When the eraseDatabaseOnSchemaChange flag is true, the migrator will","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorVACycfc":{"name":"init()","abstract":"

A new migrator.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV33disablingDeferredForeignKeyChecksACyF":{"name":"disablingDeferredForeignKeyChecks()","abstract":"

Returns a migrator that will not perform deferred foreign key checks in","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV17registerMigration_16foreignKeyChecks7migrateySS_AC07ForeigngH0OyAA0B0CKctF":{"name":"registerMigration(_:foreignKeyChecks:migrate:)","abstract":"

Registers a migration.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV7migrateyyAA0B6Writer_pKF":{"name":"migrate(_:)","abstract":"

Iterate migrations in the same order as they were registered. If a","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV7migrate_4upToyAA0B6Writer_p_SStKF":{"name":"migrate(_:upTo:)","abstract":"

Iterate migrations in the same order as they were registered, up to the","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV12asyncMigrate_10completionyAA0B6Writer_p_yAA0B0C_s5Error_pSgtctF":{"name":"asyncMigrate(_:completion:)","abstract":"

Iterate migrations in the same order as they were registered. If a","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV10migrationsSaySSGvp":{"name":"migrations","abstract":"

The list of registered migration identifiers, in the same order as they","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV17appliedMigrationsySaySSGAA0B0CKF":{"name":"appliedMigrations(_:)","abstract":"

Returns the identifiers of registered and applied migrations, in the","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV18appliedIdentifiersyShySSGAA0B0CKF":{"name":"appliedIdentifiers(_:)","abstract":"

Returns the applied migration identifiers, even unregistered ones.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV19completedMigrationsySaySSGAA0B0CKF":{"name":"completedMigrations(_:)","abstract":"

Returns the identifiers of completed migrations, of which all previous","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV22hasCompletedMigrationsySbAA0B0CKF":{"name":"hasCompletedMigrations(_:)","abstract":"

Returns true if all migrations are applied.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV17hasBeenSupersededySbAA0B0CKF":{"name":"hasBeenSuperseded(_:)","abstract":"

Returns whether database contains unknown migration","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV16migratePublisheryAA0B10PublishersO7MigrateVAA0B6Writer_pF":{"name":"migratePublisher(_:)","abstract":"

Returns a Publisher that asynchronously migrates a database.

","parent_name":"DatabaseMigrator"},"Structs/DatabaseMigrator.html#/s:4GRDB16DatabaseMigratorV16migratePublisher_9receiveOnAA0B10PublishersO7MigrateVAA0B6Writer_p_xt7Combine9SchedulerRzlF":{"name":"migratePublisher(_:receiveOn:)","abstract":"

Returns a Publisher that asynchronously migrates a database.

","parent_name":"DatabaseMigrator"},"Structs/FTS5TokenFlags.html#/rawValue":{"name":"rawValue","parent_name":"FTS5TokenFlags"},"Structs/FTS5TokenFlags.html#/init(rawValue:)":{"name":"init(rawValue:)","parent_name":"FTS5TokenFlags"},"Structs/FTS5TokenFlags.html#/colocated":{"name":"colocated","abstract":"

FTS5_TOKEN_COLOCATED

","parent_name":"FTS5TokenFlags"},"Structs/FTS5TokenizerDescriptor.html#/components":{"name":"components","abstract":"

The tokenizer components

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/init(components:)":{"name":"init(components:)","abstract":"

Creates an FTS5 tokenizer descriptor.

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/ascii(separators:tokenCharacters:)":{"name":"ascii(separators:tokenCharacters:)","abstract":"

The “ascii” tokenizer

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/porter(wrapping:)":{"name":"porter(wrapping:)","abstract":"

See https://www.sqlite.org/fts5.html#porter_tokenizer

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5TokenizerDescriptor.html#/unicode61(diacritics:separators:tokenCharacters:)":{"name":"unicode61(diacritics:separators:tokenCharacters:)","abstract":"

An “unicode61” tokenizer

","parent_name":"FTS5TokenizerDescriptor"},"Structs/FTS5Tokenization.html#/rawValue":{"name":"rawValue","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/init(rawValue:)":{"name":"init(rawValue:)","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/query":{"name":"query","abstract":"

FTS5_TOKENIZE_QUERY

","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/prefix":{"name":"prefix","abstract":"

FTS5_TOKENIZE_PREFIX

","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/document":{"name":"document","abstract":"

FTS5_TOKENIZE_DOCUMENT

","parent_name":"FTS5Tokenization"},"Structs/FTS5Tokenization.html#/aux":{"name":"aux","abstract":"

FTS5_TOKENIZE_AUX

","parent_name":"FTS5Tokenization"},"Structs/FTS5Pattern.html#/rawPattern":{"name":"rawPattern","abstract":"

The raw pattern string. Guaranteed to be a valid FTS5 pattern.

","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingAnyTokenIn:)":{"name":"init(matchingAnyTokenIn:)","abstract":"

Creates a pattern that matches any token found in the input string;","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingAllTokensIn:)":{"name":"init(matchingAllTokensIn:)","abstract":"

Creates a pattern that matches all tokens found in the input string;","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingAllPrefixesIn:)":{"name":"init(matchingAllPrefixesIn:)","abstract":"

Creates a pattern that matches all token prefixes found in the input","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingPhrase:)":{"name":"init(matchingPhrase:)","abstract":"

Creates a pattern that matches a contiguous string; returns nil if no","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/init(matchingPrefixPhrase:)":{"name":"init(matchingPrefixPhrase:)","abstract":"

Creates a pattern that matches the prefix of an indexed document;","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/databaseValue":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"FTS5Pattern"},"Structs/FTS5Pattern.html#/fromDatabaseValue(_:)":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an FTS5Pattern initialized from dbValue, if it","parent_name":"FTS5Pattern"},"Structs/FTS5/Diacritics.html#/keep":{"name":"keep","abstract":"

Do not remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS5/Diacritics.html#/removeLegacy":{"name":"removeLegacy","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS5/Diacritics.html#/remove":{"name":"remove","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS5/Diacritics.html":{"name":"Diacritics","abstract":"

Options for Latin script characters. Matches the raw “remove_diacritics”","parent_name":"FTS5"},"Structs/FTS5.html#/init()":{"name":"init()","abstract":"

Creates a FTS5 module suitable for the Database","parent_name":"FTS5"},"Structs/FTS5.html#/moduleName":{"name":"moduleName","abstract":"

The virtual table module name

","parent_name":"FTS5"},"Structs/FTS5.html#/makeTableDefinition()":{"name":"makeTableDefinition()","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS5"},"Structs/FTS5.html#/makeTableDefinition(configuration:)":{"name":"makeTableDefinition(configuration:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS5"},"Structs/FTS5.html#/moduleArguments(for:in:)":{"name":"moduleArguments(for:in:)","abstract":"

Don’t use this method.

","parent_name":"FTS5"},"Structs/FTS5.html#/database(_:didCreate:using:)":{"name":"database(_:didCreate:using:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS5"},"Structs/FTS4.html#/s:4GRDB4FTS4VACycfc":{"name":"init()","abstract":"

Creates a FTS4 module suitable for the Database","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V10moduleNameSSvp":{"name":"moduleName","abstract":"

The virtual table module name

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V19makeTableDefinitionAA0bdE0CyF":{"name":"makeTableDefinition()","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V19makeTableDefinition13configurationAA0bdE0CAA07VirtualD13ConfigurationV_tF":{"name":"makeTableDefinition(configuration:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V15moduleArguments3for2inSaySSGAA0B15TableDefinitionC_AA8DatabaseCtF":{"name":"moduleArguments(for:in:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS4.html#/s:4GRDB4FTS4V8database_9didCreate5usingyAA8DatabaseC_SSAA0B15TableDefinitionCtKF":{"name":"database(_:didCreate:using:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS4"},"Structs/FTS3TokenizerDescriptor.html#/s:4GRDB23FTS3TokenizerDescriptorV6simpleACvpZ":{"name":"simple","abstract":"

The “simple” tokenizer.

","parent_name":"FTS3TokenizerDescriptor"},"Structs/FTS3TokenizerDescriptor.html#/s:4GRDB23FTS3TokenizerDescriptorV6porterACvpZ":{"name":"porter","abstract":"

The “porter” tokenizer.

","parent_name":"FTS3TokenizerDescriptor"},"Structs/FTS3TokenizerDescriptor.html#/s:4GRDB23FTS3TokenizerDescriptorV9unicode6110diacritics10separators15tokenCharactersAcA0B0V10DiacriticsO_ShySJGALtFZ":{"name":"unicode61(diacritics:separators:tokenCharacters:)","abstract":"

The “unicode61” tokenizer.

","parent_name":"FTS3TokenizerDescriptor"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV03rawC0SSvp":{"name":"rawPattern","abstract":"

The raw pattern string. Guaranteed to be a valid FTS3/4 pattern.

","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV03rawC0ACSS_tKcfc":{"name":"init(rawPattern:)","abstract":"

Creates a pattern from a raw pattern string; throws DatabaseError on","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV18matchingAnyTokenInACSgSS_tcfc":{"name":"init(matchingAnyTokenIn:)","abstract":"

Creates a pattern that matches any token found in the input string;","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV19matchingAllTokensInACSgSS_tcfc":{"name":"init(matchingAllTokensIn:)","abstract":"

Creates a pattern that matches all tokens found in the input string;","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV21matchingAllPrefixesInACSgSS_tcfc":{"name":"init(matchingAllPrefixesIn:)","abstract":"

Creates a pattern that matches all token prefixes found in the input","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV14matchingPhraseACSgSS_tcfc":{"name":"init(matchingPhrase:)","abstract":"

Creates a pattern that matches a contiguous string; returns nil if no","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV13databaseValueAA08DatabaseE0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"FTS3Pattern"},"Structs/FTS3Pattern.html#/s:4GRDB11FTS3PatternV17fromDatabaseValueyACSgAA0eF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an FTS3Pattern initialized from dbValue, if it contains","parent_name":"FTS3Pattern"},"Structs/FTS3/Diacritics.html#/s:4GRDB4FTS3V10DiacriticsO4keepyA2EmF":{"name":"keep","abstract":"

Do not remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html#/s:4GRDB4FTS3V10DiacriticsO12removeLegacyyA2EmF":{"name":"removeLegacy","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html#/remove":{"name":"remove","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html#/s:4GRDB4FTS3V10DiacriticsO6removeyA2EmF":{"name":"remove","abstract":"

Remove diacritics from Latin script characters. This","parent_name":"Diacritics"},"Structs/FTS3/Diacritics.html":{"name":"Diacritics","abstract":"

Options for Latin script characters. Matches the raw “remove_diacritics”","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3VACycfc":{"name":"init()","abstract":"

Creates a FTS3 module suitable for the Database","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V8tokenize_13withTokenizerSaySSGSS_AA0bE10DescriptorVtFZ":{"name":"tokenize(_:withTokenizer:)","abstract":"

Returns an array of tokens found in the string argument.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V10moduleNameSSvp":{"name":"moduleName","abstract":"

The virtual table module name

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V19makeTableDefinitionAA0bdE0CyF":{"name":"makeTableDefinition()","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V19makeTableDefinition13configurationAA0bdE0CAA07VirtualD13ConfigurationV_tF":{"name":"makeTableDefinition(configuration:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V15moduleArguments3for2inSaySSGAA0B15TableDefinitionC_AA8DatabaseCtF":{"name":"moduleArguments(for:in:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/FTS3.html#/s:4GRDB4FTS3V8database_9didCreate5usingyAA8DatabaseC_SSAA0B15TableDefinitionCtF":{"name":"database(_:didCreate:using:)","abstract":"

Reserved; part of the VirtualTableModule protocol.

","parent_name":"FTS3"},"Structs/DatabasePreUpdateEvent/Kind.html#/insert":{"name":"insert","abstract":"

SQLITE_INSERT

","parent_name":"Kind"},"Structs/DatabasePreUpdateEvent/Kind.html#/delete":{"name":"delete","abstract":"

SQLITE_DELETE

","parent_name":"Kind"},"Structs/DatabasePreUpdateEvent/Kind.html#/update":{"name":"update","abstract":"

SQLITE_UPDATE

","parent_name":"Kind"},"Structs/DatabasePreUpdateEvent/Kind.html":{"name":"Kind","abstract":"

An event kind

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/kind":{"name":"kind","abstract":"

The event kind

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/databaseName":{"name":"databaseName","abstract":"

The database name

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/tableName":{"name":"tableName","abstract":"

The table name

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/count":{"name":"count","abstract":"

The number of columns in the row that is being inserted, updated, or deleted.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/depth":{"name":"depth","abstract":"

1 for inserts, updates, or deletes invoked by top-level triggers;","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/initialRowID":{"name":"initialRowID","abstract":"

The initial rowID of the row being changed for .Update and .Delete changes,","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/finalRowID":{"name":"finalRowID","abstract":"

The final rowID of the row being changed for .Update and .Insert changes,","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/initialDatabaseValues":{"name":"initialDatabaseValues","abstract":"

The initial database values in the row.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/initialDatabaseValue(atIndex:)":{"name":"initialDatabaseValue(atIndex:)","abstract":"

Returns the initial DatabaseValue at given index.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/finalDatabaseValues":{"name":"finalDatabaseValues","abstract":"

The final database values in the row.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/finalDatabaseValue(atIndex:)":{"name":"finalDatabaseValue(atIndex:)","abstract":"

Returns the final DatabaseValue at given index.

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabasePreUpdateEvent.html#/copy()":{"name":"copy()","abstract":"

Returns an event that can be stored:

","parent_name":"DatabasePreUpdateEvent"},"Structs/DatabaseEvent/Kind.html#/s:4GRDB13DatabaseEventV4KindO6insertyA2EmF":{"name":"insert","abstract":"

SQLITE_INSERT

","parent_name":"Kind"},"Structs/DatabaseEvent/Kind.html#/s:4GRDB13DatabaseEventV4KindO6deleteyA2EmF":{"name":"delete","abstract":"

SQLITE_DELETE

","parent_name":"Kind"},"Structs/DatabaseEvent/Kind.html#/s:4GRDB13DatabaseEventV4KindO6updateyA2EmF":{"name":"update","abstract":"

SQLITE_UPDATE

","parent_name":"Kind"},"Structs/DatabaseEvent/Kind.html":{"name":"Kind","abstract":"

An event kind

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV4kindAC4KindOvp":{"name":"kind","abstract":"

The event kind

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV12databaseNameSSvp":{"name":"databaseName","abstract":"

The database name

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV9tableNameSSvp":{"name":"tableName","abstract":"

The table name

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV5rowIDs5Int64Vvp":{"name":"rowID","abstract":"

The rowID of the changed row.

","parent_name":"DatabaseEvent"},"Structs/DatabaseEvent.html#/s:4GRDB13DatabaseEventV4copyACyF":{"name":"copy()","abstract":"

Returns an event that can be stored:

","parent_name":"DatabaseEvent"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO3YMDyA2EmF":{"name":"YMD","abstract":"

The format “yyyy-MM-dd”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO6YMD_HMyA2EmF":{"name":"YMD_HM","abstract":"

The format “yyyy-MM-dd HH:mm”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO7YMD_HMSyA2EmF":{"name":"YMD_HMS","abstract":"

The format “yyyy-MM-dd HH:mm:ss”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO8YMD_HMSSyA2EmF":{"name":"YMD_HMSS","abstract":"

The format “yyyy-MM-dd HH:mm:ss.SSS”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO2HMyA2EmF":{"name":"HM","abstract":"

The format “HH:mm”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO3HMSyA2EmF":{"name":"HMS","abstract":"

The format “HH:mm:ss”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html#/s:4GRDB22DatabaseDateComponentsV6FormatO4HMSSyA2EmF":{"name":"HMSS","abstract":"

The format “HH:mm:ss.SSS”.

","parent_name":"Format"},"Structs/DatabaseDateComponents/Format.html":{"name":"Format","abstract":"

The available formats for reading and storing date components.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV04dateD010Foundation0cD0Vvp":{"name":"dateComponents","abstract":"

The date components

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV6formatAC6FormatOvp":{"name":"format","abstract":"

The database format

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV_6formatAC10Foundation0cD0V_AC6FormatOtcfc":{"name":"init(_:format:)","abstract":"

Creates a DatabaseDateComponents from a DateComponents and a format.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV15sqliteStatement5indexACSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV13databaseValueAA0bF0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV04fromB5ValueyACSgAA0bF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a DatabaseDateComponents if dbValue contains a","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV4fromACs7Decoder_p_tKcfc":{"name":"init(from:)","abstract":"

Creates a new instance by decoding from the given decoder.

","parent_name":"DatabaseDateComponents"},"Structs/DatabaseDateComponents.html#/s:4GRDB22DatabaseDateComponentsV6encode2toys7Encoder_p_tKF":{"name":"encode(to:)","abstract":"

Encodes this value into the given encoder.

","parent_name":"DatabaseDateComponents"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV7isEmptySbvp":{"name":"isEmpty","abstract":"

Undocumented

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVACycfc":{"name":"init()","abstract":"

Creates empty StatementArguments.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACxcSTRzAA24DatabaseValueConvertible_pSg7ElementRtzlufc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of optional values.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACxcSTRzAA24DatabaseValueConvertible7ElementRpzlufc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of optional values.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACSgSayypGcfc":{"name":"init(_:)","abstract":"

Creates statement arguments from any array. The result is nil unless all","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACSDySSAA24DatabaseValueConvertible_pSgGcfc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of (key, value) dictionary,","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACxcSTRzSS_AA24DatabaseValueConvertible_pSgt7ElementRtzlufc":{"name":"init(_:)","abstract":"

Creates statement arguments from a sequence of (key, value) pairs, such","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsVyACSgSDys11AnyHashableVypGcfc":{"name":"init(_:)","abstract":"

Creates statement arguments from [AnyHashable: Any].

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV6append10contentsOfSDySSAA13DatabaseValueVGAC_tF":{"name":"append(contentsOf:)","abstract":"

Extends statement arguments with other arguments.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV1poiyA2C_ACtFZ":{"name":"+(_:_:)","abstract":"

Creates a new StatementArguments by extending the left-hand size","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV2apoiyA2C_ACtFZ":{"name":"&+(_:_:)","abstract":"

Creates a new StatementArguments by extending the left-hand size","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV2peoiyyACz_ACtFZ":{"name":"+=(_:_:)","abstract":"

Extends the left-hand size arguments with the right-hand side arguments.

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV12arrayLiteralAcA24DatabaseValueConvertible_pSgd_tcfc":{"name":"init(arrayLiteral:)","abstract":"

Returns a StatementArguments from an array literal:

","parent_name":"StatementArguments"},"Structs/StatementArguments.html#/s:4GRDB18StatementArgumentsV17dictionaryLiteralACSS_AA24DatabaseValueConvertible_pSgtd_tcfc":{"name":"init(dictionaryLiteral:)","abstract":"

Returns a StatementArguments from a dictionary literal:

","parent_name":"StatementArguments"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV7adapterAA10RowAdapter_pSgvp":{"name":"adapter","abstract":"

The request adapter

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV3sql9arguments7adapter6cachedACyxGSS_AA18StatementArgumentsVAA10RowAdapter_pSgSbtcfc":{"name":"init(sql:arguments:adapter:cached:)","abstract":"

Creates a request from an SQL string, optional arguments, and","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV7literal7adapter6cachedACyxGAA3SQLV_AA10RowAdapter_pSgSbtcfc":{"name":"init(literal:adapter:cached:)","abstract":"

Creates a request from an SQL literal, and optional row adapter.

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestV20unicodeScalarLiteralACyxGSS_tcfc":{"name":"init(unicodeScalarLiteral:)","abstract":"

:nodoc

","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestVA2A3RowCRszlE3sql9arguments7adapter6cachedACyAEGSS_AA18StatementArgumentsVAA0C7Adapter_pSgSbtcfc":{"name":"init(sql:arguments:adapter:cached:)","abstract":"

Creates a request from an SQL string, optional arguments, and","parent_name":"SQLRequest"},"Structs/SQLRequest.html#/s:4GRDB10SQLRequestVA2A3RowCRszlE7literal7adapter6cachedACyAEGAA3SQLV_AA0C7Adapter_pSgSbtcfc":{"name":"init(literal:adapter:cached:)","abstract":"

Creates a request from an SQL literal, and optional row adapter.

","parent_name":"SQLRequest"},"Structs/SQL.html#/s:4GRDB3SQLV3sql9argumentsACSS_AA18StatementArgumentsVtcfc":{"name":"init(sql:arguments:)","abstract":"

Creates an SQL literal from a plain SQL string, and","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLVyAcA22SQLSpecificExpressible_pcfc":{"name":"init(_:)","abstract":"

Creates an SQL literal from an SQL expression.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV7isEmptySbvp":{"name":"isEmpty","abstract":"

Returns true if this literal generates an empty SQL string

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV5buildySS3sql_AA18StatementArgumentsV9argumentstAA8DatabaseCKF":{"name":"build(_:)","abstract":"

Turn a SQL literal into raw SQL and arguments.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV1poiyA2C_ACtFZ":{"name":"+(_:_:)","abstract":"

Returns the SQL literal produced by the concatenation of two literals.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV2peoiyyACz_ACtFZ":{"name":"+=(_:_:)","abstract":"

Appends an SQL literal to the receiver.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV6append7literalyAC_tF":{"name":"append(literal:)","abstract":"

Appends an SQL literal to the receiver.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV6append3sql9argumentsySS_AA18StatementArgumentsVtF":{"name":"append(sql:arguments:)","abstract":"

Appends a plain SQL string to the receiver, and eventual arguments.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","abstract":"

Creates a literal SQL expression.

","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","parent_name":"SQL"},"Structs/SQL.html#/s:4GRDB3SQLV20unicodeScalarLiteralACSS_tcfc":{"name":"init(unicodeScalarLiteral:)","abstract":"

:nodoc

","parent_name":"SQL"},"Structs/RenameColumnAdapter.html#/s:4GRDB19RenameColumnAdapterVyACS2Sccfc":{"name":"init(_:)","abstract":"

Creates a RenameColumnAdapter adapter that renames columns according to the","parent_name":"RenameColumnAdapter"},"Structs/ScopeAdapter.html#/s:4GRDB12ScopeAdapterVyACSDySSAA03RowC0_pGcfc":{"name":"init(_:)","abstract":"

Creates an adapter that preserves row contents and add scoped rows.

","parent_name":"ScopeAdapter"},"Structs/ScopeAdapter.html#/s:4GRDB12ScopeAdapterV4base6scopesAcA03RowC0_p_SDySSAaF_pGtcfc":{"name":"init(base:scopes:)","abstract":"

Creates an adapter based on the base adapter, and add scoped rows.

","parent_name":"ScopeAdapter"},"Structs/RangeRowAdapter.html#/s:4GRDB15RangeRowAdapterVyACSnySiGcfc":{"name":"init(_:)","abstract":"

Creates a RangeRowAdapter that only exposes a range of columns.

","parent_name":"RangeRowAdapter"},"Structs/RangeRowAdapter.html#/s:4GRDB15RangeRowAdapterVyACSNySiGcfc":{"name":"init(_:)","abstract":"

Creates a RangeRowAdapter that only exposes a range of columns.

","parent_name":"RangeRowAdapter"},"Structs/SuffixRowAdapter.html#/s:4GRDB16SuffixRowAdapterV9fromIndexACSi_tcfc":{"name":"init(fromIndex:)","abstract":"

Creates a SuffixRowAdapter that hides all columns before the","parent_name":"SuffixRowAdapter"},"Structs/ColumnMapping.html#/s:4GRDB13ColumnMappingVyACSDyS2SGcfc":{"name":"init(_:)","abstract":"

Creates a ColumnMapping with a dictionary from mapped column names to","parent_name":"ColumnMapping"},"Structs/EmptyRowAdapter.html#/s:4GRDB15EmptyRowAdapterVACycfc":{"name":"init()","abstract":"

Creates an EmptyRowAdapter

","parent_name":"EmptyRowAdapter"},"Structs/AnyFetchRequest.html#/s:4GRDB15AnyFetchRequestV02asD02ofACyqd__Gqd__m_tlF":{"name":"asRequest(of:)","abstract":"

Creates a request bound to type RowDecoder.

","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB15AnyFetchRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"AnyFetchRequest"},"Structs/AnyFetchRequest.html#/s:4GRDB15AnyFetchRequestVyACyxGqd__c10RowDecoderQyd__RszAA0cD0Rd__lufc":{"name":"init(_:)","abstract":"

Creates a request that wraps and forwards operations to request.

","parent_name":"AnyFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB12FetchRequestP10RowDecoderQa":{"name":"RowDecoder","parent_name":"AdaptedFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB19AdaptedFetchRequestV11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"AdaptedFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","parent_name":"AdaptedFetchRequest"},"Structs/AdaptedFetchRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","parent_name":"AdaptedFetchRequest"},"Structs/PreparedRequest.html#/s:4GRDB15PreparedRequestV9statementAA9StatementCvp":{"name":"statement","abstract":"

A prepared statement

","parent_name":"PreparedRequest"},"Structs/PreparedRequest.html#/s:4GRDB15PreparedRequestV7adapterAA10RowAdapter_pSgvp":{"name":"adapter","abstract":"

An eventual adapter for rows fetched by the select statement

","parent_name":"PreparedRequest"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO4nullyA2EmF":{"name":"null","abstract":"

The NULL storage class.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO5int64yAEs5Int64VcAEmF":{"name":"int64(_:)","abstract":"

The INTEGER storage class, wrapping an Int64.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO6doubleyAESdcAEmF":{"name":"double(_:)","abstract":"

The REAL storage class, wrapping a Double.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO6stringyAESScAEmF":{"name":"string(_:)","abstract":"

The TEXT storage class, wrapping a String.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO4blobyAE10Foundation4DataVcAEmF":{"name":"blob(_:)","abstract":"

The BLOB storage class, wrapping Data.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO5valueAA0bC11Convertible_pSgvp":{"name":"value","abstract":"

Returns Int64, Double, String, Data or nil.

","parent_name":"Storage"},"Structs/DatabaseValue/Storage.html#/s:4GRDB13DatabaseValueV7StorageO2eeoiySbAE_AEtFZ":{"name":"==(_:_:)","abstract":"

Return true if the storages are identical.

","parent_name":"Storage"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV7storageAC7StorageOvp":{"name":"storage","abstract":"

The SQLite storage

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV4nullACvpZ":{"name":"null","abstract":"

The NULL DatabaseValue.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue/Storage.html":{"name":"Storage","abstract":"

An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV5valueACSgyp_tcfc":{"name":"init(value:)","abstract":"

Creates a DatabaseValue from Any.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV6isNullSbvp":{"name":"isNull","abstract":"

Returns true if databaseValue is NULL.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV2eeoiySbAC_ACtFZ":{"name":"==(_:_:)","abstract":"

Returns whether two DatabaseValues are equal.

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV08databaseC0ACvp":{"name":"databaseValue","abstract":"

Returns self

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB13DatabaseValueV04frombC0yACSgACFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns the database value

","parent_name":"DatabaseValue"},"Structs/DatabaseValue.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"DatabaseValue"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV6extentAA0B0C011TransactionD6ExtentOvp":{"name":"extent","abstract":"

The extent of the database observation. The default is","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV8trackingAcA0bC11Convertible_pd_tcfc":{"name":"init(tracking:)","abstract":"

Creates a DatabaseRegionObservation which observes regions, and","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV8trackingACSayAA0bC11Convertible_pG_tcfc":{"name":"init(tracking:)","abstract":"

Creates a DatabaseRegionObservation which observes regions, and","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV5start2in8onChangeAA19TransactionObserver_pAA0B6Writer_p_yAA0B0CctKF":{"name":"start(in:onChange:)","abstract":"

Starts the observation in the provided database writer (such as","parent_name":"DatabaseRegionObservation"},"Structs/DatabaseRegionObservation.html#/s:4GRDB25DatabaseRegionObservationV9publisher2inAA0B10PublishersO0bC0VAA0B6Writer_p_tF":{"name":"publisher(in:)","abstract":"

Returns a publisher that tracks changes in a database region.

","parent_name":"DatabaseRegionObservation"},"Structs/AnyDatabaseRegionConvertible.html#/s:4GRDB28AnyDatabaseRegionConvertibleVyAcA0cD0VAA0C0CKccfc":{"name":"init(_:)","abstract":"

Undocumented

","parent_name":"AnyDatabaseRegionConvertible"},"Structs/AnyDatabaseRegionConvertible.html#/s:4GRDB28AnyDatabaseRegionConvertibleVyAcA0cdE0_pcfc":{"name":"init(_:)","abstract":"

Undocumented

","parent_name":"AnyDatabaseRegionConvertible"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV7isEmptySbvp":{"name":"isEmpty","abstract":"

Returns whether the region is empty.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV06isFullB0Sbvp":{"name":"isFullDatabase","abstract":"

Returns whether the region covers the full database: all columns and all","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV04fullB0ACvpZ":{"name":"fullDatabase","abstract":"

The region that covers the full database: all columns and all rows","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionVACycfc":{"name":"init()","abstract":"

Creates an empty database region.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV5tableACSS_tcfc":{"name":"init(table:)","abstract":"

Creates a region that spans all rows and columns of a database table.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV5unionyA2CF":{"name":"union(_:)","abstract":"

Returns the union of this region and the given one.

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV9formUnionyyACF":{"name":"formUnion(_:)","abstract":"

Inserts the given region into this region

","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified14byEventsOfKindSbAA0b5EventI0O_tF":{"name":"isModified(byEventsOfKind:)","abstract":"

Returns whether the content in the region would be impacted if the","parent_name":"DatabaseRegion"},"Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF":{"name":"isModified(by:)","abstract":"

Returns whether the content in the region is impacted by this event.

","parent_name":"DatabaseRegion"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV10resultCodeAA06ResultE0Vvp":{"name":"resultCode","abstract":"

The SQLite error code (see","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18extendedResultCodeAA0eF0Vvp":{"name":"extendedResultCode","abstract":"

The SQLite extended error code (see","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV7messageSSSgvp":{"name":"message","abstract":"

The SQLite error message.

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV3sqlSSSgvp":{"name":"sql","abstract":"

The SQL query that yielded the error (if relevant).

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV9argumentsAA18StatementArgumentsVSgvp":{"name":"arguments","abstract":"

The query arguments that yielded the error (if relevant).

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV10resultCode7message3sql9argumentsAcA06ResultE0V_SSSgAjA18StatementArgumentsVSgtcfc":{"name":"init(resultCode:message:sql:arguments:)","abstract":"

Creates a Database Error

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV9SQLITE_OKAA10ResultCodeVvpZ":{"name":"SQLITE_OK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_ERRORAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_INTERNALAA10ResultCodeVvpZ":{"name":"SQLITE_INTERNAL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_PERMAA10ResultCodeVvpZ":{"name":"SQLITE_PERM","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_ABORTAA10ResultCodeVvpZ":{"name":"SQLITE_ABORT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_BUSYAA10ResultCodeVvpZ":{"name":"SQLITE_BUSY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_LOCKEDAA10ResultCodeVvpZ":{"name":"SQLITE_LOCKED","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_NOMEMAA10ResultCodeVvpZ":{"name":"SQLITE_NOMEM","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_READONLYAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV16SQLITE_INTERRUPTAA10ResultCodeVvpZ":{"name":"SQLITE_INTERRUPT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_IOERRAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV14SQLITE_CORRUPTAA10ResultCodeVvpZ":{"name":"SQLITE_CORRUPT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_NOTFOUNDAA10ResultCodeVvpZ":{"name":"SQLITE_NOTFOUND","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_FULLAA10ResultCodeVvpZ":{"name":"SQLITE_FULL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_CANTOPENAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_PROTOCOLAA10ResultCodeVvpZ":{"name":"SQLITE_PROTOCOL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_EMPTYAA10ResultCodeVvpZ":{"name":"SQLITE_EMPTY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_SCHEMAAA10ResultCodeVvpZ":{"name":"SQLITE_SCHEMA","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_TOOBIGAA10ResultCodeVvpZ":{"name":"SQLITE_TOOBIG","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_CONSTRAINTAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV15SQLITE_MISMATCHAA10ResultCodeVvpZ":{"name":"SQLITE_MISMATCH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_MISUSEAA10ResultCodeVvpZ":{"name":"SQLITE_MISUSE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_NOLFSAA10ResultCodeVvpZ":{"name":"SQLITE_NOLFS","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_AUTHAA10ResultCodeVvpZ":{"name":"SQLITE_AUTH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_FORMATAA10ResultCodeVvpZ":{"name":"SQLITE_FORMAT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV12SQLITE_RANGEAA10ResultCodeVvpZ":{"name":"SQLITE_RANGE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_NOTADBAA10ResultCodeVvpZ":{"name":"SQLITE_NOTADB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV13SQLITE_NOTICEAA10ResultCodeVvpZ":{"name":"SQLITE_NOTICE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV14SQLITE_WARNINGAA10ResultCodeVvpZ":{"name":"SQLITE_WARNING","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV10SQLITE_ROWAA10ResultCodeVvpZ":{"name":"SQLITE_ROW","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV11SQLITE_DONEAA10ResultCodeVvpZ":{"name":"SQLITE_DONE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_ERROR_MISSING_COLLSEQAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR_MISSING_COLLSEQ","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_ERROR_RETRYAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR_RETRY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_ERROR_SNAPSHOTAA10ResultCodeVvpZ":{"name":"SQLITE_ERROR_SNAPSHOT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_READAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_READ","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_IOERR_SHORT_READAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHORT_READ","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_WRITEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_WRITE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_FSYNCAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_FSYNC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV22SQLITE_IOERR_DIR_FSYNCAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DIR_FSYNC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_IOERR_TRUNCATEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_TRUNCATE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_FSTATAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_FSTAT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_UNLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_UNLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_RDLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_RDLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_DELETEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DELETE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_BLOCKEDAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_BLOCKED","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_NOMEMAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_NOMEM","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_ACCESSAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_ACCESS","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV30SQLITE_IOERR_CHECKRESERVEDLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_CHECKRESERVEDLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_LOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_LOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_CLOSEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_CLOSE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV22SQLITE_IOERR_DIR_CLOSEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DIR_CLOSE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_SHMOPENAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMOPEN","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_SHMSIZEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMSIZE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_IOERR_SHMLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_IOERR_SHMMAPAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SHMMAP","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_SEEKAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_SEEK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_IOERR_DELETE_NOENTAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_DELETE_NOENT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_MMAPAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_MMAP","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_IOERR_GETTEMPPATHAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_GETTEMPPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_IOERR_CONVPATHAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_CONVPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_IOERR_VNODEAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_VNODE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV17SQLITE_IOERR_AUTHAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_AUTH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_IOERR_BEGIN_ATOMICAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_BEGIN_ATOMIC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV26SQLITE_IOERR_COMMIT_ATOMICAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_COMMIT_ATOMIC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_IOERR_ROLLBACK_ATOMICAA10ResultCodeVvpZ":{"name":"SQLITE_IOERR_ROLLBACK_ATOMIC","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_LOCKED_SHAREDCACHEAA10ResultCodeVvpZ":{"name":"SQLITE_LOCKED_SHAREDCACHE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV18SQLITE_LOCKED_VTABAA10ResultCodeVvpZ":{"name":"SQLITE_LOCKED_VTAB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_BUSY_RECOVERYAA10ResultCodeVvpZ":{"name":"SQLITE_BUSY_RECOVERY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV20SQLITE_BUSY_SNAPSHOTAA10ResultCodeVvpZ":{"name":"SQLITE_BUSY_SNAPSHOT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_CANTOPEN_NOTEMPDIRAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_NOTEMPDIR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_CANTOPEN_ISDIRAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_ISDIR","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CANTOPEN_FULLPATHAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_FULLPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CANTOPEN_CONVPATHAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_CONVPATH","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CANTOPEN_DIRTYWALAA10ResultCodeVvpZ":{"name":"SQLITE_CANTOPEN_DIRTYWAL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV19SQLITE_CORRUPT_VTABAA10ResultCodeVvpZ":{"name":"SQLITE_CORRUPT_VTAB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_CORRUPT_SEQUENCEAA10ResultCodeVvpZ":{"name":"SQLITE_CORRUPT_SEQUENCE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_RECOVERYAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_RECOVERY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_CANTLOCKAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_CANTLOCK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_ROLLBACKAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_ROLLBACK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_READONLY_DBMOVEDAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_DBMOVED","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_READONLY_CANTINITAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_CANTINIT","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_READONLY_DIRECTORYAA10ResultCodeVvpZ":{"name":"SQLITE_READONLY_DIRECTORY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV21SQLITE_ABORT_ROLLBACKAA10ResultCodeVvpZ":{"name":"SQLITE_ABORT_ROLLBACK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_CONSTRAINT_CHECKAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_CHECK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_CONSTRAINT_COMMITHOOKAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_COMMITHOOK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_CONSTRAINT_FOREIGNKEYAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_FOREIGNKEY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV26SQLITE_CONSTRAINT_FUNCTIONAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_FUNCTION","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_CONSTRAINT_NOTNULLAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_NOTNULL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV28SQLITE_CONSTRAINT_PRIMARYKEYAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_PRIMARYKEY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_CONSTRAINT_TRIGGERAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_TRIGGER","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_CONSTRAINT_UNIQUEAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_UNIQUE","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV22SQLITE_CONSTRAINT_VTABAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_VTAB","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV23SQLITE_CONSTRAINT_ROWIDAA10ResultCodeVvpZ":{"name":"SQLITE_CONSTRAINT_ROWID","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV25SQLITE_NOTICE_RECOVER_WALAA10ResultCodeVvpZ":{"name":"SQLITE_NOTICE_RECOVER_WAL","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV30SQLITE_NOTICE_RECOVER_ROLLBACKAA10ResultCodeVvpZ":{"name":"SQLITE_NOTICE_RECOVER_ROLLBACK","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV24SQLITE_WARNING_AUTOINDEXAA10ResultCodeVvpZ":{"name":"SQLITE_WARNING_AUTOINDEX","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV16SQLITE_AUTH_USERAA10ResultCodeVvpZ":{"name":"SQLITE_AUTH_USER","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV26SQLITE_OK_LOAD_PERMANENTLYAA10ResultCodeVvpZ":{"name":"SQLITE_OK_LOAD_PERMANENTLY","abstract":"

Undocumented

","parent_name":"DatabaseError"},"Structs/DatabaseError.html#/s:4GRDB13DatabaseErrorV014isInterruptionC0Sbvp":{"name":"isInterruptionError","abstract":"

Returns true if the error has code SQLITE_ABORT or SQLITE_INTERRUPT.

","parent_name":"DatabaseError"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV8rawValues5Int32Vvp":{"name":"rawValue","abstract":"

The raw SQLite result code

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV8rawValueACs5Int32V_tcfc":{"name":"init(rawValue:)","abstract":"

Creates a ResultCode from a raw SQLite result code.

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV07primarybC0ACvp":{"name":"primaryResultCode","abstract":"

A result code limited to the least significant 8 bits of the receiver.","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV2teoiySbAC_ACtFZ":{"name":"~=(_:_:)","abstract":"

Returns true if the code on the left matches the code on the right.

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV9SQLITE_OKACvpZ":{"name":"SQLITE_OK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_ERRORACvpZ":{"name":"SQLITE_ERROR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_INTERNALACvpZ":{"name":"SQLITE_INTERNAL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_PERMACvpZ":{"name":"SQLITE_PERM","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_ABORTACvpZ":{"name":"SQLITE_ABORT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_BUSYACvpZ":{"name":"SQLITE_BUSY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_LOCKEDACvpZ":{"name":"SQLITE_LOCKED","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_NOMEMACvpZ":{"name":"SQLITE_NOMEM","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_READONLYACvpZ":{"name":"SQLITE_READONLY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV16SQLITE_INTERRUPTACvpZ":{"name":"SQLITE_INTERRUPT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_IOERRACvpZ":{"name":"SQLITE_IOERR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV14SQLITE_CORRUPTACvpZ":{"name":"SQLITE_CORRUPT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_NOTFOUNDACvpZ":{"name":"SQLITE_NOTFOUND","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_FULLACvpZ":{"name":"SQLITE_FULL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_CANTOPENACvpZ":{"name":"SQLITE_CANTOPEN","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_PROTOCOLACvpZ":{"name":"SQLITE_PROTOCOL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_EMPTYACvpZ":{"name":"SQLITE_EMPTY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_SCHEMAACvpZ":{"name":"SQLITE_SCHEMA","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_TOOBIGACvpZ":{"name":"SQLITE_TOOBIG","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_CONSTRAINTACvpZ":{"name":"SQLITE_CONSTRAINT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV15SQLITE_MISMATCHACvpZ":{"name":"SQLITE_MISMATCH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_MISUSEACvpZ":{"name":"SQLITE_MISUSE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_NOLFSACvpZ":{"name":"SQLITE_NOLFS","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_AUTHACvpZ":{"name":"SQLITE_AUTH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_FORMATACvpZ":{"name":"SQLITE_FORMAT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV12SQLITE_RANGEACvpZ":{"name":"SQLITE_RANGE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_NOTADBACvpZ":{"name":"SQLITE_NOTADB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV13SQLITE_NOTICEACvpZ":{"name":"SQLITE_NOTICE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV14SQLITE_WARNINGACvpZ":{"name":"SQLITE_WARNING","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV10SQLITE_ROWACvpZ":{"name":"SQLITE_ROW","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV11SQLITE_DONEACvpZ":{"name":"SQLITE_DONE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_ERROR_MISSING_COLLSEQACvpZ":{"name":"SQLITE_ERROR_MISSING_COLLSEQ","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_ERROR_RETRYACvpZ":{"name":"SQLITE_ERROR_RETRY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_ERROR_SNAPSHOTACvpZ":{"name":"SQLITE_ERROR_SNAPSHOT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_READACvpZ":{"name":"SQLITE_IOERR_READ","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_IOERR_SHORT_READACvpZ":{"name":"SQLITE_IOERR_SHORT_READ","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_WRITEACvpZ":{"name":"SQLITE_IOERR_WRITE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_FSYNCACvpZ":{"name":"SQLITE_IOERR_FSYNC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV22SQLITE_IOERR_DIR_FSYNCACvpZ":{"name":"SQLITE_IOERR_DIR_FSYNC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_IOERR_TRUNCATEACvpZ":{"name":"SQLITE_IOERR_TRUNCATE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_FSTATACvpZ":{"name":"SQLITE_IOERR_FSTAT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_UNLOCKACvpZ":{"name":"SQLITE_IOERR_UNLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_RDLOCKACvpZ":{"name":"SQLITE_IOERR_RDLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_DELETEACvpZ":{"name":"SQLITE_IOERR_DELETE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_BLOCKEDACvpZ":{"name":"SQLITE_IOERR_BLOCKED","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_NOMEMACvpZ":{"name":"SQLITE_IOERR_NOMEM","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_ACCESSACvpZ":{"name":"SQLITE_IOERR_ACCESS","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV30SQLITE_IOERR_CHECKRESERVEDLOCKACvpZ":{"name":"SQLITE_IOERR_CHECKRESERVEDLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_LOCKACvpZ":{"name":"SQLITE_IOERR_LOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_CLOSEACvpZ":{"name":"SQLITE_IOERR_CLOSE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV22SQLITE_IOERR_DIR_CLOSEACvpZ":{"name":"SQLITE_IOERR_DIR_CLOSE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_SHMOPENACvpZ":{"name":"SQLITE_IOERR_SHMOPEN","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_SHMSIZEACvpZ":{"name":"SQLITE_IOERR_SHMSIZE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_IOERR_SHMLOCKACvpZ":{"name":"SQLITE_IOERR_SHMLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_IOERR_SHMMAPACvpZ":{"name":"SQLITE_IOERR_SHMMAP","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_SEEKACvpZ":{"name":"SQLITE_IOERR_SEEK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_IOERR_DELETE_NOENTACvpZ":{"name":"SQLITE_IOERR_DELETE_NOENT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_MMAPACvpZ":{"name":"SQLITE_IOERR_MMAP","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_IOERR_GETTEMPPATHACvpZ":{"name":"SQLITE_IOERR_GETTEMPPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_IOERR_CONVPATHACvpZ":{"name":"SQLITE_IOERR_CONVPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_IOERR_VNODEACvpZ":{"name":"SQLITE_IOERR_VNODE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV17SQLITE_IOERR_AUTHACvpZ":{"name":"SQLITE_IOERR_AUTH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_IOERR_BEGIN_ATOMICACvpZ":{"name":"SQLITE_IOERR_BEGIN_ATOMIC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV26SQLITE_IOERR_COMMIT_ATOMICACvpZ":{"name":"SQLITE_IOERR_COMMIT_ATOMIC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_IOERR_ROLLBACK_ATOMICACvpZ":{"name":"SQLITE_IOERR_ROLLBACK_ATOMIC","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_LOCKED_SHAREDCACHEACvpZ":{"name":"SQLITE_LOCKED_SHAREDCACHE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV18SQLITE_LOCKED_VTABACvpZ":{"name":"SQLITE_LOCKED_VTAB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_BUSY_RECOVERYACvpZ":{"name":"SQLITE_BUSY_RECOVERY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV20SQLITE_BUSY_SNAPSHOTACvpZ":{"name":"SQLITE_BUSY_SNAPSHOT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_CANTOPEN_NOTEMPDIRACvpZ":{"name":"SQLITE_CANTOPEN_NOTEMPDIR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_CANTOPEN_ISDIRACvpZ":{"name":"SQLITE_CANTOPEN_ISDIR","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CANTOPEN_FULLPATHACvpZ":{"name":"SQLITE_CANTOPEN_FULLPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CANTOPEN_CONVPATHACvpZ":{"name":"SQLITE_CANTOPEN_CONVPATH","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CANTOPEN_DIRTYWALACvpZ":{"name":"SQLITE_CANTOPEN_DIRTYWAL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV19SQLITE_CORRUPT_VTABACvpZ":{"name":"SQLITE_CORRUPT_VTAB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_CORRUPT_SEQUENCEACvpZ":{"name":"SQLITE_CORRUPT_SEQUENCE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_RECOVERYACvpZ":{"name":"SQLITE_READONLY_RECOVERY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_CANTLOCKACvpZ":{"name":"SQLITE_READONLY_CANTLOCK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_ROLLBACKACvpZ":{"name":"SQLITE_READONLY_ROLLBACK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_READONLY_DBMOVEDACvpZ":{"name":"SQLITE_READONLY_DBMOVED","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_READONLY_CANTINITACvpZ":{"name":"SQLITE_READONLY_CANTINIT","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_READONLY_DIRECTORYACvpZ":{"name":"SQLITE_READONLY_DIRECTORY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV21SQLITE_ABORT_ROLLBACKACvpZ":{"name":"SQLITE_ABORT_ROLLBACK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_CONSTRAINT_CHECKACvpZ":{"name":"SQLITE_CONSTRAINT_CHECK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_CONSTRAINT_COMMITHOOKACvpZ":{"name":"SQLITE_CONSTRAINT_COMMITHOOK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_CONSTRAINT_FOREIGNKEYACvpZ":{"name":"SQLITE_CONSTRAINT_FOREIGNKEY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV26SQLITE_CONSTRAINT_FUNCTIONACvpZ":{"name":"SQLITE_CONSTRAINT_FUNCTION","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_CONSTRAINT_NOTNULLACvpZ":{"name":"SQLITE_CONSTRAINT_NOTNULL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV28SQLITE_CONSTRAINT_PRIMARYKEYACvpZ":{"name":"SQLITE_CONSTRAINT_PRIMARYKEY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_CONSTRAINT_TRIGGERACvpZ":{"name":"SQLITE_CONSTRAINT_TRIGGER","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_CONSTRAINT_UNIQUEACvpZ":{"name":"SQLITE_CONSTRAINT_UNIQUE","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV22SQLITE_CONSTRAINT_VTABACvpZ":{"name":"SQLITE_CONSTRAINT_VTAB","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV23SQLITE_CONSTRAINT_ROWIDACvpZ":{"name":"SQLITE_CONSTRAINT_ROWID","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV25SQLITE_NOTICE_RECOVER_WALACvpZ":{"name":"SQLITE_NOTICE_RECOVER_WAL","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV30SQLITE_NOTICE_RECOVER_ROLLBACKACvpZ":{"name":"SQLITE_NOTICE_RECOVER_ROLLBACK","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV24SQLITE_WARNING_AUTOINDEXACvpZ":{"name":"SQLITE_WARNING_AUTOINDEX","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV16SQLITE_AUTH_USERACvpZ":{"name":"SQLITE_AUTH_USER","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV26SQLITE_OK_LOAD_PERMANENTLYACvpZ":{"name":"SQLITE_OK_LOAD_PERMANENTLY","abstract":"

Undocumented

","parent_name":"ResultCode"},"Structs/ResultCode.html#/s:4GRDB10ResultCodeV2teoiySbAC_s5Error_ptFZ":{"name":"~=(_:_:)","abstract":"

Returns true if the code on the left matches the error on the right.

","parent_name":"ResultCode"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV2idSivp":{"name":"id","abstract":"

The first column in the output of the foreign_key_list pragma

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV16destinationTableSSvp":{"name":"destinationTable","abstract":"

The name of the destination table

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV7mappingSaySS6origin_SS11destinationtGvp":{"name":"mapping","abstract":"

The column to column mapping

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV13originColumnsSaySSGvp":{"name":"originColumns","abstract":"

The origin columns

","parent_name":"ForeignKeyInfo"},"Structs/ForeignKeyInfo.html#/s:4GRDB14ForeignKeyInfoV18destinationColumnsSaySSGvp":{"name":"destinationColumns","abstract":"

The destination columns

","parent_name":"ForeignKeyInfo"},"Structs/PrimaryKeyInfo.html#/s:4GRDB14PrimaryKeyInfoV7columnsSaySSGvp":{"name":"columns","abstract":"

The columns in the primary key; this array is never empty.

","parent_name":"PrimaryKeyInfo"},"Structs/PrimaryKeyInfo.html#/s:4GRDB14PrimaryKeyInfoV11rowIDColumnSSSgvp":{"name":"rowIDColumn","abstract":"

When not nil, the name of the column that contains the INTEGER PRIMARY KEY.

","parent_name":"PrimaryKeyInfo"},"Structs/PrimaryKeyInfo.html#/s:4GRDB14PrimaryKeyInfoV7isRowIDSbvp":{"name":"isRowID","abstract":"

When true, the primary key is the rowid:

","parent_name":"PrimaryKeyInfo"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV11originTableSSvp":{"name":"originTable","abstract":"

The name of the table that contains the REFERENCES clause

","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV11originRowIDs5Int64VSgvp":{"name":"originRowID","abstract":"

The rowid of the row that contains the invalid REFERENCES clause, or","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV16destinationTableSSvp":{"name":"destinationTable","abstract":"

The name of the table that is referred to.

","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV07foreignC2IdSivp":{"name":"foreignKeyId","abstract":"

The id of the specific foreign key constraint that failed. This id","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB15FetchableRecordP3rowxAA3RowC_tcfc":{"name":"init(row:)","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV18failureDescriptionySSAA8DatabaseCKF":{"name":"failureDescription(_:)","abstract":"

Returns a precise description of the foreign key violation.

","parent_name":"ForeignKeyViolation"},"Structs/ForeignKeyViolation.html#/s:4GRDB19ForeignKeyViolationV13databaseErroryAA08DatabaseF0VAA0G0CF":{"name":"databaseError(_:)","abstract":"

Returns a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY

","parent_name":"ForeignKeyViolation"},"Structs/IndexInfo.html#/s:4GRDB9IndexInfoV4nameSSvp":{"name":"name","abstract":"

The name of the index

","parent_name":"IndexInfo"},"Structs/IndexInfo.html#/s:4GRDB9IndexInfoV7columnsSaySSGvp":{"name":"columns","abstract":"

The indexed columns

","parent_name":"IndexInfo"},"Structs/IndexInfo.html#/s:4GRDB9IndexInfoV8isUniqueSbvp":{"name":"isUnique","abstract":"

True if the index is unique

","parent_name":"IndexInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV4nameSSvp":{"name":"name","abstract":"

The column name

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV4typeSSvp":{"name":"type","abstract":"

The column data type

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV9isNotNullSbvp":{"name":"isNotNull","abstract":"

True if and only if the column is constrained to be not null.

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV15defaultValueSQLSSSgvp":{"name":"defaultValueSQL","abstract":"

The SQL snippet that defines the default value, if any.

","parent_name":"ColumnInfo"},"Structs/ColumnInfo.html#/s:4GRDB10ColumnInfoV15primaryKeyIndexSivp":{"name":"primaryKeyIndex","abstract":"

Zero for columns that are not part of the primary key.

","parent_name":"ColumnInfo"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV18foreignKeysEnabledSbvp":{"name":"foreignKeysEnabled","abstract":"

If true, foreign key constraints are checked.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV8readonlySbvp":{"name":"readonly","abstract":"

If true, database modifications are disallowed.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV5labelSSSgvp":{"name":"label","abstract":"

The configuration label.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV33acceptsDoubleQuotedStringLiteralsSbvp":{"name":"acceptsDoubleQuotedStringLiterals","abstract":"

If false, SQLite from version 3.29.0 will not interpret a double-quoted","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV31observesSuspensionNotificationsSbvp":{"name":"observesSuspensionNotifications","abstract":"

When true, the Database.suspendNotification and","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV15prepareDatabaseyyyAA0D0CKcF":{"name":"prepareDatabase(_:)","abstract":"

The function argument is run when an SQLite connection is opened,","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV22defaultTransactionKindAA8DatabaseC0dE0Ovp":{"name":"defaultTransactionKind","abstract":"

The default kind of transaction.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV24allowsUnsafeTransactionsSbvp":{"name":"allowsUnsafeTransactions","abstract":"

If false, it is a programmer error to leave a transaction opened at the","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV8busyModeAA8DatabaseC04BusyD0Ovp":{"name":"busyMode","abstract":"

The behavior in case of SQLITE_BUSY error. See https://www.sqlite.org/rescode.html#busy

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV18maximumReaderCountSivp":{"name":"maximumReaderCount","abstract":"

The maximum number of concurrent readers (applies to database","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV3qos8Dispatch0D3QoSVvp":{"name":"qos","abstract":"

The quality of service class for the work performed by the database.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationV11targetQueueSo17OS_dispatch_queueCSgvp":{"name":"targetQueue","abstract":"

The target queue for all database accesses.

","parent_name":"Configuration"},"Structs/Configuration.html#/s:4GRDB13ConfigurationVACycfc":{"name":"init()","abstract":"

Creates a factory configuration

","parent_name":"Configuration"},"Structs/Configuration.html":{"name":"Configuration","abstract":"

Configuration for a DatabaseQueue or DatabasePool.

"},"Structs/ColumnInfo.html":{"name":"ColumnInfo","abstract":"

A column of a database table.

"},"Structs/IndexInfo.html":{"name":"IndexInfo","abstract":"

An index on a database table.

"},"Structs/ForeignKeyViolation.html":{"name":"ForeignKeyViolation","abstract":"

A foreign key violation produced by PRAGMA foreign_key_check

"},"Structs/PrimaryKeyInfo.html":{"name":"PrimaryKeyInfo","abstract":"

Primary keys are returned from the Database.primaryKey(_:) method.

"},"Structs/ForeignKeyInfo.html":{"name":"ForeignKeyInfo","abstract":"

You get foreign keys from table names, with the"},"Structs/ResultCode.html":{"name":"ResultCode","abstract":"

An SQLite result code.

"},"Structs/DatabaseError.html":{"name":"DatabaseError","abstract":"

DatabaseError wraps an SQLite error.

"},"Structs/DatabaseRegion.html":{"name":"DatabaseRegion","abstract":"

DatabaseRegion defines a region in the database. DatabaseRegion is dedicated"},"Structs/AnyDatabaseRegionConvertible.html":{"name":"AnyDatabaseRegionConvertible","abstract":"

A type-erased DatabaseRegionConvertible

"},"Structs/DatabaseRegionObservation.html":{"name":"DatabaseRegionObservation","abstract":"

DatabaseRegionObservation tracks changes in the results of database"},"Structs/DatabaseValue.html":{"name":"DatabaseValue","abstract":"

DatabaseValue is the intermediate type between SQLite and your values.

"},"Structs/PreparedRequest.html":{"name":"PreparedRequest","abstract":"

A PreparedRequest is a request that is ready to be executed.

"},"Structs/AdaptedFetchRequest.html":{"name":"AdaptedFetchRequest","abstract":"

An adapted request.

"},"Structs/AnyFetchRequest.html":{"name":"AnyFetchRequest","abstract":"

A type-erased FetchRequest.

"},"Structs.html#/s:4GRDB8RowIndexV":{"name":"RowIndex","abstract":"

Indexes to (ColumnName, DatabaseValue) pairs in a database row.

"},"Structs/EmptyRowAdapter.html":{"name":"EmptyRowAdapter","abstract":"

EmptyRowAdapter is a row adapter that hides all columns.

"},"Structs/ColumnMapping.html":{"name":"ColumnMapping","abstract":"

ColumnMapping is a row adapter that maps column names.

"},"Structs/SuffixRowAdapter.html":{"name":"SuffixRowAdapter","abstract":"

SuffixRowAdapter is a row adapter that hides the first columns in a row.

"},"Structs/RangeRowAdapter.html":{"name":"RangeRowAdapter","abstract":"

RangeRowAdapter is a row adapter that only exposes a range of columns.

"},"Structs/ScopeAdapter.html":{"name":"ScopeAdapter","abstract":"

ScopeAdapter is a row adapter that lets you define scopes on rows.

"},"Structs/RenameColumnAdapter.html":{"name":"RenameColumnAdapter","abstract":"

RenameColumnAdapter is a row adapter that renames columns.

"},"Structs/SQL.html":{"name":"SQL","abstract":"

SQL helps you build SQL literal with"},"Structs/SQLRequest.html":{"name":"SQLRequest","abstract":"

A FetchRequest built from raw SQL.

"},"Structs/StatementArguments.html":{"name":"StatementArguments","abstract":"

StatementArguments provide values to argument placeholders in raw"},"Structs/DatabaseDateComponents.html":{"name":"DatabaseDateComponents","abstract":"

DatabaseDateComponents reads and stores DateComponents in the database.

"},"Structs/DatabaseEvent.html":{"name":"DatabaseEvent","abstract":"

A database event, notified to TransactionObserver.

"},"Structs/DatabasePreUpdateEvent.html":{"name":"DatabasePreUpdateEvent"},"Structs/FTS3.html":{"name":"FTS3","abstract":"

FTS3 lets you define “fts3” virtual tables.

"},"Structs/FTS3Pattern.html":{"name":"FTS3Pattern","abstract":"

A full text pattern that can query FTS3 and FTS4 virtual tables.

"},"Structs/FTS3TokenizerDescriptor.html":{"name":"FTS3TokenizerDescriptor","abstract":"

An FTS3 tokenizer, suitable for FTS3 and FTS4 table definitions:

"},"Structs/FTS4.html":{"name":"FTS4","abstract":"

FTS4 lets you define “fts4” virtual tables.

"},"Structs/FTS5.html":{"name":"FTS5","abstract":"

FTS5 lets you define “fts5” virtual tables.

"},"Structs/FTS5Pattern.html":{"name":"FTS5Pattern","abstract":"

A full text pattern that can query FTS5 virtual tables.

"},"Structs/FTS5Tokenization.html":{"name":"FTS5Tokenization","abstract":"

The reason why FTS5 is requesting tokenization.

"},"Structs/FTS5TokenizerDescriptor.html":{"name":"FTS5TokenizerDescriptor","abstract":"

An FTS5 tokenizer, suitable for FTS5 table definitions:

"},"Structs/FTS5TokenFlags.html":{"name":"FTS5TokenFlags","abstract":"

Flags that tell SQLite how to register a token.

"},"Structs/DatabaseMigrator.html":{"name":"DatabaseMigrator","abstract":"

A DatabaseMigrator registers and applies database migrations.

"},"Structs/ForeignKey.html":{"name":"ForeignKey","abstract":"

A ForeignKey helps building associations when GRDB can’t infer a foreign"},"Structs/AssociationAggregate.html":{"name":"AssociationAggregate","abstract":"

An AssociationAggregate is able to compute aggregated values from a"},"Structs.html#/s:4GRDB20BelongsToAssociationV":{"name":"BelongsToAssociation","abstract":"

The BelongsTo association sets up a one-to-one connection from a record"},"Structs.html#/s:4GRDB18HasManyAssociationV":{"name":"HasManyAssociation","abstract":"

The HasMany association indicates a one-to-many connection between two"},"Structs.html#/s:4GRDB25HasManyThroughAssociationV":{"name":"HasManyThroughAssociation","abstract":"

The HasManyThrough association is often used to set up a many-to-many"},"Structs.html#/s:4GRDB17HasOneAssociationV":{"name":"HasOneAssociation","abstract":"

The HasOne association indicates a one-to-one connection between two"},"Structs.html#/s:4GRDB24HasOneThroughAssociationV":{"name":"HasOneThroughAssociation","abstract":"

A HasOneThrough association sets up a one-to-one connection with"},"Structs.html#/s:4GRDB15JoinAssociationV":{"name":"JoinAssociation","abstract":"

The Join association is used to join common table expression to regular"},"Structs/CommonTableExpression.html":{"name":"CommonTableExpression","abstract":"

A common table expression that can be"},"Structs/QueryInterfaceRequest.html":{"name":"QueryInterfaceRequest","abstract":"

QueryInterfaceRequest is a request that generates SQL for you.

"},"Structs.html#/s:4GRDB16ColumnAssignmentV":{"name":"ColumnAssignment","abstract":"

A ColumnAssignment can update rows in the database.

"},"Structs/Column.html":{"name":"Column","abstract":"

A column in a database table.

"},"Structs/SQLExpression.html":{"name":"SQLExpression","abstract":"

SQLExpression is the type that represents an SQL expression, as"},"Structs/SQLOrdering.html":{"name":"SQLOrdering","abstract":"

The type that can be used as an SQL ordering term, as described at"},"Structs/PersistenceContainer.html":{"name":"PersistenceContainer","abstract":"

Use persistence containers in the encode(to:) method of your"},"Structs/SQLSelection.html":{"name":"SQLSelection","abstract":"

The type that can be selected, as described at"},"Structs/AllColumns.html":{"name":"AllColumns","abstract":"

AllColumns is the * in SELECT *.

"},"Structs/SQLSubquery.html":{"name":"SQLSubquery","abstract":"

The type that can be embedded as a subquery.

"},"Structs/Table.html":{"name":"Table","abstract":"

Table can build query interface requests.

"},"Structs.html#/s:4GRDB25VirtualTableConfigurationV":{"name":"VirtualTableConfiguration","abstract":"

Undocumented

"},"Structs/PersistenceConflictPolicy.html":{"name":"PersistenceConflictPolicy","abstract":"

The MutablePersistableRecord protocol uses this type in order to handle"},"Structs/Inflections.html":{"name":"Inflections","abstract":"

Experimental

"},"Structs/ValueObservation.html":{"name":"ValueObservation","abstract":"

ValueObservation tracks changes in the results of database requests, and"},"Protocols/DatabaseCancellable.html#/s:4GRDB19DatabaseCancellableP6cancelyyF":{"name":"cancel()","abstract":"

Cancel the activity.

","parent_name":"DatabaseCancellable"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordP9didInsert4with3forys5Int64V_SSSgtF":{"name":"didInsert(with:for:)","abstract":"

Notifies the record that it was successfully inserted.

","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordP6insertyyAA8DatabaseCKF":{"name":"insert(_:)","abstract":"

Executes an INSERT statement.

","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordP4saveyyAA8DatabaseCKF":{"name":"save(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordPAAE13performInsertyyAA8DatabaseCKF":{"name":"performInsert(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"PersistableRecord"},"Protocols/PersistableRecord.html#/s:4GRDB17PersistableRecordPAAE11performSaveyyAA8DatabaseCKF":{"name":"performSave(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"PersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP25persistenceConflictPolicyAA011PersistencefG0VvpZ":{"name":"persistenceConflictPolicy","abstract":"

The policy that handles SQLite conflicts when records are inserted","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP9didInsert4with3forys5Int64V_SSSgtF":{"name":"didInsert(with:for:)","abstract":"

Notifies the record that it was successfully inserted.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6insertyyAA8DatabaseCKF":{"name":"insert(_:)","abstract":"

Executes an INSERT statement.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6update_7columnsyAA8DatabaseC_ShySSGtKF":{"name":"update(_:columns:)","abstract":"

Executes an UPDATE statement.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP4saveyyAA8DatabaseCKF":{"name":"save(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6deleteySbAA8DatabaseCKF":{"name":"delete(_:)","abstract":"

Executes a DELETE statement.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordP6existsySbAA8DatabaseCKF":{"name":"exists(_:)","abstract":"

Returns true if and only if the primary key matches a row in","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE8insertedyxAA8DatabaseCKF":{"name":"inserted(_:)","abstract":"

Executes an INSERT statement so that self is saved in the database,","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE6updateyyAA8DatabaseCKF":{"name":"update(_:)","abstract":"

Executes an UPDATE statement that updates all table columns.

","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13updateChanges_4fromSbAA8DatabaseC_qd__tKAaBRd__lF":{"name":"updateChanges(_:from:)","abstract":"

If the record has any difference from the other record, executes an","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13updateChanges_4withSbAA8DatabaseC_yxzKXEtKF":{"name":"updateChanges(_:with:)","abstract":"

Mutates the record according to the provided closure, and then, if the","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE5savedyxAA8DatabaseCKF":{"name":"saved(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performInsertyyAA8DatabaseCKF":{"name":"performInsert(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performUpdate_7columnsyAA8DatabaseC_ShySSGtKF":{"name":"performUpdate(_:columns:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE11performSaveyyAA8DatabaseCKF":{"name":"performSave(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performDeleteySbAA8DatabaseCKF":{"name":"performDelete(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAAE13performExistsySbAA8DatabaseCKF":{"name":"performExists(_:)","abstract":"

Don’t invoke this method directly: it is an internal method for types","parent_name":"MutablePersistableRecord"},"Protocols/MutablePersistableRecord.html#/s:4GRDB24MutablePersistableRecordPAARlzCrlE13updateChanges_4withSbAA8DatabaseC_yxKXEtKF":{"name":"updateChanges(_:with:)","abstract":"

Mutates the record according to the provided closure, and then, if the","parent_name":"MutablePersistableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP3rowxAA3RowC_tcfc":{"name":"init(row:)","abstract":"

Creates a record from row.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP24databaseDecodingUserInfoSDys06CodingfG3KeyVypGvpZ":{"name":"databaseDecodingUserInfo","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP19databaseJSONDecoder3for10Foundation0E0CSS_tFZ":{"name":"databaseJSONDecoder(for:)","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP28databaseDateDecodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseDateDecodingStrategy","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordP30databaseColumnDecodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseColumnDecodingStrategy","abstract":"

When the FetchableRecord type also adopts the standard Decodable","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE11fetchCursor_9arguments7adapterAA0cE0CyxGAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

A cursor over records fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchAll_9arguments7adapterSayxGAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of records fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchOne_9arguments7adapterxSgAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single record fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE11fetchCursor_3sql9arguments7adapterAA0cE0CyxGAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over records fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchAll_3sql9arguments7adapterSayxGAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of records fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchOne_3sql9arguments7adapterxSgAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single record fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE11fetchCursoryAA0cE0CyxGAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over records fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchAllySayxGAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of records fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAAE8fetchOneyxSgAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single record fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE11fetchCursoryAA0cF0CyxGAA8DatabaseCKFZ":{"name":"fetchCursor(_:)","abstract":"

A cursor over all records fetched from the database.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchAllySayxGAA8DatabaseCKFZ":{"name":"fetchAll(_:)","abstract":"

An array of all records fetched from the database.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchOneyxSgAA8DatabaseCKFZ":{"name":"fetchOne(_:)","abstract":"

The first found record.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzrlE8fetchSetyShyxGAA8DatabaseCKFZ":{"name":"fetchSet(_:)","abstract":"

A set of all records fetched from the database.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE11fetchCursor_4keysAA0cF0CyxGAA8DatabaseC_qd__tKSTRd__AA0H16ValueConvertible7ElementRpd__lFZ":{"name":"fetchCursor(_:keys:)","abstract":"

Returns a cursor over records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchAll_4keysSayxGAA8DatabaseC_qd__tKSTRd__AA0H16ValueConvertible7ElementRpd__lFZ":{"name":"fetchAll(_:keys:)","abstract":"

Returns an array of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchOne_3keyxSgAA8DatabaseC_qd__SgtKAA0H16ValueConvertibleRd__lFZ":{"name":"fetchOne(_:key:)","abstract":"

Returns a single record given its primary key.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE11fetchCursor_3idsAA0cK0CyxGAA0F0C_qd__tKSlRd__7ElementQyd__AIRSlFZ":{"name":"fetchCursor(_:ids:)","abstract":"

Returns a cursor over records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE8fetchAll_3idsSayxGAA0F0C_qd__tKSlRd__7ElementQyd__AIRSlFZ":{"name":"fetchAll(_:ids:)","abstract":"

Returns an array of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE8fetchOne_2idxSgAA0F0C_AItKFZ":{"name":"fetchOne(_:id:)","abstract":"

Returns a single record given its primary key.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE11fetchCursor_3idsAA0cN0CyxGAA0I0C_qd__tKSlRd__AaJ7ElementRpd__AmVRSlFZ":{"name":"fetchCursor(_:ids:)","abstract":"

Returns a cursor over records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE8fetchAll_3idsSayxGAA0I0C_qd__tKSlRd__AaJ7ElementRpd__AmTRSlFZ":{"name":"fetchAll(_:ids:)","abstract":"

Returns an array of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0Rzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE8fetchOne_2idxSgAA0I0C_AMtKFZ":{"name":"fetchOne(_:id:)","abstract":"

Returns a single record given its primary key.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzrlE8fetchSet_4keysShyxGAA8DatabaseC_qd__tKSTRd__AA0H16ValueConvertible7ElementRpd__lFZ":{"name":"fetchSet(_:keys:)","abstract":"

Returns a set of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzs12IdentifiableRzAA24DatabaseValueConvertible2IDsAEPRpzrlE8fetchSet_3idsShyxGAA0F0C_qd__tKSlRd__7ElementQyd__AIRSlFZ":{"name":"fetchSet(_:ids:)","abstract":"

Returns a set of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzs12IdentifiableRzAA17_OptionalProtocol2IDsAEPRpzAA24DatabaseValueConvertibleAgH_7WrappedAaFPRPzrlE8fetchSet_3idsShyxGAA0I0C_qd__tKSlRd__AaJ7ElementRpd__AmTRSlFZ":{"name":"fetchSet(_:ids:)","abstract":"

Returns a set of records, given their primary keys.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE11fetchCursor_4keysAA0cF0CyxGAA8DatabaseC_SaySDySSAA0H16ValueConvertible_pSgGGtKFZ":{"name":"fetchCursor(_:keys:)","abstract":"

Returns a cursor over records identified by the provided unique keys","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchAll_4keysSayxGAA8DatabaseC_SaySDySSAA0H16ValueConvertible_pSgGGtKFZ":{"name":"fetchAll(_:keys:)","abstract":"

Returns an array of records identified by the provided unique keys","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzrlE8fetchOne_3keyxSgAA8DatabaseC_SDySSAA0H16ValueConvertible_pSgGSgtKFZ":{"name":"fetchOne(_:key:)","abstract":"

Returns a single record identified by a unique key (the primary key or","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPA2A05TableC0RzSHRzrlE8fetchSet_4keysShyxGAA8DatabaseC_SaySDySSAA0H16ValueConvertible_pSgGGtKFZ":{"name":"fetchSet(_:keys:)","abstract":"

Returns a set of records identified by the provided unique keys","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAASHRzrlE8fetchSet_9arguments7adapterShyxGAA9StatementC_AA0H9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of records fetched from a prepared statement.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAASHRzrlE8fetchSet_3sql9arguments7adapterShyxGAA8DatabaseC_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of records fetched from an SQL query.

","parent_name":"FetchableRecord"},"Protocols/FetchableRecord.html#/s:4GRDB15FetchableRecordPAASHRzrlE8fetchSetyShyxGAA8DatabaseC_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of records fetched from a fetch request.

","parent_name":"FetchableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP6encode2toyAA20PersistenceContainerVz_tF":{"name":"encode(to:)","abstract":"

Encodes the record into database values.

","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP24databaseEncodingUserInfoSDys06CodingfG3KeyVypGvpZ":{"name":"databaseEncodingUserInfo","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP19databaseJSONEncoder3for10Foundation0E0CSS_tFZ":{"name":"databaseJSONEncoder(for:)","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP28databaseDateEncodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseDateEncodingStrategy","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP28databaseUUIDEncodingStrategyAA08DatabaseeF0OvpZ":{"name":"databaseUUIDEncodingStrategy","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordP30databaseColumnEncodingStrategyAA08DatabaseefG0OvpZ":{"name":"databaseColumnEncodingStrategy","abstract":"

When the EncodableRecord type also adopts the standard Encodable","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordPAAE18databaseDictionarySDySSAA13DatabaseValueVGvp":{"name":"databaseDictionary","abstract":"

A dictionary whose keys are the columns encoded in the encode(to:) method.

","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordPAAE14databaseEqualsySbxF":{"name":"databaseEquals(_:)","abstract":"

Returns a boolean indicating whether this record and the other record","parent_name":"EncodableRecord"},"Protocols/EncodableRecord.html#/s:4GRDB15EncodableRecordPAAE15databaseChanges4fromSDySSAA13DatabaseValueVGqd___tAaBRd__lF":{"name":"databaseChanges(from:)","abstract":"

A dictionary of values changed from the other record.

","parent_name":"EncodableRecord"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP0C10DefinitionQa":{"name":"TableDefinition","abstract":"

The type of the closure argument in the","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP10moduleNameSSvp":{"name":"moduleName","abstract":"

The name of the module.

","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP04makeC10Definition0cF0QzyF":{"name":"makeTableDefinition()","abstract":"

Returns a table definition that is passed as the closure argument in the","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP04makeC10Definition13configuration0cF0QzAA0bC13ConfigurationV_tF":{"name":"makeTableDefinition(configuration:)","abstract":"

Returns a table definition that is passed as the closure argument in the","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP15moduleArguments3for2inSaySSG0C10DefinitionQz_AA8DatabaseCtKF":{"name":"moduleArguments(for:in:)","abstract":"

Returns the module arguments for the CREATE VIRTUAL TABLE query.

","parent_name":"VirtualTableModule"},"Protocols/VirtualTableModule.html#/s:4GRDB18VirtualTableModuleP8database_9didCreate5usingyAA8DatabaseC_SS0C10DefinitionQztKF":{"name":"database(_:didCreate:using:)","abstract":"

Execute any relevant database statement after the virtual table has","parent_name":"VirtualTableModule"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryableP11sqlSubqueryAA11SQLSubqueryVvp":{"name":"sqlSubquery","abstract":"

Undocumented

","parent_name":"SQLSubqueryable"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryablePAAE13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","abstract":"

Returns a subquery expression.

","parent_name":"SQLSubqueryable"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryablePAAE8containsyAA13SQLExpressionVAA14SQLExpressible_pF":{"name":"contains(_:)","abstract":"

Returns an expression that checks the inclusion of the expression in","parent_name":"SQLSubqueryable"},"Protocols/SQLSubqueryable.html#/s:4GRDB15SQLSubqueryablePAAE6existsAA13SQLExpressionVyF":{"name":"exists()","abstract":"

Returns an expression that is true if and only if the subquery would","parent_name":"SQLSubqueryable"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE3ascAA11SQLOrderingVvp":{"name":"asc","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE4descAA11SQLOrderingVvp":{"name":"desc","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/ascNullsLast":{"name":"ascNullsLast","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/descNullsFirst":{"name":"descNullsFirst","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE12ascNullsLastAA11SQLOrderingVvp":{"name":"ascNullsLast","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE14descNullsFirstAA11SQLOrderingVvp":{"name":"descNullsFirst","abstract":"

Returns a value that can be used as an argument to QueryInterfaceRequest.order()

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE9collatingyAA13SQLExpressionVAA8DatabaseC13CollationNameVF":{"name":"collating(_:)","abstract":"

Returns a collated expression.

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE9collatingyAA13SQLExpressionVAA17DatabaseCollationCF":{"name":"collating(_:)","abstract":"

Returns a collated expression.

","parent_name":"SQLSpecificExpressible"},"Protocols/SQLSpecificExpressible.html#/s:4GRDB22SQLSpecificExpressiblePAAE4like_6escapeAA13SQLExpressionVAA14SQLExpressible_p_AaH_pSgtF":{"name":"like(_:escape:)","abstract":"

An SQL expression with the LIKE SQL operator.

","parent_name":"SQLSpecificExpressible"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestP8distinctxyF":{"name":"distinct()","abstract":"

Creates a request which returns distinct rows.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestP4withyxAA21CommonTableExpressionVyqd__GlF":{"name":"with(_:)","abstract":"

Returns a request which embeds the common table expression.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestPAAE9annotated4withxAA20AssociationAggregateVy10RowDecoderQzGd_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends aggregates to the current selection.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestPAAE9annotated4withxSayAA20AssociationAggregateVy10RowDecoderQzGG_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends aggregates to the current selection.

","parent_name":"DerivableRequest"},"Protocols/DerivableRequest.html#/s:4GRDB16DerivableRequestPAAE6havingyxAA20AssociationAggregateVy10RowDecoderQzGF":{"name":"having(_:)","abstract":"

Creates a request which appends the provided aggregate predicate to","parent_name":"DerivableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE9including3allxqd___tAA17AssociationToManyRd__16OriginRowDecoderQyd__0jK0RtzlF":{"name":"including(all:)","abstract":"

Creates a request that prefetches an association.

","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE9including8optionalxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"including(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE9including8requiredxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"including(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE7joining8optionalxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"joining(optional:)","abstract":"

Creates a request that joins an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPAAE7joining8requiredxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0hI0RtzlF":{"name":"joining(required:)","abstract":"

Creates a request that joins an association. The columns of the","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPA2A09SelectionC0RzrlE9annotated12withOptionalxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0jK0AA05TypedC0PRtzlF":{"name":"annotated(withOptional:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"JoinableRequest"},"Protocols/JoinableRequest.html#/s:4GRDB15JoinableRequestPA2A09SelectionC0RzrlE9annotated12withRequiredxqd___tAA11AssociationRd__16OriginRowDecoderQyd__0jK0AA05TypedC0PRtzlF":{"name":"annotated(withRequired:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"JoinableRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestP5orderyxSayAA15SQLOrderingTerm_pGAA8DatabaseCKcF":{"name":"order(_:)","abstract":"

Creates a request with the provided orderings promise.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestP8reversedxyF":{"name":"reversed()","abstract":"

Creates a request that reverses applied orderings.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestP9unorderedxyF":{"name":"unordered()","abstract":"

Creates a request without any ordering.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestPAAE5order3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"order(sql:arguments:)","abstract":"

Creates a request sorted according to sql.

","parent_name":"OrderedRequest"},"Protocols/OrderedRequest.html#/s:4GRDB14OrderedRequestPAAE5order7literalxAA3SQLV_tF":{"name":"order(literal:)","abstract":"

Creates a request sorted according to an SQL literal.

","parent_name":"OrderedRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestP5groupyxSayAA14SQLExpressible_pGAA8DatabaseCKcF":{"name":"group(_:)","abstract":"

Creates a request grouped according to expressions promise.

","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestP6havingyxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"having(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE5group3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"group(sql:arguments:)","abstract":"

Creates a request with a new grouping.

","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE5group7literalxAA3SQLV_tF":{"name":"group(literal:)","abstract":"

Creates a request with a new grouping.

","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE6having3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"having(sql:arguments:)","abstract":"

Creates a request with the provided sql added to the","parent_name":"AggregatingRequest"},"Protocols/AggregatingRequest.html#/s:4GRDB18AggregatingRequestPAAE6having7literalxAA3SQLV_tF":{"name":"having(literal:)","abstract":"

Creates a request with the provided SQL literal added to the","parent_name":"AggregatingRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestP6filteryxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate promise added to the","parent_name":"FilteredRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestPAAE6filter3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"filter(sql:arguments:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"FilteredRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestPAAE6filter7literalxAA3SQLV_tF":{"name":"filter(literal:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"FilteredRequest"},"Protocols/FilteredRequest.html#/s:4GRDB15FilteredRequestPAAE4nonexyF":{"name":"none()","abstract":"

Creates a request that matches nothing.

","parent_name":"FilteredRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestP6selectyxSayAA13SQLSelectable_pGAA8DatabaseCKcF":{"name":"select(_:)","abstract":"

Creates a request which selects selection promise.

","parent_name":"SelectionRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestP9annotated4withxSayAA13SQLSelectable_pGAA8DatabaseCKc_tF":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection promise.

","parent_name":"SelectionRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestPAAE6select3sql9argumentsxSS_AA18StatementArgumentsVtF":{"name":"select(sql:arguments:)","abstract":"

Creates a request which selects sql.

","parent_name":"SelectionRequest"},"Protocols/SelectionRequest.html#/s:4GRDB16SelectionRequestPAAE6select7literalxAA3SQLV_tF":{"name":"select(literal:)","abstract":"

Creates a request which selects an SQL literal.

","parent_name":"SelectionRequest"},"Protocols/TypedRequest.html#/s:4GRDB12TypedRequestP10RowDecoderQa":{"name":"RowDecoder","abstract":"

The type that can decode database rows.

","parent_name":"TypedRequest"},"Protocols/AssociationToMany.html#/s:4GRDB11AssociationP6forKeyyxSSF":{"name":"forKey(_:)","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE5countAA0B9AggregateVy16OriginRowDecoderQzGvp":{"name":"count","abstract":"

The number of associated records.

","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE7isEmptyAA0B9AggregateVy16OriginRowDecoderQzGvp":{"name":"isEmpty","abstract":"

Creates an aggregate that is true if there exists no associated records.

","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE7averageyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"average(_:)","abstract":"

Creates an aggregate which evaluate to the average value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE7averageyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"average(_:)","abstract":"

Creates an aggregate which evaluate to the average value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3maxyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aggregate which evaluate to the maximum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3maxyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aggregate which evaluate to the maximum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3minyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"min(_:)","abstract":"

Creates an aggregate which evaluate to the minimum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3minyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"min(_:)","abstract":"

Creates an aggregate which evaluate to the minimum value of the given","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3sumyAA0B9AggregateVy16OriginRowDecoderQzGAA14SQLExpressible_pF":{"name":"sum(_:)","abstract":"

Creates an aggregate which evaluate to the sum of the given expression","parent_name":"AssociationToMany"},"Protocols/AssociationToMany.html#/s:4GRDB17AssociationToManyPAAE3sumyAA0B9AggregateVy16OriginRowDecoderQzGAA22SQLSpecificExpressible_pF":{"name":"sum(_:)","abstract":"

Creates an aggregate which evaluate to the sum of the given expression","parent_name":"AssociationToMany"},"Protocols/AssociationToOne.html#/s:4GRDB11AssociationP6forKeyyxSSF":{"name":"forKey(_:)","parent_name":"AssociationToOne"},"Protocols/Association.html#/s:4GRDB11AssociationP16OriginRowDecoderQa":{"name":"OriginRowDecoder","abstract":"

The record type at the origin of the association.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationP6forKeyyxSSF":{"name":"forKey(_:)","abstract":"

Creates an association with the given key.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE7aliasedyxAA10TableAliasCF":{"name":"aliased(_:)","abstract":"

Creates an association that allows you to define expressions that target","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE6selectyxSayAA13SQLSelectable_pGAA8DatabaseCKcF":{"name":"select(_:)","abstract":"

Creates an association which selects selection.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE9annotated4withxSayAA13SQLSelectable_pGAA8DatabaseCKc_tF":{"name":"annotated(with:)","abstract":"

Creates an association which appends selection.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE6filteryxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"filter(_:)","abstract":"

Creates an association with the provided predicate promise added to","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE5orderyxSayAA15SQLOrderingTerm_pGAA8DatabaseCKcF":{"name":"order(_:)","abstract":"

Creates an association with the provided orderings promise.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE8reversedxyF":{"name":"reversed()","abstract":"

Creates an association that reverses applied orderings.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE9unorderedxyF":{"name":"unordered()","abstract":"

Creates an association without any ordering.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB12TableRequestP08databaseB4NameSSvp":{"name":"databaseTableName","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE5groupyxSayAA14SQLExpressible_pGAA8DatabaseCKcF":{"name":"group(_:)","abstract":"

Creates an association grouped according to expressions promise.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE6havingyxAA14SQLExpressible_pAA8DatabaseCKcF":{"name":"having(_:)","abstract":"

Creates an association with the provided predicate promise added to","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE8distinctxyF":{"name":"distinct()","abstract":"

Creates an association for returns distinct rows.

","parent_name":"Association"},"Protocols/Association.html#/s:4GRDB11AssociationPAAE4withyxAA21CommonTableExpressionVyqd__GlF":{"name":"with(_:)","abstract":"

Returns an association that embeds the common table expression.

","parent_name":"Association"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionP4nameSSvp":{"name":"name","abstract":"

The unqualified name of a database column.

","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionPAAE5matchyAA13SQLExpressionVAA11FTS3PatternVSgF":{"name":"match(_:)","abstract":"

A matching SQL expression with the MATCH SQL operator.

","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionPAAE3set2toAA0B10AssignmentVAA14SQLExpressible_pSg_tF":{"name":"set(to:)","abstract":"

Creates an assignment to a value.

","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"ColumnExpression"},"Protocols/ColumnExpression.html#/s:4GRDB16ColumnExpressionPA2A0B0VRszrlE5rowIDAEvpZ":{"name":"rowID","abstract":"

The hidden rowID column

","parent_name":"ColumnExpression"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordP08databaseB4NameSSvpZ":{"name":"databaseTableName","abstract":"

The name of the database table used to build requests.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordP17databaseSelectionSayAA13SQLSelectable_pGvpZ":{"name":"databaseSelection","abstract":"

The default request selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE8matchingyAA21QueryInterfaceRequestVyxGAA11FTS3PatternVSgFZ":{"name":"matching(_:)","abstract":"

Returns a QueryInterfaceRequest with a matching predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9belongsTo_3key5usingAA07BelongsE11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAaBRd__lFZ":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7hasMany_3key5usingAA03HasE11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAaBRd__lFZ":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination type,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6hasOne_3key5usingAA03HasE11AssociationVyxqd__Gqd__m_SSSgAA10ForeignKeyVSgtAaBRd__lFZ":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination type,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9belongsTo_3key5usingAA07BelongsE11AssociationVyxqd__GAA0B0Vyqd__G_SSSgAA10ForeignKeyVSgtlFZ":{"name":"belongsTo(_:key:using:)","abstract":"

Creates a “Belongs To” association between Self and the destination","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7hasMany_3key5usingAA03HasE11AssociationVyxqd__GAA0B0Vyqd__G_SSSgAA10ForeignKeyVSgtlFZ":{"name":"hasMany(_:key:using:)","abstract":"

Creates a “Has many” association between Self and the destination table,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6hasOne_3key5usingAA03HasE11AssociationVyxqd__GAA0B0Vyqd__G_SSSgAA10ForeignKeyVSgtlFZ":{"name":"hasOne(_:key:using:)","abstract":"

Creates a “Has one” association between Self and the destination table,","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE11association2to2onAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_AA14SQLExpressible_pAA0B5AliasC_AOtctlFZ":{"name":"association(to:on:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE11association2toAA15JoinAssociationVyxqd__GAA06CommonB10ExpressionVyqd__G_tlFZ":{"name":"association(to:)","abstract":"

Creates an association to a common table expression that you can join","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7hasMany_7through5using3keyAA03HasE18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginlM0Qyd__RszAA0K0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lFZ":{"name":"hasMany(_:through:using:key:)","abstract":"

Creates a “Has Many Through” association between Self and the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6hasOne_7through5using3keyAA03HasE18ThroughAssociationVyx10RowDecoderQyd_0_GAKm_qd__qd_0_SSSgt06OriginlM0Qyd__RszAA0k2ToE0Rd__AaPRd_0_ANQyd_0_AJRtd__r0_lFZ":{"name":"hasOne(_:through:using:key:)","abstract":"

Creates a “Has One Through” association between Self and the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9including3allAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA17AssociationToManyRd__lFZ":{"name":"including(all:)","abstract":"

Creates a request that prefetches an association.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9including8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"including(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9including8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"including(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7joining8optionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"joining(optional:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7joining8requiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"joining(required:)","abstract":"

Creates a request that includes an association. The columns of the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated12withOptionalAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"annotated(withOptional:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated12withRequiredAA21QueryInterfaceRequestVyxGqd___t16OriginRowDecoderQyd__RszAA11AssociationRd__lFZ":{"name":"annotated(withRequired:)","abstract":"

Creates a request which appends columns of an associated record to","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGd_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGSayAA20AssociationAggregateVyxGG_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request with aggregates appended to the selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6havingyAA21QueryInterfaceRequestVyxGAA20AssociationAggregateVyxGFZ":{"name":"having(_:)","abstract":"

Creates a request with the provided aggregate predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE3allAA21QueryInterfaceRequestVyxGyFZ":{"name":"all()","abstract":"

Creates a request which fetches all records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE4noneAA21QueryInterfaceRequestVyxGyFZ":{"name":"none()","abstract":"

Creates a request which fetches no record.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6selectyAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tFZ":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6selectyAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pGFZ":{"name":"select(_:)","abstract":"

Creates a request which selects selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtFZ":{"name":"select(sql:arguments:)","abstract":"

Creates a request which selects sql.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tFZ":{"name":"select(literal:)","abstract":"

Creates a request which selects an SQL literal.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select_2asAA21QueryInterfaceRequestVyqd__GSayAA13SQLSelectable_pG_qd__mtlFZ":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select_2asAA21QueryInterfaceRequestVyqd__GAA13SQLSelectable_pd_qd__mtlFZ":{"name":"select(_:as:)","abstract":"

Creates a request which selects selection, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select3sql9arguments2asAA21QueryInterfaceRequestVyqd__GSS_AA18StatementArgumentsVqd__mtlFZ":{"name":"select(sql:arguments:as:)","abstract":"

Creates a request which selects sql, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6select7literal2asAA21QueryInterfaceRequestVyqd__GAA3SQLV_qd__mtlFZ":{"name":"select(literal:as:)","abstract":"

Creates a request which selects an SQL literal, and fetches values of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGSayAA13SQLSelectable_pG_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9annotated4withAA21QueryInterfaceRequestVyxGAA13SQLSelectable_pd_tFZ":{"name":"annotated(with:)","abstract":"

Creates a request which appends selection.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filteryAA21QueryInterfaceRequestVyxGAA14SQLExpressible_pFZ":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filteryAA21QueryInterfaceRequestVyxGAA22SQLSpecificExpressible_pFZ":{"name":"filter(_:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter3keyAA21QueryInterfaceRequestVyxGqd__Sg_tAA24DatabaseValueConvertibleRd__lFZ":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter4keysAA21QueryInterfaceRequestVyxGqd___tSTRd__AA24DatabaseValueConvertible7ElementRpd__lFZ":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter3keyAA21QueryInterfaceRequestVyxGSDySSAA24DatabaseValueConvertible_pSgGSg_tFZ":{"name":"filter(key:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter4keysAA21QueryInterfaceRequestVyxGSaySDySSAA24DatabaseValueConvertible_pSgGG_tFZ":{"name":"filter(keys:)","abstract":"

Creates a request with the provided primary key predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtFZ":{"name":"filter(sql:arguments:)","abstract":"

Creates a request with the provided predicate.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6filter7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tFZ":{"name":"filter(literal:)","abstract":"

Creates a request with the provided predicate added to the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5orderyAA21QueryInterfaceRequestVyxGAA15SQLOrderingTerm_pd_tFZ":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5orderyAA21QueryInterfaceRequestVyxGSayAA15SQLOrderingTerm_pGFZ":{"name":"order(_:)","abstract":"

Creates a request sorted according to the","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE17orderByPrimaryKeyAA21QueryInterfaceRequestVyxGyFZ":{"name":"orderByPrimaryKey()","abstract":"

Creates a request sorted by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5order3sql9argumentsAA21QueryInterfaceRequestVyxGSS_AA18StatementArgumentsVtFZ":{"name":"order(sql:arguments:)","abstract":"

Creates a request sorted according to sql.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5order7literalAA21QueryInterfaceRequestVyxGAA3SQLV_tFZ":{"name":"order(literal:)","abstract":"

Creates a request sorted according to an SQL literal.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE5limit_6offsetAA21QueryInterfaceRequestVyxGSi_SiSgtFZ":{"name":"limit(_:offset:)","abstract":"

Creates a request which fetches limit rows, starting at","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE7aliasedyAA21QueryInterfaceRequestVyxGAA0B5AliasCFZ":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE4withyAA21QueryInterfaceRequestVyxGAA06CommonB10ExpressionVyqd__GlFZ":{"name":"with(_:)","abstract":"

Returns a request which embeds the common table expression.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE10fetchCountySiAA8DatabaseCKFZ":{"name":"fetchCount(_:)","abstract":"

The number of records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE23numberOfSelectedColumnsySiAA8DatabaseCKFZ":{"name":"numberOfSelectedColumns(_:)","abstract":"

Returns the number of selected columns.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteAllySiAA8DatabaseCKFZ":{"name":"deleteAll(_:)","abstract":"

Deletes all records; returns the number of deleted rows.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6exists_3keySbAA8DatabaseC_qd__tKAA0F16ValueConvertibleRd__lFZ":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE6exists_3keySbAA8DatabaseC_SDySSAA0F16ValueConvertible_pSgGtKFZ":{"name":"exists(_:key:)","abstract":"

Returns whether a row exists for this unique key (primary key or any key","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteAll_4keysSiAA8DatabaseC_qd__tKSTRd__AA0G16ValueConvertible7ElementRpd__lFZ":{"name":"deleteAll(_:keys:)","abstract":"

Delete records identified by their primary keys; returns the number of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteOne_3keySbAA8DatabaseC_qd__SgtKAA0G16ValueConvertibleRd__lFZ":{"name":"deleteOne(_:key:)","abstract":"

Delete a record, identified by its primary key; returns whether a","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteAll_4keysSiAA8DatabaseC_SaySDySSAA0G16ValueConvertible_pSgGGtKFZ":{"name":"deleteAll(_:keys:)","abstract":"

Delete records identified by the provided unique keys (primary key or","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9deleteOne_3keySbAA8DatabaseC_SDySSAA0G16ValueConvertible_pSgGtKFZ":{"name":"deleteOne(_:key:)","abstract":"

Delete a record, identified by a unique key (the primary key or any key","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9updateAll_10onConflict_SiAA8DatabaseC_AG0G10ResolutionOSgSayAA16ColumnAssignmentVGtKFZ":{"name":"updateAll(_:onConflict:_:)","abstract":"

Updates all records; returns the number of updated records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAE9updateAll_10onConflict__SiAA8DatabaseC_AG0G10ResolutionOSgAA16ColumnAssignmentVALdtKFZ":{"name":"updateAll(_:onConflict:_:_:)","abstract":"

Updates all records; returns the number of updated records.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPA2A09EncodableC0RzrlE7request3forAA21QueryInterfaceRequestVy10RowDecoderQyd__Gqd___t06OriginjK0Qyd__RszAA11AssociationRd__lF":{"name":"request(for:)","abstract":"

Creates a request that fetches the associated record(s).

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE6filter2idAA21QueryInterfaceRequestVyxGAH_tFZ":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__7ElementQyd__AHRSlFZ":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE06selectH0AA21QueryInterfaceRequestVyAHGyFZ":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE6filter2idAA21QueryInterfaceRequestVyxGAL_tFZ":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE6filter3idsAA21QueryInterfaceRequestVyxGqd___tSlRd__AaI7ElementRpd__AlSRSlFZ":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE06selectG0AA21QueryInterfaceRequestVyALGyFZ":{"name":"selectID()","abstract":"

Creates a request which selects the primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE6exists_2idSbAA0E0C_AHtKFZ":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE6exists_2idSbAA0H0C_ALtKFZ":{"name":"exists(_:id:)","abstract":"

Returns whether a row exists for this primary key.

","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE9deleteAll_3idsSiAA0E0C_qd__tKSlRd__7ElementQyd__AHRSlFZ":{"name":"deleteAll(_:ids:)","abstract":"

Delete records identified by their primary keys; returns the number of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA24DatabaseValueConvertible2IDsADPRpzrlE9deleteOne_2idSbAA0E0C_AHtKFZ":{"name":"deleteOne(_:id:)","abstract":"

Delete a record, identified by its primary key; returns whether a","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE9deleteAll_3idsSiAA0H0C_qd__tKSlRd__AaI7ElementRpd__AlRRSlFZ":{"name":"deleteAll(_:ids:)","abstract":"

Delete records identified by their primary keys; returns the number of","parent_name":"TableRecord"},"Protocols/TableRecord.html#/s:4GRDB11TableRecordPAAs12IdentifiableRzAA17_OptionalProtocol2IDsADPRpzAA24DatabaseValueConvertibleAfG_7WrappedAaEPRPzrlE9deleteOne_2idSbAA0H0C_ALtKFZ":{"name":"deleteOne(_:id:)","abstract":"

Delete a record, identified by its primary key; returns whether a","parent_name":"TableRecord"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestP08databaseB4NameSSvp":{"name":"databaseTableName","abstract":"

The name of the database table

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestP7aliasedyxAA0B5AliasCF":{"name":"aliased(_:)","abstract":"

Creates a request that allows you to define expressions that target","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzrlE8matchingyxAA11FTS3PatternVSgF":{"name":"matching(_:)","abstract":"

Creates a request with a full-text predicate added to the eventual","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter3keyxqd__Sg_tAA24DatabaseValueConvertibleRd__lF":{"name":"filter(key:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter4keysxqd___tSTRd__AA24DatabaseValueConvertible7ElementRpd__lF":{"name":"filter(keys:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter3keyxSDySSAA24DatabaseValueConvertible_pSgGSg_tF":{"name":"filter(key:)","abstract":"

Creates a request filtered by unique key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0RzrlE6filter4keysxSaySDySSAA24DatabaseValueConvertible_pSgGG_tF":{"name":"filter(keys:)","abstract":"

Creates a request filtered by unique key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA24DatabaseValueConvertibleAgH_2IDRPzrlE6filter2idxAL_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA24DatabaseValueConvertibleAgH_2IDRPzrlE6filter3idsxqd___tSlRd__AaJ7ElementRpd__AlPRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA17_OptionalProtocolAgH_2IDRPzAA24DatabaseValueConvertibleAgH_AK7WrappedAaJPRPzrlE6filter2idxAP_tF":{"name":"filter(id:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A08FilteredC0RzAA05TypedC0Rzs12Identifiable10RowDecoderAaEPRpzAA17_OptionalProtocolAgH_2IDRPzAA24DatabaseValueConvertibleAgH_AK7WrappedAaJPRPzrlE6filter3idsxqd___tSlRd__AaM7ElementRpd__ApTRSlF":{"name":"filter(ids:)","abstract":"

Creates a request filtered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A07OrderedC0RzrlE17orderByPrimaryKeyxyF":{"name":"orderByPrimaryKey()","abstract":"

Creates a request ordered by primary key.

","parent_name":"TableRequest"},"Protocols/TableRequest.html#/s:4GRDB12TableRequestPA2A011AggregatingC0RzrlE17groupByPrimaryKeyxyF":{"name":"groupByPrimaryKey()","abstract":"

Creates a request grouped by primary key.

","parent_name":"TableRequest"},"Protocols/FTS5WrapperTokenizer.html#/wrappedTokenizer":{"name":"wrappedTokenizer","abstract":"

The wrapped tokenizer

","parent_name":"FTS5WrapperTokenizer"},"Protocols/FTS5WrapperTokenizer.html#/accept(token:flags:for:tokenCallback:)":{"name":"accept(token:flags:for:tokenCallback:)","abstract":"

Given a token produced by the wrapped tokenizer, notifies customized","parent_name":"FTS5WrapperTokenizer"},"Protocols/FTS5WrapperTokenizer.html#/tokenize(context:tokenization:pText:nText:tokenCallback:)":{"name":"tokenize(context:tokenization:pText:nText:tokenCallback:)","abstract":"

Default implementation

","parent_name":"FTS5WrapperTokenizer"},"Protocols/FTS5Tokenizer.html#/tokenize(context:tokenization:pText:nText:tokenCallback:)":{"name":"tokenize(context:tokenization:pText:nText:tokenCallback:)","abstract":"

Tokenizes the text described by pText and nText, and","parent_name":"FTS5Tokenizer"},"Protocols/FTS5Tokenizer.html#/tokenize(document:)":{"name":"tokenize(document:)","abstract":"

Tokenizes the string argument as a document that would be inserted into","parent_name":"FTS5Tokenizer"},"Protocols/FTS5Tokenizer.html#/tokenize(query:)":{"name":"tokenize(query:)","abstract":"

Tokenizes the string argument as an FTS5 query.

","parent_name":"FTS5Tokenizer"},"Protocols/FTS5CustomTokenizer.html#/name":{"name":"name","abstract":"

The name of the tokenizer; should uniquely identify your custom","parent_name":"FTS5CustomTokenizer"},"Protocols/FTS5CustomTokenizer.html#/init(db:arguments:)":{"name":"init(db:arguments:)","abstract":"

Creates a custom tokenizer.

","parent_name":"FTS5CustomTokenizer"},"Protocols/FTS5CustomTokenizer.html#/tokenizerDescriptor(arguments:)":{"name":"tokenizerDescriptor(arguments:)","abstract":"

Creates an FTS5 tokenizer descriptor.

","parent_name":"FTS5CustomTokenizer"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP8observes12eventsOfKindSbAA013DatabaseEventG0O_tF":{"name":"observes(eventsOfKind:)","abstract":"

Filters database changes that should be notified the the","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP17databaseDidChange4withyAA13DatabaseEventV_tF":{"name":"databaseDidChange(with:)","abstract":"

Notifies a database change (insert, update, or delete).

","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP18databaseWillCommityyKF":{"name":"databaseWillCommit()","abstract":"

When a transaction is about to be committed, the transaction observer","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP17databaseDidCommityyAA8DatabaseCF":{"name":"databaseDidCommit(_:)","abstract":"

Database changes have been committed.

","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverP19databaseDidRollbackyyAA8DatabaseCF":{"name":"databaseDidRollback(_:)","abstract":"

Database changes have been rollbacked.

","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/databaseWillChange(with:)":{"name":"databaseWillChange(with:)","abstract":"

Notifies before a database change (insert, update, or delete)","parent_name":"TransactionObserver"},"Protocols/TransactionObserver.html#/s:4GRDB19TransactionObserverPAAE037stopObservingDatabaseChangesUntilNextB0yyF":{"name":"stopObservingDatabaseChangesUntilNextTransaction()","abstract":"

After this method has been called, the databaseDidChange(with:)","parent_name":"TransactionObserver"},"Protocols/SQLExpressible.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","abstract":"

Returns an SQL expression.

","parent_name":"SQLExpressible"},"Protocols/SQLExpressible.html#/s:4GRDB14SQLExpressiblePAASYRzAaB8RawValueSYRpzrlE13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"SQLExpressible"},"Protocols/SQLExpressible.html#/s:4GRDB14SQLExpressiblePA2A6ColumnVRszrlE5rowIDAEvpZ":{"name":"rowID","abstract":"

The hidden rowID column

","parent_name":"SQLExpressible"},"Protocols/SQLOrderingTerm.html#/s:4GRDB15SQLOrderingTermP11sqlOrderingAA0B0Vvp":{"name":"sqlOrdering","abstract":"

Returns an SQL ordering.

","parent_name":"SQLOrderingTerm"},"Protocols/SQLSelectable.html#/s:4GRDB13SQLSelectableP12sqlSelectionAA12SQLSelectionVvp":{"name":"sqlSelection","abstract":"

Returns an SQL selection.

","parent_name":"SQLSelectable"},"Protocols/StatementColumnConvertible.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Initializes a value from a raw SQLite statement pointer, if possible.

","parent_name":"StatementColumnConvertible"},"Protocols/StatementBinding.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","abstract":"

Binds a statement argument.

","parent_name":"StatementBinding"},"Protocols/RowAdapter.html#/s:4GRDB10RowAdapterPAAE12addingScopesyAaB_pSDySSAaB_pGF":{"name":"addingScopes(_:)","abstract":"

Returns an adapter based on self, with added scopes.

","parent_name":"RowAdapter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP5writeyqd__qd__AA0B0CKXEKlF":{"name":"write(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP10asyncWrite_10completionyqd__AA0B0CKc_yAG_s6ResultOyqd__s5Error_pGtctlF":{"name":"asyncWrite(_:completion:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","abstract":"

Concurrently executes a read-only block in a protected dispatch queue.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE3add19transactionObserver6extentyAA011TransactionF0_p_AA0B0C0H17ObservationExtentOtF":{"name":"add(transactionObserver:extent:)","abstract":"

Add a transaction observer, so that it gets notified of","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE6remove19transactionObserveryAA011TransactionF0_p_tF":{"name":"remove(transactionObserver:)","abstract":"

Undocumented

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE5eraseyyKF":{"name":"erase()","abstract":"

Erases the content of the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE6vacuumyyKF":{"name":"vacuum()","abstract":"

Rebuilds the database file, repacking it into a minimal amount of","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/vacuum(into:)":{"name":"vacuum(into:)","abstract":"

Creates a new database file at the specified path with a minimum","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE6vacuum4intoySS_tKF":{"name":"vacuum(into:)","abstract":"

Creates a new database file at the specified path with a minimum","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher7updatesAA0B10PublishersO5WriteVy_qd__Gqd__AA0B0CKc_tlF":{"name":"writePublisher(updates:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher9receiveOn7updatesAA0B10PublishersO5WriteVy_qd_0_Gqd___qd_0_AA0B0CKct7Combine9SchedulerRd__r0_lF":{"name":"writePublisher(receiveOn:updates:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher7updates8thenReadAA0B10PublishersO5WriteVy_qd_0_Gqd__AA0B0CKc_qd_0_AM_qd__tKctr0_lF":{"name":"writePublisher(updates:thenRead:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/DatabaseWriter.html#/s:4GRDB14DatabaseWriterPAAE14writePublisher9receiveOn7updates8thenReadAA0B10PublishersO5WriteVy_qd_1_Gqd___qd_0_AA0B0CKcqd_1_AN_qd_0_tKct7Combine9SchedulerRd__r1_lF":{"name":"writePublisher(receiveOn:updates:thenRead:)","abstract":"

Returns a Publisher that asynchronously writes into the database.

","parent_name":"DatabaseWriter"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestP10RowDecoderQa":{"name":"RowDecoder","abstract":"

The type that tells how fetched database rows should be interpreted.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestP012makePreparedC0_15forSingleResultAA0eC0VAA8DatabaseC_SbtKF":{"name":"makePreparedRequest(_:forSingleResult:)","abstract":"

Returns a PreparedRequest that is ready to be executed.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestP10fetchCountySiAA8DatabaseCKF":{"name":"fetchCount(_:)","abstract":"

Returns the number of rows fetched by the request.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPAAE14databaseRegionyAA08DatabaseE0VAA0F0CKF":{"name":"databaseRegion(_:)","abstract":"

Returns the database region that the request feeds from.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPAAE7adaptedyAA07AdaptedbC0VyxGAA10RowAdapter_pAA8DatabaseCKcF":{"name":"adapted(_:)","abstract":"

Returns an adapted request.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzrlE11fetchCursoryAA0deJ0CyAFGAA0D0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzrlE8fetchAllySayAFGAA0D0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzrlE8fetchOneyAFSgAA0D0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzSHAFRQrlE8fetchSetyShyAFGAA0D0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzrlE11fetchCursoryAA08NullablehiM0CyAIGAA0H0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzrlE8fetchAllySayAISgGAA0H0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzrlE8fetchOneyAISgAA0H0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzSHAIRQrlE8fetchSetyShyAISgGAA0H0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE11fetchCursoryAA0dG0CAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched rows.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE8fetchAllySayAEGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched rows.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE8fetchSetyShyAEGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched rows.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A3RowC0D7DecoderRtzrlE8fetchOneyAESgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first fetched row.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQrlE11fetchCursoryAA04FastdeL0CyAFGAA0D0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQrlE8fetchAllySayAFGAA0D0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQrlE8fetchOneyAFSgAA0D0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A24DatabaseValueConvertible10RowDecoderRpzAA015StatementColumnF0AFRQSHAFRQrlE8fetchSetyShyAFGAA0D0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQrlE11fetchCursoryAA012FastNullablehiO0CyAIGAA0H0CKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQrlE8fetchAllySayAISgGAA0H0CKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQrlE8fetchOneyAISgAA0H0CKF":{"name":"fetchOne(_:)","abstract":"

The first fetched value.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A17_OptionalProtocol10RowDecoderRpzAA24DatabaseValueConvertibleAE_7WrappedRPzAA015StatementColumnJ0AIRQSHAIRQrlE8fetchSetyShyAISgGAA0H0CKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched optional values.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzrlE11fetchCursoryAA0eI0CyAFGAA8DatabaseCKF":{"name":"fetchCursor(_:)","abstract":"

A cursor over fetched records.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzrlE8fetchAllySayAFGAA8DatabaseCKF":{"name":"fetchAll(_:)","abstract":"

An array of fetched records.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzrlE8fetchOneyAFSgAA8DatabaseCKF":{"name":"fetchOne(_:)","abstract":"

The first fetched record.

","parent_name":"FetchRequest"},"Protocols/FetchRequest.html#/s:4GRDB12FetchRequestPA2A15FetchableRecord10RowDecoderRpzSHAFRQrlE8fetchSetyShyAFGAA8DatabaseCKF":{"name":"fetchSet(_:)","abstract":"

A set of fetched records.

","parent_name":"FetchRequest"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a value initialized from dbValue, if possible.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE11fetchCursor_9arguments7adapterAA0bcF0CyxGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchAll_9arguments7adapterSayxGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchOne_9arguments7adapterxSgAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single value fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE11fetchCursor_3sql9arguments7adapterAA0bcF0CyxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchAll_3sql9arguments7adapterSayxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchOne_3sql9arguments7adapterxSgAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single value fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE11fetchCursoryAA0bcF0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchAllySayxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAAE8fetchOneyxSgAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single value fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAASHRzrlE8fetchSet_9arguments7adapterShyxGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAASHRzrlE8fetchSet_3sql9arguments7adapterShyxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAASHRzrlE8fetchSetyShyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE11fetchCursor_9arguments7adapterAA04FastbcH0CyxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchAll_9arguments7adapterSayxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchOne_9arguments7adapterxSgAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single value fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzSHRzrlE8fetchSet_9arguments7adapterShyxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of values fetched from a prepared statement.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE11fetchCursor_3sql9arguments7adapterAA04FastbcH0CyxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchAll_3sql9arguments7adapterSayxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchOne_3sql9arguments7adapterxSgAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single value fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzSHRzrlE8fetchSet_3sql9arguments7adapterShyxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of values fetched from an SQL query.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE11fetchCursoryAA04FastbcH0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchAllySayxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzrlE8fetchOneyxSgAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single value fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePA2A015StatementColumnD0RzSHRzrlE8fetchSetyShyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of values fetched from a fetch request.

","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAA10Foundation09ReferenceD0RzAaB0F4TypeAdEPRpzrlE08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseValueConvertible.html#/s:4GRDB24DatabaseValueConvertiblePAA10Foundation09ReferenceD0RzAaB0F4TypeAdEPRpzrlE04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"DatabaseValueConvertible"},"Protocols/DatabaseRegionConvertible.html#/s:4GRDB25DatabaseRegionConvertibleP08databaseC0yAA0bC0VAA0B0CKF":{"name":"databaseRegion(_:)","abstract":"

Returns a database region.

","parent_name":"DatabaseRegionConvertible"},"Protocols/DatabaseRegionConvertible.html#/s:4GRDB25DatabaseRegionConvertiblePA2A0bC0VRszrlE04fullB0AEvpZ":{"name":"fullDatabase","abstract":"

The region that covers the full database: all columns and all rows","parent_name":"DatabaseRegionConvertible"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","abstract":"

Closes the database connection with the sqlite3_close() function.

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","abstract":"

This method causes any pending database operation to abort and return at","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","abstract":"

Synchronously executes a read-only function that accepts a database","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","abstract":"

Asynchronously executes a read-only function that accepts a","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","abstract":"

Synchronously executes a function that accepts a database","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","abstract":"

Synchronously executes a function that accepts a database","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderPAAE6backup2toyAA0B6Writer_p_tKF":{"name":"backup(to:)","abstract":"

Copies the database contents into another database.

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderPAAE13readPublisher5valueAA0B10PublishersO4ReadVy_qd__Gqd__AA0B0CKc_tlF":{"name":"readPublisher(value:)","abstract":"

Returns a Publisher that asynchronously completes with a fetched value.

","parent_name":"DatabaseReader"},"Protocols/DatabaseReader.html#/s:4GRDB14DatabaseReaderPAAE13readPublisher9receiveOn5valueAA0B10PublishersO4ReadVy_qd_0_Gqd___qd_0_AA0B0CKct7Combine9SchedulerRd__r0_lF":{"name":"readPublisher(receiveOn:value:)","abstract":"

Returns a Publisher that asynchronously completes with a fetched value.

","parent_name":"DatabaseReader"},"Protocols/DatabaseAggregate.html#/s:4GRDB17DatabaseAggregatePxycfc":{"name":"init()","abstract":"

Creates an aggregate.

","parent_name":"DatabaseAggregate"},"Protocols/DatabaseAggregate.html#/s:4GRDB17DatabaseAggregateP4stepyySayAA0B5ValueVGKF":{"name":"step(_:)","abstract":"

This method is called at each step of the aggregation.

","parent_name":"DatabaseAggregate"},"Protocols/DatabaseAggregate.html#/s:4GRDB17DatabaseAggregateP8finalizeAA0B16ValueConvertible_pSgyKF":{"name":"finalize()","abstract":"

Returns the final result

","parent_name":"DatabaseAggregate"},"Protocols/Cursor.html#/s:4GRDB6CursorP7ElementQa":{"name":"Element","abstract":"

The type of element traversed by the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","abstract":"

Advances to the next element and returns it, or nil if no next element","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7isEmptySbyKF":{"name":"isEmpty()","abstract":"

Returns a Boolean value indicating whether the cursor contains","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE8contains5whereS2b7ElementQzKXE_tKF":{"name":"contains(where:)","abstract":"

Returns a Boolean value indicating whether the cursor contains an","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE10enumeratedAA010EnumeratedB0CyxGyF":{"name":"enumerated()","abstract":"

Returns a cursor of pairs (n, x), where n represents a consecutive","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6filteryAA06FilterB0CyxGSb7ElementQzKcF":{"name":"filter(_:)","abstract":"

Returns the elements of the cursor that satisfy the given predicate.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE5first5where7ElementQzSgSbAGKXE_tKF":{"name":"first(where:)","abstract":"

Returns the first element of the cursor that satisfies the given","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE10compactMapyAA0dB0CyAA06FilterB0CyAFyxqd__SgGGqd__GAI7ElementQzKclF":{"name":"compactMap(_:)","abstract":"

Returns a cursor over the concatenated non-nil results of mapping","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE4drop5whileAA09DropWhileB0CyxGSb7ElementQzKc_tF":{"name":"drop(while:)","abstract":"

Returns a cursor that skips any initial elements that satisfy","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE9dropFirstyAA04DropdB0CyxGSiF":{"name":"dropFirst(_:)","abstract":"

Returns a cursor containing all but the given number of initial","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE9dropFirstAA04DropdB0CyxGyF":{"name":"dropFirst()","abstract":"

Returns a cursor containing all but the first element of the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE8dropLastySay7ElementQzGSiKF":{"name":"dropLast(_:)","abstract":"

Returns an array containing all but the given number of final","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE8dropLastSay7ElementQzGyKF":{"name":"dropLast()","abstract":"

Returns an array containing all but the last element of the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7flatMapyAA07FlattenB0CyAA0dB0CyxAA03AnyB0Cy7ElementQyd__GGGqd__AKQzKcSTRd__lF":{"name":"flatMap(_:)","abstract":"

Returns a cursor over the concatenated results of mapping transform","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7flatMapyAA07FlattenB0CyAA0dB0Cyxqd__GGqd__7ElementQzKcAaBRd__lF":{"name":"flatMap(_:)","abstract":"

Returns a cursor over the concatenated results of mapping transform","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE7forEachyyy7ElementQzKXEKF":{"name":"forEach(_:)","abstract":"

Calls the given closure on each element in the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE3mapyAA03MapB0Cyxqd__Gqd__7ElementQzKclF":{"name":"map(_:)","abstract":"

Returns a cursor over the results of the transform function applied to","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE3max2by7ElementQzSgSbAG_AGtKXE_tKF":{"name":"max(by:)","abstract":"

Returns the maximum element in the cursor, using the given predicate as","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE3min2by7ElementQzSgSbAG_AGtKXE_tKF":{"name":"min(by:)","abstract":"

Returns the minimum element in the cursor, using the given predicate as","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6prefixyAA06PrefixB0CyxGSiF":{"name":"prefix(_:)","abstract":"

Returns a cursor, up to the specified maximum length, containing the","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6prefix5whileAA011PrefixWhileB0CyxGSb7ElementQzKc_tF":{"name":"prefix(while:)","abstract":"

Returns a cursor of the initial consecutive elements that satisfy","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6reduceyqd__qd___qd__qd___7ElementQztKXEtKlF":{"name":"reduce(_:_:)","abstract":"

Returns the result of calling the given combining closure with each","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6reduce4into_qd__qd___yqd__z_7ElementQztKXEtKlF":{"name":"reduce(into:_:)","abstract":"

Returns the result of calling the given combining closure with each","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAE6suffixySay7ElementQzGSiKF":{"name":"suffix(_:)","abstract":"

Returns an array, up to the given maximum length, containing the","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASQ7ElementRpzrlE8containsySbAEKF":{"name":"contains(_:)","abstract":"

Returns a Boolean value indicating whether the cursor contains the","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASL7ElementRpzrlE3maxAESgyKF":{"name":"max()","abstract":"

Returns the maximum element in the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASL7ElementRpzrlE3minAESgyKF":{"name":"min()","abstract":"

Returns the minimum element in the cursor.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPA2aB7ElementRpzrlE6joinedAA07FlattenB0CyxGyF":{"name":"joined()","abstract":"

Returns the elements of this cursor of cursors, concatenated.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAAST7ElementRpzrlE6joinedAA07FlattenB0CyAA03MapB0CyxAA03AnyB0CyAD_ADQZGGGyF":{"name":"joined()","abstract":"

Returns the elements of this cursor of sequences, concatenated.

","parent_name":"Cursor"},"Protocols/Cursor.html#/s:4GRDB6CursorPAASy7ElementRpzrlE6joined9separatorS2S_tKF":{"name":"joined(separator:)","abstract":"

Returns the elements of this cursor of sequences, concatenated.

","parent_name":"Cursor"},"Protocols/Cursor.html":{"name":"Cursor","abstract":"

A type that supplies the values of some external resource, one at a time.

"},"Protocols/DatabaseAggregate.html":{"name":"DatabaseAggregate","abstract":"

The protocol for custom SQLite aggregates.

"},"Protocols/DatabaseReader.html":{"name":"DatabaseReader","abstract":"

DatabaseReader is the protocol for all types that can fetch values from"},"Protocols/DatabaseRegionConvertible.html":{"name":"DatabaseRegionConvertible","abstract":"

DatabaseRegionConvertible is the protocol for values that can be turned"},"Protocols/DatabaseValueConvertible.html":{"name":"DatabaseValueConvertible","abstract":"

Types that adopt DatabaseValueConvertible can be initialized from"},"Protocols/FetchRequest.html":{"name":"FetchRequest","abstract":"

The protocol for all requests that fetch database rows, and tell how those"},"Protocols/DatabaseWriter.html":{"name":"DatabaseWriter","abstract":"

DatabaseWriter is the protocol for all types that can write into an"},"Protocols/RowAdapter.html":{"name":"RowAdapter","abstract":"

RowAdapter is a protocol that helps two incompatible row interfaces"},"Protocols/StatementBinding.html":{"name":"StatementBinding","abstract":"

Undocumented

"},"Protocols/StatementColumnConvertible.html":{"name":"StatementColumnConvertible","abstract":"

The StatementColumnConvertible protocol grants access to the low-level C"},"Protocols/SQLSelectable.html":{"name":"SQLSelectable","abstract":"

SQLSelectable is the protocol for types that can be selected, as"},"Protocols/SQLOrderingTerm.html":{"name":"SQLOrderingTerm","abstract":"

The protocol for all types that can be used as an SQL ordering term, as"},"Protocols/SQLExpressible.html":{"name":"SQLExpressible","abstract":"

SQLExpressible is the protocol for all types that can be used as an"},"Protocols/TransactionObserver.html":{"name":"TransactionObserver","abstract":"

A transaction observer is notified of all changes and transactions committed"},"Protocols/FTS5CustomTokenizer.html":{"name":"FTS5CustomTokenizer","abstract":"

The protocol for custom FTS5 tokenizers.

"},"Protocols/FTS5Tokenizer.html":{"name":"FTS5Tokenizer","abstract":"

The protocol for FTS5 tokenizers

"},"Protocols/FTS5WrapperTokenizer.html":{"name":"FTS5WrapperTokenizer","abstract":"

The protocol for custom FTS5 tokenizers that wrap another tokenizer.

"},"Protocols/TableRequest.html":{"name":"TableRequest","abstract":"

The protocol for all requests that feed from a database table

"},"Protocols/TableRecord.html":{"name":"TableRecord","abstract":"

Types that adopt TableRecord declare a particular relationship with"},"Protocols/ColumnExpression.html":{"name":"ColumnExpression","abstract":"

Adopt the ColumnExpression protocol when you define a column type.

"},"Protocols/Association.html":{"name":"Association","abstract":"

The base protocol for all associations that define a connection between two"},"Protocols/AssociationToOne.html":{"name":"AssociationToOne","abstract":"

The base protocol for all associations that define a one-to-one connection.

"},"Protocols/AssociationToMany.html":{"name":"AssociationToMany","abstract":"

The base protocol for all associations that define a one-to-many connection.

"},"Protocols/TypedRequest.html":{"name":"TypedRequest","abstract":"

The protocol for all requests that know how database rows should"},"Protocols/SelectionRequest.html":{"name":"SelectionRequest","abstract":"

The protocol for all requests that can refine their selection.

"},"Protocols/FilteredRequest.html":{"name":"FilteredRequest","abstract":"

The protocol for all requests that can be filtered.

"},"Protocols/AggregatingRequest.html":{"name":"AggregatingRequest","abstract":"

The protocol for all requests that can aggregate.

"},"Protocols/OrderedRequest.html":{"name":"OrderedRequest","abstract":"

The protocol for all requests that can be ordered.

"},"Protocols/JoinableRequest.html":{"name":"JoinableRequest","abstract":"

The protocol for all requests that can be associated.

"},"Protocols/DerivableRequest.html":{"name":"DerivableRequest","abstract":"

The base protocol for all requests that can be refined.

"},"Protocols/SQLSpecificExpressible.html":{"name":"SQLSpecificExpressible","abstract":"

SQLSpecificExpressible is a protocol for all database-specific types that"},"Protocols/SQLSubqueryable.html":{"name":"SQLSubqueryable","abstract":"

The protocol for types that can be embedded as a subquery.

"},"Protocols/VirtualTableModule.html":{"name":"VirtualTableModule","abstract":"

The protocol for SQLite virtual table modules. It lets you define a DSL for"},"Protocols/EncodableRecord.html":{"name":"EncodableRecord","abstract":"

Types that adopt EncodableRecord can be encoded into the database.

"},"Protocols/FetchableRecord.html":{"name":"FetchableRecord","abstract":"

Types that adopt FetchableRecord can be initialized from a database Row.

"},"Protocols/MutablePersistableRecord.html":{"name":"MutablePersistableRecord","abstract":"

Types that adopt MutablePersistableRecord can be inserted, updated,"},"Protocols/PersistableRecord.html":{"name":"PersistableRecord","abstract":"

Types that adopt PersistableRecord can be inserted, updated, and deleted.

"},"Protocols/DatabaseCancellable.html":{"name":"DatabaseCancellable","abstract":"

A protocol indicating that an activity or action supports cancellation.

"},"Protocols.html#/s:4GRDB12ValueReducerP":{"name":"ValueReducer","abstract":"

The ValueReducer protocol supports ValueObservation.

"},"Functions.html#/s:4GRDB20splittingRowAdapters12columnCountsSayAA0C7Adapter_pGSaySiG_tF":{"name":"splittingRowAdapters(columnCounts:)","abstract":"

Returns an array of row adapters that split a row according to the input"},"Functions.html#/s:4GRDB1nopyAA20AssociationAggregateVyxGAElF":{"name":"!(_:)","abstract":"

Returns a logically negated aggregate.

"},"Functions.html#/s:4GRDB2aaoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"&&(_:_:)","abstract":"

Groups two aggregates with the AND SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"||(_:_:)","abstract":"

Groups two aggregates with the OR SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGAE_SbtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB2eeoiyAA20AssociationAggregateVyxGSb_AEtlF":{"name":"==(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGAE_SbtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB2neoiyAA20AssociationAggregateVyxGSb_AEtlF":{"name":"!=(_:_:)","abstract":"

Returns an aggregate that checks the boolean value of an aggregate.

"},"Functions.html#/s:4GRDB3eeeoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"===(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"===(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"===(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"!==(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"!==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"!==(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"<=(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"<=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"<=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the <= SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"<(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"<(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"<(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the < SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":">(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":">(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":">(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the > SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":">=(_:_:)","abstract":"

Returns an aggregate that compares two aggregates with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":">=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":">=(_:_:)","abstract":"

Returns an aggregate that compares an aggregate with the >= SQL operator.

"},"Functions.html#/s:4GRDB1sopyAA20AssociationAggregateVyxGAElF":{"name":"-(_:)","abstract":"

Returns an arithmetically negated aggregate.

"},"Functions.html#/s:4GRDB1poiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"+(_:_:)","abstract":"

Returns an aggregate that sums two aggregates with the + SQL operator.

"},"Functions.html#/s:4GRDB1poiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"+(_:_:)","abstract":"

Returns an aggregate that sums an aggregate with the + SQL operator.

"},"Functions.html#/s:4GRDB1poiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"+(_:_:)","abstract":"

Returns an aggregate that sums an aggregate with the + SQL operator.

"},"Functions.html#/s:4GRDB1soiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"-(_:_:)","abstract":"

Returns an aggregate that substracts two aggregates with the - SQL operator.

"},"Functions.html#/s:4GRDB1soiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"-(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the - SQL operator.

"},"Functions.html#/s:4GRDB1soiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"-(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the - SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"*(_:_:)","abstract":"

Returns an aggregate that multiplies two aggregates with the * SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"*(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the * SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"*(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the * SQL operator.

"},"Functions.html#/s:4GRDB1doiyAA20AssociationAggregateVyxGAE_AEtlF":{"name":"/(_:_:)","abstract":"

Returns an aggregate that multiplies two aggregates with the / SQL operator.

"},"Functions.html#/s:4GRDB1doiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"/(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the / SQL operator.

"},"Functions.html#/s:4GRDB1doiyAA20AssociationAggregateVyxGAA14SQLExpressible_p_AEtlF":{"name":"/(_:_:)","abstract":"

Returns an aggregate that substracts an aggregate with the / SQL operator.

"},"Functions.html#/s:4GRDB2qqoiyAA20AssociationAggregateVyxGAE_AA14SQLExpressible_ptlF":{"name":"??(_:_:)","abstract":"

Returns an aggregate that evaluates the IFNULL SQL function.

"},"Functions.html#/s:4GRDB2peoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"+=(_:_:)","abstract":"

Creates an assignment that adds a value

"},"Functions.html#/s:4GRDB2seoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"-=(_:_:)","abstract":"

Creates an assignment that subtracts a value

"},"Functions.html#/s:4GRDB2meoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"*=(_:_:)","abstract":"

Creates an assignment that multiplies by a value

"},"Functions.html#/s:4GRDB2deoiyAA16ColumnAssignmentVAA0C10Expression_p_AA14SQLExpressible_ptF":{"name":"/=(_:_:)","abstract":"

Creates an assignment that divides by a value

"},"Functions.html#/s:4GRDB3absyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"abs(_:)","abstract":"

Returns an expression that evaluates the ABS SQL function.

"},"Functions.html#/s:4GRDB7averageyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"average(_:)","abstract":"

Returns an expression that evaluates the AVG SQL function.

"},"Functions.html#/s:4GRDB5countyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"count(_:)","abstract":"

Returns an expression that evaluates the COUNT SQL function.

"},"Functions.html#/s:4GRDB5count8distinctAA13SQLExpressionVAA22SQLSpecificExpressible_p_tF":{"name":"count(distinct:)","abstract":"

Returns an expression that evaluates the COUNT(DISTINCT) SQL function.

"},"Functions.html#/s:4GRDB2qqoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"??(_:_:)","abstract":"

Returns an expression that evaluates the IFNULL SQL function.

"},"Functions.html#/s:4GRDB6lengthyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"length(_:)","abstract":"

Returns an expression that evaluates the LENGTH SQL function.

"},"Functions.html#/s:4GRDB3maxyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"max(_:)","abstract":"

Returns an expression that evaluates the MAX SQL function.

"},"Functions.html#/s:4GRDB3minyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"min(_:)","abstract":"

Returns an expression that evaluates the MIN SQL function.

"},"Functions.html#/s:4GRDB3sumyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"sum(_:)","abstract":"

Returns an expression that evaluates the SUM SQL function.

"},"Functions.html#/s:4GRDB9julianDayyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA15SQLDateModifierOdtF":{"name":"julianDay(_:_:)","abstract":"

Returns an expression that evaluates the JULIANDAY SQL function.

"},"Functions.html#/s:4GRDB8dateTimeyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA15SQLDateModifierOdtF":{"name":"dateTime(_:_:)","abstract":"

Returns an expression that evaluates the DATETIME SQL function.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"==(_:_:)","abstract":"

An SQL expression that compares two expressions with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_SbtF":{"name":"==(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"==(_:_:)","abstract":"

An SQL expression that compares two expressions with the = SQL operator.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVSb_AA22SQLSpecificExpressible_ptF":{"name":"==(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2eeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"==(_:_:)","abstract":"

An SQL expression that compares two expressions with the = SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"!=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_SbtF":{"name":"!=(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"!=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <> SQL operator.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVSb_AA22SQLSpecificExpressible_ptF":{"name":"!=(_:_:)","abstract":"

An SQL expression that checks the boolean value of an expression.

"},"Functions.html#/s:4GRDB2neoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"!=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <> SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"===(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"===(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS SQL operator.

"},"Functions.html#/s:4GRDB3eeeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"===(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_pSgtF":{"name":"!==(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA13SQLExpressionVAA14SQLExpressible_pSg_AA22SQLSpecificExpressible_ptF":{"name":"!==(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB3neeoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"!==(_:_:)","abstract":"

An SQL expression that compares two expressions with the IS NOT SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"<(_:_:)","abstract":"

An SQL expression that compares two expressions with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"<(_:_:)","abstract":"

An SQL expression that compares two expressions with the < SQL operator.

"},"Functions.html#/s:4GRDB1loiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"<(_:_:)","abstract":"

An SQL expression that compares two expressions with the < SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"<=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"<=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <= SQL operator.

"},"Functions.html#/s:4GRDB2leoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"<=(_:_:)","abstract":"

An SQL expression that compares two expressions with the <= SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":">(_:_:)","abstract":"

An SQL expression that compares two expressions with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":">(_:_:)","abstract":"

An SQL expression that compares two expressions with the > SQL operator.

"},"Functions.html#/s:4GRDB1goiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":">(_:_:)","abstract":"

An SQL expression that compares two expressions with the > SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":">=(_:_:)","abstract":"

An SQL expression that compares two expressions with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":">=(_:_:)","abstract":"

An SQL expression that compares two expressions with the >= SQL operator.

"},"Functions.html#/s:4GRDB2geoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":">=(_:_:)","abstract":"

An SQL expression that compares two expressions with the >= SQL operator.

"},"Functions.html#/s:4GRDB1moiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"*(_:_:)","abstract":"

An SQL arithmetic multiplication.

"},"Functions.html#/s:4GRDB1moiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"*(_:_:)","abstract":"

An SQL arithmetic multiplication.

"},"Functions.html#/s:4GRDB1moiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"*(_:_:)","abstract":"

An SQL arithmetic multiplication.

"},"Functions.html#/s:4GRDB1doiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"/(_:_:)","abstract":"

An SQL arithmetic division.

"},"Functions.html#/s:4GRDB1doiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"/(_:_:)","abstract":"

An SQL arithmetic division.

"},"Functions.html#/s:4GRDB1doiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"/(_:_:)","abstract":"

An SQL arithmetic division.

"},"Functions.html#/s:4GRDB1poiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"+(_:_:)","abstract":"

An SQL arithmetic addition.

"},"Functions.html#/s:4GRDB1poiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"+(_:_:)","abstract":"

An SQL arithmetic addition.

"},"Functions.html#/s:4GRDB1poiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"+(_:_:)","abstract":"

An SQL arithmetic addition.

"},"Functions.html#/s:4GRDB1sopyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"-(_:)","abstract":"

A negated SQL arithmetic expression.

"},"Functions.html#/s:4GRDB1soiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"-(_:_:)","abstract":"

An SQL arithmetic substraction.

"},"Functions.html#/s:4GRDB1soiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"-(_:_:)","abstract":"

An SQL arithmetic substraction.

"},"Functions.html#/s:4GRDB1soiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"-(_:_:)","abstract":"

An SQL arithmetic substraction.

"},"Functions.html#/s:4GRDB2aaoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"&&(_:_:)","abstract":"

A logical SQL expression with the AND SQL operator.

"},"Functions.html#/s:4GRDB2aaoiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"&&(_:_:)","abstract":"

A logical SQL expression with the AND SQL operator.

"},"Functions.html#/s:4GRDB2aaoiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"&&(_:_:)","abstract":"

A logical SQL expression with the AND SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AA14SQLExpressible_ptF":{"name":"||(_:_:)","abstract":"

A logical SQL expression with the OR SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA13SQLExpressionVAA14SQLExpressible_p_AA22SQLSpecificExpressible_ptF":{"name":"||(_:_:)","abstract":"

A logical SQL expression with the OR SQL operator.

"},"Functions.html#/s:4GRDB2oooiyAA13SQLExpressionVAA22SQLSpecificExpressible_p_AaE_ptF":{"name":"||(_:_:)","abstract":"

A logical SQL expression with the OR SQL operator.

"},"Functions.html#/s:4GRDB1nopyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"!(_:)","abstract":"

A negated logical SQL expression with the NOT SQL operator.

"},"Functions.html#/s:4GRDB21databaseQuestionMarks5countSSSi_tF":{"name":"databaseQuestionMarks(count:)","abstract":"

Return as many question marks separated with commas as the count argument.

"},"Extensions/CountableClosedRange.html#/s:SN4GRDBAA14SQLExpressibleRzSxRzSZ6StrideSxRpzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"CountableClosedRange"},"Extensions/CountableRange.html#/s:Sn4GRDBAA14SQLExpressibleRzSxRzSZ6StrideSxRpzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"CountableRange"},"Extensions/ClosedRange.html#/s:SN4GRDBAA14SQLExpressibleRzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"ClosedRange"},"Extensions/Range.html#/s:Sn4GRDBAA14SQLExpressibleRzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in a range.

","parent_name":"Range"},"Extensions/ColumnExpression.html#/match(_:)":{"name":"match(_:)","abstract":"

A matching SQL expression with the MATCH SQL operator.

","parent_name":"ColumnExpression"},"Extensions/TableRecord.html#/matching(_:)":{"name":"matching(_:)","abstract":"

Returns a QueryInterfaceRequest with a matching predicate.

","parent_name":"TableRecord"},"Extensions/TableRequest.html#/matching(_:)":{"name":"matching(_:)","abstract":"

Creates a request with a full-text predicate added to the eventual","parent_name":"TableRequest"},"Extensions/Column.html#/rank":{"name":"rank","abstract":"

The FTS5 rank column

","parent_name":"Column"},"Extensions/String.html#/s:SS4GRDBE15sqliteStatement5indexSSs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"String"},"Extensions/String.html#/s:SS4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"String"},"Extensions/String.html#/s:SS4GRDBE17fromDatabaseValueySSSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a String initialized from dbValue, if possible.

","parent_name":"String"},"Extensions/String.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"String"},"Extensions/String.html#/s:SS4GRDBE24quotedDatabaseIdentifierSSvp":{"name":"quotedDatabaseIdentifier","abstract":"

Returns the receiver, quoted for safe insertion as an identifier in an","parent_name":"String"},"Extensions/Float.html#/s:Sf4GRDBE15sqliteStatement5indexSfs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Float"},"Extensions/Float.html#/s:Sf4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Float"},"Extensions/Float.html#/s:Sf4GRDBE17fromDatabaseValueySfSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Float initialized from dbValue, if possible.

","parent_name":"Float"},"Extensions/Float.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Float"},"Extensions/Double.html#/s:Sd4GRDBE15sqliteStatement5indexSds13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Double"},"Extensions/Double.html#/s:Sd4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Double"},"Extensions/Double.html#/s:Sd4GRDBE17fromDatabaseValueySdSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Double initialized from dbValue, if possible.

","parent_name":"Double"},"Extensions/Double.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Double"},"Extensions/UInt64.html#/s:s6UInt64V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt64"},"Extensions/UInt64.html#/s:s6UInt64V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt64"},"Extensions/UInt64.html#/s:s6UInt64V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt64 initialized from dbValue, if possible.

","parent_name":"UInt64"},"Extensions/UInt64.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt64"},"Extensions/UInt32.html#/s:s6UInt32V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt32"},"Extensions/UInt32.html#/s:s6UInt32V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt32"},"Extensions/UInt32.html#/s:s6UInt32V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt32 initialized from dbValue, if possible.

","parent_name":"UInt32"},"Extensions/UInt32.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt32"},"Extensions/UInt16.html#/s:s6UInt16V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt16"},"Extensions/UInt16.html#/s:s6UInt16V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt16"},"Extensions/UInt16.html#/s:s6UInt16V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt16 initialized from dbValue, if possible.

","parent_name":"UInt16"},"Extensions/UInt16.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt16"},"Extensions/UInt8.html#/s:s5UInt8V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt8"},"Extensions/UInt8.html#/s:s5UInt8V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt8"},"Extensions/UInt8.html#/s:s5UInt8V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an UInt8 initialized from dbValue, if possible.

","parent_name":"UInt8"},"Extensions/UInt8.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt8"},"Extensions/UInt.html#/s:Su4GRDBE15sqliteStatement5indexSuSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"UInt"},"Extensions/UInt.html#/s:Su4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"UInt"},"Extensions/UInt.html#/s:Su4GRDBE17fromDatabaseValueySuSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int initialized from dbValue, if possible.

","parent_name":"UInt"},"Extensions/UInt.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"UInt"},"Extensions/Int64.html#/s:s5Int64V4GRDBE15sqliteStatement5indexABs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int64"},"Extensions/Int64.html#/s:s5Int64V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int64"},"Extensions/Int64.html#/s:s5Int64V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int64 initialized from dbValue, if possible.

","parent_name":"Int64"},"Extensions/Int64.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int64"},"Extensions/Int32.html#/s:s5Int32V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_ABtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int32"},"Extensions/Int32.html#/s:s5Int32V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int32"},"Extensions/Int32.html#/s:s5Int32V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int32 initialized from dbValue, if possible.

","parent_name":"Int32"},"Extensions/Int32.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int32"},"Extensions/Int16.html#/s:s5Int16V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int16"},"Extensions/Int16.html#/s:s5Int16V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int16"},"Extensions/Int16.html#/s:s5Int16V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int16 initialized from dbValue, if possible.

","parent_name":"Int16"},"Extensions/Int16.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int16"},"Extensions/Int8.html#/s:s4Int8V4GRDBE15sqliteStatement5indexABSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int8"},"Extensions/Int8.html#/s:s4Int8V4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int8"},"Extensions/Int8.html#/s:s4Int8V4GRDBE17fromDatabaseValueyABSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int8 initialized from dbValue, if possible.

","parent_name":"Int8"},"Extensions/Int8.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int8"},"Extensions/Int.html#/s:Si4GRDBE15sqliteStatement5indexSiSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Int"},"Extensions/Int.html#/s:Si4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Int"},"Extensions/Int.html#/s:Si4GRDBE17fromDatabaseValueySiSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an Int initialized from dbValue, if possible.

","parent_name":"Int"},"Extensions/Int.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Int"},"Extensions/Bool.html#/s:Sb4GRDBE15sqliteStatement5indexSbs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Bool"},"Extensions/Bool.html#/s:Sb4GRDBE13databaseValueAA08DatabaseC0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Bool"},"Extensions/Bool.html#/s:Sb4GRDBE17fromDatabaseValueySbSgAA0cD0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Bool initialized from dbValue, if possible.

","parent_name":"Bool"},"Extensions/Bool.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Bool"},"Extensions/UUID.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"UUID"},"Extensions/UUID.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"UUID"},"Extensions/UUID.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","parent_name":"UUID"},"Extensions/NSUUID.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"NSUUID"},"Extensions/NSUUID.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"NSUUID"},"Extensions/NSURL.html#/s:So5NSURLC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.","parent_name":"NSURL"},"Extensions/NSURL.html#/s:So5NSURLC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSURL initialized from dbValue, if possible.

","parent_name":"NSURL"},"Extensions/NSString.html#/s:So8NSStringC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"NSString"},"Extensions/NSString.html#/s:So8NSStringC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSString initialized from dbValue, if possible.

","parent_name":"NSString"},"Extensions/NSNumber.html#/s:So8NSNumberC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"NSNumber"},"Extensions/NSNumber.html#/s:So8NSNumberC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSNumber initialized from dbValue, if possible.

","parent_name":"NSNumber"},"Extensions/NSNull.html#/s:So6NSNullC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns DatabaseValue.null.

","parent_name":"NSNull"},"Extensions/NSNull.html#/s:So6NSNullC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns nil.

","parent_name":"NSNull"},"Extensions/NSData.html#/s:So6NSDataC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"NSData"},"Extensions/NSData.html#/s:So6NSDataC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns an NSData initialized from dbValue, if it contains","parent_name":"NSData"},"Extensions/Decimal.html#/s:4GRDB24DatabaseValueConvertibleP08databaseC0AA0bC0Vvp":{"name":"databaseValue","parent_name":"Decimal"},"Extensions/Decimal.html#/s:4GRDB24DatabaseValueConvertibleP04frombC0yxSgAA0bC0VFZ":{"name":"fromDatabaseValue(_:)","parent_name":"Decimal"},"Extensions/Decimal.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","parent_name":"Decimal"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE13databaseValueAD08DatabaseE0Vvp":{"name":"databaseValue","abstract":"

Returns a database value that contains the date encoded as","parent_name":"Date"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE17fromDatabaseValueyACSgAD0eF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a date initialized from dbValue, if possible.

","parent_name":"Date"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE9julianDayACSgSd_tcfc":{"name":"init(julianDay:)","abstract":"

Creates a date from a Julian Day.

","parent_name":"Date"},"Extensions/Date.html#/s:10Foundation4DateV4GRDBE15sqliteStatement5indexACSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","abstract":"

Returns a value initialized from a raw SQLite statement pointer.

","parent_name":"Date"},"Extensions/NSDate.html#/s:So6NSDateC4GRDBE13databaseValueAC08DatabaseD0Vvp":{"name":"databaseValue","abstract":"

Returns a database value that contains the date encoded as","parent_name":"NSDate"},"Extensions/NSDate.html#/s:So6NSDateC4GRDBE17fromDatabaseValueyABXDSgAC0dE0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a date initialized from dbValue, if possible.

","parent_name":"NSDate"},"Extensions/Data.html#/s:4GRDB26StatementColumnConvertibleP06sqliteB05indexxSgs13OpaquePointerV_s5Int32Vtcfc":{"name":"init(sqliteStatement:index:)","parent_name":"Data"},"Extensions/Data.html#/s:10Foundation4DataV4GRDBE13databaseValueAD08DatabaseE0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"Data"},"Extensions/Data.html#/s:10Foundation4DataV4GRDBE17fromDatabaseValueyACSgAD0eF0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a Data initialized from dbValue, if it contains","parent_name":"Data"},"Extensions/Data.html#/s:4GRDB16StatementBindingP4bind2to2ats5Int32Vs13OpaquePointerV_AHtF":{"name":"bind(to:at:)","parent_name":"Data"},"Extensions/CGFloat.html#/s:12CoreGraphics7CGFloatV4GRDBE13databaseValueAD08DatabaseF0Vvp":{"name":"databaseValue","abstract":"

Returns a value that can be stored in the database.

","parent_name":"CGFloat"},"Extensions/CGFloat.html#/s:12CoreGraphics7CGFloatV4GRDBE17fromDatabaseValueyACSgAD0fG0VFZ":{"name":"fromDatabaseValue(_:)","abstract":"

Returns a CGFloat initialized from dbValue, if possible.

","parent_name":"CGFloat"},"Extensions/Collection.html#/s:Sl4GRDBAA3SQLV7ElementRtzrlE6joined9separatorACSS_tF":{"name":"joined(separator:)","abstract":"

Returns the concatenated SQL literal of this collection of literals,","parent_name":"Collection"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE11fetchCursor_9arguments7adapterAA08NullablebcF0CyxGAA9StatementC_AA0J9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE8fetchAll_9arguments7adapterSayxSgGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzSHRzlE8fetchSet_9arguments7adapterShyxSgGAA9StatementC_AA0I9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE11fetchCursor_3sql9arguments7adapterAA08NullablebcF0CyxGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE8fetchAll_3sql9arguments7adapterSayxSgGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzSHRzlE8fetchSet_3sql9arguments7adapterShyxSgGAA0B0C_SSAA18StatementArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE11fetchCursoryAA08NullablebcF0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzlE8fetchAllySayxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzSHRzlE8fetchSetyShyxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE11fetchCursor_9arguments7adapterAA012FastNullablebcH0CyxGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE8fetchAll_9arguments7adapterSayxSgGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzSHRzlE8fetchSet_9arguments7adapterShyxSgGAA0E0C_AA0E9ArgumentsVSgAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from a prepared statement.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE11fetchCursor_3sql9arguments7adapterAA012FastNullablebcH0CyxGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE8fetchAll_3sql9arguments7adapterSayxSgGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzSHRzlE8fetchSet_3sql9arguments7adapterShyxSgGAA0B0C_SSAA0E9ArgumentsVAA10RowAdapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of optional values fetched from an SQL query.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE11fetchCursoryAA012FastNullablebcH0CyxGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzlE8fetchAllySayxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Optional.html#/s:Sq4GRDBAA24DatabaseValueConvertibleRzAA015StatementColumnD0RzSHRzlE8fetchSetyShyxSgGAA0B0C_qd__tKAA12FetchRequestRd__lFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of optional values fetched from a fetch request.

","parent_name":"Optional"},"Extensions/Database.html#/usePassphrase(_:)":{"name":"usePassphrase(_:)","abstract":"

Sets the passphrase used to crypt and decrypt an SQLCipher database.

","parent_name":"Database"},"Extensions/Database.html#/changePassphrase(_:)":{"name":"changePassphrase(_:)","abstract":"

Changes the passphrase used by an SQLCipher encrypted database.

","parent_name":"Database"},"Extensions/Database.html#/dropFTS5SynchronizationTriggers(forTable:)":{"name":"dropFTS5SynchronizationTriggers(forTable:)","abstract":"

Deletes the synchronization triggers for a synchronized FTS5 table

","parent_name":"Database"},"Extensions/Database.html#/add(tokenizer:)":{"name":"add(tokenizer:)","abstract":"

Add a custom FTS5 tokenizer.

","parent_name":"Database"},"Extensions/Database.html#/makeFTS5Pattern(rawPattern:forTable:)":{"name":"makeFTS5Pattern(rawPattern:forTable:)","abstract":"

Creates a pattern from a raw pattern string; throws DatabaseError on","parent_name":"Database"},"Extensions/Database.html#/makeTokenizer(_:)":{"name":"makeTokenizer(_:)","abstract":"

Creates an FTS5 tokenizer, given its descriptor.

","parent_name":"Database"},"Extensions/Sequence.html#/s:ST4GRDBE7flatMapyAA13FlattenCursorCyAA0cE0CyAA03AnyE0Cy7ElementQzGqd__GGqd__AJKcAA0E0Rd__lF":{"name":"flatMap(_:)","abstract":"

Returns a cursor over the concatenated results of mapping transform","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA3SQLV7ElementRtzrlE6joined9separatorACSS_tF":{"name":"joined(separator:)","abstract":"

Returns the concatenated SQL literal of this sequence of literals,","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA22SQLSpecificExpressible7ElementRpzrlE6joined8operatorAA13SQLExpressionVAH25AssociativeBinaryOperatorV_tF":{"name":"joined(operator:)","abstract":"

Returns an expression by joining all elements with an associative SQL","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA22SQLSpecificExpressible_p7ElementRtzrlE6joined8operatorAA13SQLExpressionVAH25AssociativeBinaryOperatorV_tF":{"name":"joined(operator:)","abstract":"

Returns an expression by joining all elements with an associative SQL","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA14SQLExpressible7ElementRpzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in","parent_name":"Sequence"},"Extensions/Sequence.html#/s:ST4GRDBAA14SQLExpressible_p7ElementRtzrlE8containsyAA13SQLExpressionVAA22SQLSpecificExpressible_pF":{"name":"contains(_:)","abstract":"

An SQL expression that checks the inclusion of an expression in","parent_name":"Sequence"},"Extensions/Set.html#/s:Sh4GRDBEyShyxGqd__Kc7ElementQyd__RszAA6CursorRd__lufc":{"name":"init(_:)","abstract":"

Creates a set containing the elements of a cursor.

","parent_name":"Set"},"Extensions/Set.html#/s:Sh4GRDBE_15minimumCapacityShyxGqd___SitKc7ElementQyd__RszAA6CursorRd__lufc":{"name":"init(_:minimumCapacity:)","abstract":"

Creates a set containing the elements of a cursor.

","parent_name":"Set"},"Extensions/Dictionary.html#/s:SD4GRDBE8grouping2bySDyxSay7ElementQyd__GGqd___xAEKXEtKcAFRs_AA6CursorRd__lufc":{"name":"init(grouping:by:)","abstract":"

Creates a new dictionary whose keys are the groupings returned by the","parent_name":"Dictionary"},"Extensions/Dictionary.html#/s:SD4GRDBE15minimumCapacity8grouping2bySDyxSay7ElementQyd__GGSi_qd__xAFKXEtKcAGRs_AA6CursorRd__lufc":{"name":"init(minimumCapacity:grouping:by:)","abstract":"

Creates a new dictionary whose keys are the groupings returned by the","parent_name":"Dictionary"},"Extensions/Dictionary.html#/s:SD4GRDBE20uniqueKeysWithValuesSDyxq_Gqd___tKcAA6CursorRd__x_q_t7ElementRtd__lufc":{"name":"init(uniqueKeysWithValues:)","abstract":"

Creates a new dictionary from the key-value pairs in the given cursor.

","parent_name":"Dictionary"},"Extensions/Dictionary.html#/s:SD4GRDBE15minimumCapacity20uniqueKeysWithValuesSDyxq_GSi_qd__tKcAA6CursorRd__x_q_t7ElementRtd__lufc":{"name":"init(minimumCapacity:uniqueKeysWithValues:)","abstract":"

Creates a new dictionary from the key-value pairs in the given cursor.

","parent_name":"Dictionary"},"Extensions/RangeReplaceableCollection.html#/s:Sm4GRDBEyxqd__KcAA6CursorRd__7ElementQyd__ACRtzlufc":{"name":"init(_:)","abstract":"

Creates a collection containing the elements of a cursor.

","parent_name":"RangeReplaceableCollection"},"Extensions/RangeReplaceableCollection.html#/s:Sm4GRDBE_15minimumCapacityxqd___SitKcAA6CursorRd__7ElementQyd__ADRtzlufc":{"name":"init(_:minimumCapacity:)","abstract":"

Creates a collection containing the elements of a cursor.

","parent_name":"RangeReplaceableCollection"},"Extensions/RangeReplaceableCollection.html":{"name":"RangeReplaceableCollection"},"Extensions/Dictionary.html":{"name":"Dictionary"},"Extensions/Set.html":{"name":"Set"},"Extensions/Sequence.html":{"name":"Sequence"},"Extensions/Database.html":{"name":"Database"},"Extensions/Optional.html":{"name":"Optional","abstract":"

Swift’s Optional comes with built-in methods that allow to fetch cursors"},"Extensions/Collection.html":{"name":"Collection"},"Extensions/CGFloat.html":{"name":"CGFloat","abstract":"

CGFloat adopts DatabaseValueConvertible

"},"Extensions/Data.html":{"name":"Data","abstract":"

Data is convertible to and from DatabaseValue.

"},"Extensions/NSDate.html":{"name":"NSDate","abstract":"

NSDate is stored in the database using the format"},"Extensions/Date.html":{"name":"Date","abstract":"

Date is stored in the database using the format"},"Extensions/Decimal.html":{"name":"Decimal","abstract":"

Decimal adopts DatabaseValueConvertible

"},"Extensions/NSData.html":{"name":"NSData","abstract":"

NSData is convertible to and from DatabaseValue.

"},"Extensions/NSNull.html":{"name":"NSNull","abstract":"

NSNull adopts DatabaseValueConvertible

"},"Extensions/NSNumber.html":{"name":"NSNumber","abstract":"

NSNumber adopts DatabaseValueConvertible

"},"Extensions/NSString.html":{"name":"NSString","abstract":"

NSString adopts DatabaseValueConvertible

"},"Extensions/NSURL.html":{"name":"NSURL","abstract":"

NSURL stores its absoluteString in the database.

"},"Extensions.html#/s:10Foundation3URLV":{"name":"URL","abstract":"

URL stores its absoluteString in the database.

"},"Extensions/NSUUID.html":{"name":"NSUUID","abstract":"

NSUUID adopts DatabaseValueConvertible

"},"Extensions/UUID.html":{"name":"UUID","abstract":"

UUID adopts DatabaseValueConvertible

"},"Extensions/Bool.html":{"name":"Bool","abstract":"

Bool adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int.html":{"name":"Int","abstract":"

Int adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int8.html":{"name":"Int8","abstract":"

Int8 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int16.html":{"name":"Int16","abstract":"

Int16 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int32.html":{"name":"Int32","abstract":"

Int32 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Int64.html":{"name":"Int64","abstract":"

Int64 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt.html":{"name":"UInt","abstract":"

UInt adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt8.html":{"name":"UInt8","abstract":"

UInt8 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt16.html":{"name":"UInt16","abstract":"

UInt16 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt32.html":{"name":"UInt32","abstract":"

UInt32 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/UInt64.html":{"name":"UInt64","abstract":"

UInt64 adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Double.html":{"name":"Double","abstract":"

Double adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Float.html":{"name":"Float","abstract":"

Float adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/String.html":{"name":"String","abstract":"

String adopts DatabaseValueConvertible and StatementColumnConvertible.

"},"Extensions/Column.html":{"name":"Column"},"Extensions/TableRequest.html":{"name":"TableRequest"},"Extensions/TableRecord.html":{"name":"TableRecord"},"Extensions/ColumnExpression.html":{"name":"ColumnExpression"},"Extensions/Range.html":{"name":"Range"},"Extensions/ClosedRange.html":{"name":"ClosedRange"},"Extensions/CountableRange.html":{"name":"CountableRange"},"Extensions/CountableClosedRange.html":{"name":"CountableClosedRange"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO5FetchV":{"name":"Fetch","abstract":"

A reducer which passes raw fetched values through.

","parent_name":"ValueReducers"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO3MapV":{"name":"Map","abstract":"

A reducer whose values consist of those in a Base reducer","parent_name":"ValueReducers"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO16RemoveDuplicatesV":{"name":"RemoveDuplicates","abstract":"

See ValueObservation.removeDuplicates()

","parent_name":"ValueReducers"},"Enums/ValueReducers.html#/s:4GRDB13ValueReducersO5TraceV":{"name":"Trace","abstract":"

See ValueObservation.handleEvents()

","parent_name":"ValueReducers"},"Enums/SharedValueObservationExtent.html#/s:4GRDB28SharedValueObservationExtentO19observationLifetimeyA2CmF":{"name":"observationLifetime","abstract":"

The SharedValueObservation starts a single database observation, which","parent_name":"SharedValueObservationExtent"},"Enums/SharedValueObservationExtent.html#/s:4GRDB28SharedValueObservationExtentO13whileObservedyA2CmF":{"name":"whileObserved","abstract":"

The SharedValueObservation ends database observation when the number","parent_name":"SharedValueObservationExtent"},"Enums/PersistenceError.html#/s:4GRDB16PersistenceErrorO14recordNotFoundyACSS_SDySSAA13DatabaseValueVGtcACmF":{"name":"recordNotFound(databaseTableName:key:)","abstract":"

Thrown by MutablePersistableRecord.update(_:) methods when no matching","parent_name":"PersistenceError"},"Enums/DatabaseColumnDecodingStrategy.html#/s:4GRDB30DatabaseColumnDecodingStrategyO14useDefaultKeysyA2CmF":{"name":"useDefaultKeys","abstract":"

A key decoding strategy that doesn’t change key names during decoding.

","parent_name":"DatabaseColumnDecodingStrategy"},"Enums/DatabaseColumnDecodingStrategy.html#/s:4GRDB30DatabaseColumnDecodingStrategyO20convertFromSnakeCaseyA2CmF":{"name":"convertFromSnakeCase","abstract":"

A key decoding strategy that converts snake-case keys to camel-case keys.

","parent_name":"DatabaseColumnDecodingStrategy"},"Enums/DatabaseColumnDecodingStrategy.html#/s:4GRDB30DatabaseColumnDecodingStrategyO6customyACs9CodingKey_pSSccACmF":{"name":"custom(_:)","abstract":"

A key decoding strategy defined by the closure you supply.

","parent_name":"DatabaseColumnDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO010deferredToC0yA2CmF":{"name":"deferredToDate","abstract":"

The strategy that uses formatting from the Date structure.

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO026timeIntervalSinceReferenceC0yA2CmF":{"name":"timeIntervalSinceReferenceDate","abstract":"

Decodes numeric values as a number of seconds between the date and","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO21timeIntervalSince1970yA2CmF":{"name":"timeIntervalSince1970","abstract":"

Decodes numeric values as a number of seconds between the date and","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO21millisecondsSince1970yA2CmF":{"name":"millisecondsSince1970","abstract":"

Decodes numeric values as a number of milliseconds between the date and","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO7iso8601yA2CmF":{"name":"iso8601","abstract":"

Decodes dates according to the ISO 8601 standards

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO9formattedyACSo15NSDateFormatterCcACmF":{"name":"formatted(_:)","abstract":"

Decodes a String, according to the provided formatter

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseDateDecodingStrategy.html#/s:4GRDB28DatabaseDateDecodingStrategyO6customyAC10Foundation0C0VSgAA0B5ValueVccACmF":{"name":"custom(_:)","abstract":"

Decodes according to the user-provided function.

","parent_name":"DatabaseDateDecodingStrategy"},"Enums/DatabaseColumnEncodingStrategy.html#/s:4GRDB30DatabaseColumnEncodingStrategyO14useDefaultKeysyA2CmF":{"name":"useDefaultKeys","abstract":"

A key encoding strategy that doesn’t change key names during encoding.

","parent_name":"DatabaseColumnEncodingStrategy"},"Enums/DatabaseColumnEncodingStrategy.html#/s:4GRDB30DatabaseColumnEncodingStrategyO18convertToSnakeCaseyA2CmF":{"name":"convertToSnakeCase","abstract":"

A key encoding strategy that converts camel-case keys to snake-case keys.

","parent_name":"DatabaseColumnEncodingStrategy"},"Enums/DatabaseColumnEncodingStrategy.html#/s:4GRDB30DatabaseColumnEncodingStrategyO6customyACSSs9CodingKey_pccACmF":{"name":"custom(_:)","abstract":"

A key encoding strategy defined by the closure you supply.

","parent_name":"DatabaseColumnEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO14deferredToUUIDyA2CmF":{"name":"deferredToUUID","abstract":"

The strategy that uses formatting from the UUID type.

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO15uppercaseStringyA2CmF":{"name":"uppercaseString","abstract":"

Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO15lowercaseStringyA2CmF":{"name":"lowercaseString","abstract":"

Encodes UUIDs as lowercased strings such as “e621e1f8-c36c-495a-93fc-0c247a3e6e5f”

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseUUIDEncodingStrategy.html#/s:4GRDB28DatabaseUUIDEncodingStrategyO6stringACvpZ":{"name":"string","abstract":"

Encodes UUIDs as uppercased strings such as “E621E1F8-C36C-495A-93FC-0C247A3E6E5F”

","parent_name":"DatabaseUUIDEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO010deferredToC0yA2CmF":{"name":"deferredToDate","abstract":"

The strategy that uses formatting from the Date structure.

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO026timeIntervalSinceReferenceC0yA2CmF":{"name":"timeIntervalSinceReferenceDate","abstract":"

Encodes a Double: the number of seconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO21timeIntervalSince1970yA2CmF":{"name":"timeIntervalSince1970","abstract":"

Encodes a Double: the number of seconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO16secondsSince1970yA2CmF":{"name":"secondsSince1970","abstract":"

Encodes an Int64: the number of seconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO21millisecondsSince1970yA2CmF":{"name":"millisecondsSince1970","abstract":"

Encodes an Int64: the number of milliseconds between the date and","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO7iso8601yA2CmF":{"name":"iso8601","abstract":"

Encodes dates according to the ISO 8601 and RFC 3339 standards

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO9formattedyACSo15NSDateFormatterCcACmF":{"name":"formatted(_:)","abstract":"

Encodes a String, according to the provided formatter

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/DatabaseDateEncodingStrategy.html#/s:4GRDB28DatabaseDateEncodingStrategyO6customyAcA0B16ValueConvertible_pSg10Foundation0C0VccACmF":{"name":"custom(_:)","abstract":"

Encodes the result of the user-provided function

","parent_name":"DatabaseDateEncodingStrategy"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO6secondyACSdcACmF":{"name":"second(_:)","abstract":"

Adds the specified amount of seconds

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO6minuteyACSicACmF":{"name":"minute(_:)","abstract":"

Adds the specified amount of minutes

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO4houryACSicACmF":{"name":"hour(_:)","abstract":"

Adds the specified amount of hours

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO3dayyACSicACmF":{"name":"day(_:)","abstract":"

Adds the specified amount of days

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO5monthyACSicACmF":{"name":"month(_:)","abstract":"

Adds the specified amount of months

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO4yearyACSicACmF":{"name":"year(_:)","abstract":"

Adds the specified amount of years

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO10startOfDayyA2CmF":{"name":"startOfDay","abstract":"

Shifts the date backwards to the beginning of the current day

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO12startOfMonthyA2CmF":{"name":"startOfMonth","abstract":"

Shifts the date backwards to the beginning of the current month

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO11startOfYearyA2CmF":{"name":"startOfYear","abstract":"

Shifts the date backwards to the beginning of the current year

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO7weekdayyACSicACmF":{"name":"weekday(_:)","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO9unixEpochyA2CmF":{"name":"unixEpoch","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO9localTimeyA2CmF":{"name":"localTime","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB15SQLDateModifierO3utcyA2CmF":{"name":"utc","abstract":"

See https://www.sqlite.org/lang_datefunc.html

","parent_name":"SQLDateModifier"},"Enums/SQLDateModifier.html#/s:4GRDB14SQLExpressibleP13sqlExpressionAA13SQLExpressionVvp":{"name":"sqlExpression","parent_name":"SQLDateModifier"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO6insertyACSS_tcACmF":{"name":"insert(tableName:)","abstract":"

The insertion of a row in a database table

","parent_name":"DatabaseEventKind"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO6deleteyACSS_tcACmF":{"name":"delete(tableName:)","abstract":"

The deletion of a row in a database table

","parent_name":"DatabaseEventKind"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO6updateyACSS_ShySSGtcACmF":{"name":"update(tableName:columnNames:)","abstract":"

The update of a set of columns in a database table

","parent_name":"DatabaseEventKind"},"Enums/DatabaseEventKind.html#/s:4GRDB17DatabaseEventKindO9tableNameSSvp":{"name":"tableName","abstract":"

The impacted database table

","parent_name":"DatabaseEventKind"},"Enums/DatabasePublishers/Value.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Value"},"Enums/DatabasePublishers/Value.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Value"},"Enums/DatabasePublishers/Migrate.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"Migrate"},"Enums/DatabasePublishers/Migrate.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Migrate"},"Enums/DatabasePublishers/Migrate.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Migrate"},"Enums/DatabasePublishers/Write.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"Write"},"Enums/DatabasePublishers/Write.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Write"},"Enums/DatabasePublishers/Write.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Write"},"Enums/DatabasePublishers/DatabaseRegion.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"DatabaseRegion"},"Enums/DatabasePublishers/DatabaseRegion.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"DatabaseRegion"},"Enums/DatabasePublishers/Read.html#/s:7Combine9PublisherP6OutputQa":{"name":"Output","parent_name":"Read"},"Enums/DatabasePublishers/Read.html#/s:7Combine9PublisherP7FailureQa":{"name":"Failure","parent_name":"Read"},"Enums/DatabasePublishers/Read.html#/s:7Combine9PublisherP7receive10subscriberyqd___tAA10SubscriberRd__7FailureQyd__AGRtz5InputQyd__6OutputRtzlF":{"name":"receive(subscriber:)","parent_name":"Read"},"Enums/DatabasePublishers/Read.html":{"name":"Read","abstract":"

A publisher that reads a value from the database. It publishes exactly","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/DatabaseRegion.html":{"name":"DatabaseRegion","abstract":"

A publisher that tracks changes in a database region.

","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/Write.html":{"name":"Write","abstract":"

A publisher that writes into the database. It publishes exactly","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/Migrate.html":{"name":"Migrate","abstract":"

A publisher that migrates a database. It publishes exactly","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers/Value.html":{"name":"Value","abstract":"

A publisher that tracks changes in the database.

","parent_name":"DatabasePublishers"},"Enums/DatabasePublishers.html":{"name":"DatabasePublishers","abstract":"

A namespace for database Combine publishers.

"},"Enums/DatabaseEventKind.html":{"name":"DatabaseEventKind","abstract":"

A kind of database event. See the TransactionObserver protocol for"},"Enums/SQLDateModifier.html":{"name":"SQLDateModifier","abstract":"

A date modifier for SQLite date functions such as julianDay(_:_:) and"},"Enums/DatabaseDateEncodingStrategy.html":{"name":"DatabaseDateEncodingStrategy","abstract":"

DatabaseDateEncodingStrategy specifies how EncodableRecord types that"},"Enums/DatabaseUUIDEncodingStrategy.html":{"name":"DatabaseUUIDEncodingStrategy","abstract":"

DatabaseUUIDEncodingStrategy specifies how EncodableRecord types that"},"Enums/DatabaseColumnEncodingStrategy.html":{"name":"DatabaseColumnEncodingStrategy","abstract":"

DatabaseColumnEncodingStrategy specifies how EncodableRecord types that"},"Enums/DatabaseDateDecodingStrategy.html":{"name":"DatabaseDateDecodingStrategy","abstract":"

DatabaseDateDecodingStrategy specifies how FetchableRecord types that"},"Enums/DatabaseColumnDecodingStrategy.html":{"name":"DatabaseColumnDecodingStrategy","abstract":"

DatabaseColumnDecodingStrategy specifies how FetchableRecord types that"},"Enums/PersistenceError.html":{"name":"PersistenceError","abstract":"

An error thrown by a type that adopts MutablePersistableRecord.

"},"Enums/SharedValueObservationExtent.html":{"name":"SharedValueObservationExtent","abstract":"

Controls the extent of the shared database observation"},"Enums/ValueReducers.html":{"name":"ValueReducers","abstract":"

A namespace for types related to the ValueReducer protocol.

"},"Classes/ValueObservationScheduler.html#/s:4GRDB25ValueObservationSchedulerC5async7onQueueACSo17OS_dispatch_queueC_tFZ":{"name":"async(onQueue:)","abstract":"

A scheduler which asynchronously notifies fresh value of the","parent_name":"ValueObservationScheduler"},"Classes/ValueObservationScheduler.html#/s:4GRDB25ValueObservationSchedulerC9immediateACvpZ":{"name":"immediate","abstract":"

A scheduler which notifies all values on the main queue. The first one","parent_name":"ValueObservationScheduler"},"Classes/SharedValueObservation.html#/s:4GRDB22SharedValueObservationC5start7onError0F6ChangeAA19DatabaseCancellable_pys0G0_pc_yxctF":{"name":"start(onError:onChange:)","abstract":"

Starts observing the database.

","parent_name":"SharedValueObservation"},"Classes/SharedValueObservation.html#/s:4GRDB22SharedValueObservationC9publisherAA18DatabasePublishersO0C0Vy_xGyF":{"name":"publisher()","abstract":"

Creates a publisher which tracks changes in database values.

","parent_name":"SharedValueObservation"},"Classes/AnyDatabaseCancellable.html#/s:4GRDB22AnyDatabaseCancellableC6cancelACyyc_tcfc":{"name":"init(cancel:)","abstract":"

Initializes the cancellable object with the given cancel-time closure.

","parent_name":"AnyDatabaseCancellable"},"Classes/AnyDatabaseCancellable.html#/s:4GRDB22AnyDatabaseCancellableCyAcA0cD0_pcfc":{"name":"init(_:)","abstract":"

Initializes a cancellable object that forwards cancellation to the","parent_name":"AnyDatabaseCancellable"},"Classes/AnyDatabaseCancellable.html#/s:4GRDB19DatabaseCancellableP6cancelyyF":{"name":"cancel()","parent_name":"AnyDatabaseCancellable"},"Classes/Record.html#/s:4GRDB6RecordCACycfc":{"name":"init()","abstract":"

Creates a Record.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC3rowAcA3RowC_tcfc":{"name":"init(row:)","abstract":"

Creates a Record from a row.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC17databaseTableNameSSvpZ":{"name":"databaseTableName","abstract":"

The name of a database table.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC25persistenceConflictPolicyAA011PersistencedE0VvpZ":{"name":"persistenceConflictPolicy","abstract":"

The policy that handles SQLite conflicts when records are inserted","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC17databaseSelectionSayAA13SQLSelectable_pGvpZ":{"name":"databaseSelection","abstract":"

The default request selection.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6encode2toyAA20PersistenceContainerVz_tF":{"name":"encode(to:)","abstract":"

Defines the values persisted in the database.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC9didInsert4with3forys5Int64V_SSSgtF":{"name":"didInsert(with:for:)","abstract":"

Notifies the record that it was successfully inserted.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC4copyACXDyF":{"name":"copy()","abstract":"

Returns a copy of self, initialized from all values encoded in the","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC18hasDatabaseChangesSbvp":{"name":"hasDatabaseChanges","abstract":"

A boolean that indicates whether the record has changes that have not","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC15databaseChangesSDySSAA13DatabaseValueVSgGvp":{"name":"databaseChanges","abstract":"

A dictionary of changes that have not been saved.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6insertyyAA8DatabaseCKF":{"name":"insert(_:)","abstract":"

Executes an INSERT statement.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6update_7columnsyAA8DatabaseC_ShySSGtKF":{"name":"update(_:columns:)","abstract":"

Executes an UPDATE statement.

","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC13updateChangesySbAA8DatabaseCKF":{"name":"updateChanges(_:)","abstract":"

If the record has been changed, executes an UPDATE statement so that","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC4saveyyAA8DatabaseCKF":{"name":"save(_:)","abstract":"

Executes an INSERT or an UPDATE statement so that self is saved in","parent_name":"Record"},"Classes/Record.html#/s:4GRDB6RecordC6deleteySbAA8DatabaseCKF":{"name":"delete(_:)","abstract":"

Executes a DELETE statement.

","parent_name":"Record"},"Classes/RecordCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"RecordCursor"},"Classes/ColumnDefinition/GeneratedColumnQualification.html#/s:4GRDB16ColumnDefinitionC09GeneratedB13QualificationO7virtualyA2EmF":{"name":"virtual","abstract":"

Undocumented

","parent_name":"GeneratedColumnQualification"},"Classes/ColumnDefinition/GeneratedColumnQualification.html#/s:4GRDB16ColumnDefinitionC09GeneratedB13QualificationO6storedyA2EmF":{"name":"stored","abstract":"

Undocumented

","parent_name":"GeneratedColumnQualification"},"Classes/ColumnDefinition/GeneratedColumnQualification.html":{"name":"GeneratedColumnQualification","abstract":"

The GeneratedColumnQualification enum defines whether a generated","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC10primaryKey10onConflict13autoincrementACXDAA8DatabaseC0G10ResolutionOSg_SbtF":{"name":"primaryKey(onConflict:autoincrement:)","abstract":"

Adds a primary key constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7notNull10onConflictACXDAA8DatabaseC0G10ResolutionOSg_tF":{"name":"notNull(onConflict:)","abstract":"

Adds a NOT NULL constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC6unique10onConflictACXDAA8DatabaseC0F10ResolutionOSg_tF":{"name":"unique(onConflict:)","abstract":"

Adds a UNIQUE constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7indexedACXDyF":{"name":"indexed()","abstract":"

Adds an index of the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC5checkyACXDAA14SQLExpressible_pAA0B0VXEF":{"name":"check(_:)","abstract":"

Adds a CHECK constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC5check3sqlACXDSS_tF":{"name":"check(sql:)","abstract":"

Adds a CHECK constraint on the column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC8defaults2toACXDAA24DatabaseValueConvertible_p_tF":{"name":"defaults(to:)","abstract":"

Defines the default column value.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC8defaults3sqlACXDSS_tF":{"name":"defaults(sql:)","abstract":"

Defines the default column value.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7collateyACXDAA8DatabaseC13CollationNameVF":{"name":"collate(_:)","abstract":"

Defines the default column collation.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC7collateyACXDAA17DatabaseCollationCF":{"name":"collate(_:)","abstract":"

Defines the default column collation.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/generatedAs(sql:_:)":{"name":"generatedAs(sql:_:)","abstract":"

Defines the column as a generated column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/generatedAs(_:_:)":{"name":"generatedAs(_:_:)","abstract":"

Defines the column as a generated column.

","parent_name":"ColumnDefinition"},"Classes/ColumnDefinition.html#/s:4GRDB16ColumnDefinitionC10references_6column8onDelete0F6Update8deferredACXDSS_SSSgAA8DatabaseC16ForeignKeyActionOSgANSbtF":{"name":"references(_:column:onDelete:onUpdate:deferred:)","abstract":"

Defines a foreign key.

","parent_name":"ColumnDefinition"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC3add6column_AA16ColumnDefinitionCSS_AA8DatabaseC0F4TypeVSgtF":{"name":"add(column:_:)","abstract":"

Appends a column to the table.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC9addColumn3sqlySS_tF":{"name":"addColumn(sql:)","abstract":"

Appends a table column defined with raw SQL.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC9addColumn7literalyAA3SQLV_tF":{"name":"addColumn(literal:)","abstract":"

Appends a table column defined with an SQL literal.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/rename(column:to:)":{"name":"rename(column:to:)","abstract":"

Renames a column in a table.

","parent_name":"TableAlteration"},"Classes/TableAlteration.html#/s:4GRDB15TableAlterationC6rename6column2toySS_SStF":{"name":"rename(column:to:)","abstract":"

Renames a column in a table.

","parent_name":"TableAlteration"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC25autoIncrementedPrimaryKey_10onConflictAA06ColumnC0CSS_AA8DatabaseC0I10ResolutionOSgtF":{"name":"autoIncrementedPrimaryKey(_:onConflict:)","abstract":"

Defines the auto-incremented primary key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC6columnyAA06ColumnC0CSS_AA8DatabaseC0E4TypeVSgtF":{"name":"column(_:_:)","abstract":"

Appends a table column.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC6column3sqlySS_tF":{"name":"column(sql:)","abstract":"

Appends a table column defined with raw SQL.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC6column7literalyAA3SQLV_tF":{"name":"column(literal:)","abstract":"

Appends a table column defined with an SQL literal.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10primaryKey_10onConflictySaySSG_AA8DatabaseC0G10ResolutionOSgtF":{"name":"primaryKey(_:onConflict:)","abstract":"

Defines the table primary key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC9uniqueKey_10onConflictySaySSG_AA8DatabaseC0G10ResolutionOSgtF":{"name":"uniqueKey(_:onConflict:)","abstract":"

Adds a unique key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10foreignKey_10references7columns8onDelete0H6Update8deferredySaySSG_SSAJSgAA8DatabaseC07ForeignE6ActionOSgAPSbtF":{"name":"foreignKey(_:references:columns:onDelete:onUpdate:deferred:)","abstract":"

Adds a foreign key.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC5checkyyAA14SQLExpressible_pF":{"name":"check(_:)","abstract":"

Adds a CHECK constraint.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC5check3sqlySS_tF":{"name":"check(sql:)","abstract":"

Adds a CHECK constraint.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10constraint3sqlySS_tF":{"name":"constraint(sql:)","abstract":"

Appends a table constraint defined with raw SQL.

","parent_name":"TableDefinition"},"Classes/TableDefinition.html#/s:4GRDB15TableDefinitionC10constraint7literalyAA3SQLV_tF":{"name":"constraint(literal:)","abstract":"

Appends a table constraint defined with an SQL literal.

","parent_name":"TableDefinition"},"Classes/TableAlias.html#/s:4GRDB10TableAliasC4nameACSSSg_tcfc":{"name":"init(name:)","abstract":"

Creates a TableAlias, suitable for qualifying requests or associations.

","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA12SQLSelectionVAA13SQLSelectable_pcip":{"name":"subscript(_:)","abstract":"

Returns a qualified value that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA13SQLExpressionVAA22SQLSpecificExpressible_pcip":{"name":"subscript(_:)","abstract":"

Returns a qualified expression that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA11SQLOrderingVAA0D4Term_pcip":{"name":"subscript(_:)","abstract":"

Returns a qualified ordering that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasCyAA13SQLExpressionVSScip":{"name":"subscript(_:)","abstract":"

Returns a qualified columnn that is able to resolve ambiguities in","parent_name":"TableAlias"},"Classes/TableAlias.html#/s:4GRDB10TableAliasC6existsAA13SQLExpressionVvp":{"name":"exists","abstract":"

Experimental

","parent_name":"TableAlias"},"Classes/FTS5ColumnDefinition.html#/notIndexed()":{"name":"notIndexed()","abstract":"

Excludes the column from the full-text index.

","parent_name":"FTS5ColumnDefinition"},"Classes/FTS5TableDefinition.html#/tokenizer":{"name":"tokenizer","abstract":"

The virtual table tokenizer

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/content":{"name":"content","abstract":"

The FTS5 content option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/contentRowID":{"name":"contentRowID","abstract":"

The FTS5 content_rowid option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/prefixes":{"name":"prefixes","abstract":"

Support for the FTS5 prefix option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/columnSize":{"name":"columnSize","abstract":"

Support for the FTS5 columnsize option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/detail":{"name":"detail","abstract":"

Support for the FTS5 detail option

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/column(_:)":{"name":"column(_:)","abstract":"

Appends a table column.

","parent_name":"FTS5TableDefinition"},"Classes/FTS5TableDefinition.html#/synchronize(withTable:)":{"name":"synchronize(withTable:)","abstract":"

Synchronizes the full-text table with the content of an external","parent_name":"FTS5TableDefinition"},"Classes/FTS4ColumnDefinition.html#/s:4GRDB20FTS4ColumnDefinitionC10notIndexedACXDyF":{"name":"notIndexed()","abstract":"

Excludes the column from the full-text index.

","parent_name":"FTS4ColumnDefinition"},"Classes/FTS4ColumnDefinition.html#/s:4GRDB20FTS4ColumnDefinitionC12asLanguageIdACXDyF":{"name":"asLanguageId()","abstract":"

Uses the column as the Int32 language id hidden column.

","parent_name":"FTS4ColumnDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC9tokenizerAA23FTS3TokenizerDescriptorVSgvp":{"name":"tokenizer","abstract":"

The virtual table tokenizer

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC7contentSSSgvp":{"name":"content","abstract":"

The FTS4 content option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC8compressSSSgvp":{"name":"compress","abstract":"

The FTS4 compress option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC10uncompressSSSgvp":{"name":"uncompress","abstract":"

The FTS4 uncompress option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC9matchinfoSSSgvp":{"name":"matchinfo","abstract":"

The FTS4 matchinfo option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC8prefixesShySiGSgvp":{"name":"prefixes","abstract":"

Support for the FTS5 prefix option

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC6columnyAA0b6ColumnD0CSSF":{"name":"column(_:)","abstract":"

Appends a table column.

","parent_name":"FTS4TableDefinition"},"Classes/FTS4TableDefinition.html#/s:4GRDB19FTS4TableDefinitionC11synchronize04withC0ySS_tF":{"name":"synchronize(withTable:)","abstract":"

Synchronizes the full-text table with the content of an external","parent_name":"FTS4TableDefinition"},"Classes/FTS3TableDefinition.html#/s:4GRDB19FTS3TableDefinitionC9tokenizerAA0B19TokenizerDescriptorVSgvp":{"name":"tokenizer","abstract":"

The virtual table tokenizer

","parent_name":"FTS3TableDefinition"},"Classes/FTS3TableDefinition.html#/s:4GRDB19FTS3TableDefinitionC6columnyySSF":{"name":"column(_:)","abstract":"

Appends a table column.

","parent_name":"FTS3TableDefinition"},"Classes/FastNullableDatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"FastNullableDatabaseValueCursor"},"Classes/FastDatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"FastDatabaseValueCursor"},"Classes/Statement.html#/s:4GRDB9StatementC06sqliteB0s13OpaquePointerVvp":{"name":"sqliteStatement","abstract":"

The raw SQLite statement, suitable for the SQLite C API.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC3sqlSSvp":{"name":"sql","abstract":"

The SQL query

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC11columnNamesSaySSGvp":{"name":"columnNames","abstract":"

The column names, ordered from left to right.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC14databaseRegionAA08DatabaseD0Vvp":{"name":"databaseRegion","abstract":"

The database region that the statement looks into.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC10isReadonlySbvp":{"name":"isReadonly","abstract":"

Returns true if and only if the prepared statement makes no direct","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC9argumentsAA0B9ArgumentsVvp":{"name":"arguments","abstract":"

The statement arguments.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC17validateArgumentsyyAA0bD0VKF":{"name":"validateArguments(_:)","abstract":"

Throws a DatabaseError of code SQLITE_ERROR if arguments don’t fill all","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC21setUncheckedArgumentsyyAA0bE0VF":{"name":"setUncheckedArguments(_:)","abstract":"

Set arguments without any validation. Trades safety for performance.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC12setArgumentsyyAA0bD0VKF":{"name":"setArguments(_:)","abstract":"

Set the statement arguments, or throws a DatabaseError of code","parent_name":"Statement"},"Classes/Statement.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC11columnCountSivp":{"name":"columnCount","abstract":"

The number of columns in the resulting rows.

","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC5index8ofColumnSiSgSS_tF":{"name":"index(ofColumn:)","abstract":"

Returns the index of the leftmost column named name, in a","parent_name":"Statement"},"Classes/Statement.html#/s:4GRDB9StatementC7execute9argumentsyAA0B9ArgumentsVSg_tKF":{"name":"execute(arguments:)","abstract":"

Executes the prepared statement.

","parent_name":"Statement"},"Classes/RowCursor.html#/s:4GRDB9RowCursorC9statementAA9StatementCvp":{"name":"statement","abstract":"

The statement iterated by this cursor

","parent_name":"RowCursor"},"Classes/RowCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"RowCursor"},"Classes/Row/PrefetchedRowsView.html#/s:4GRDB3RowC18PrefetchedRowsViewV7isEmptySbvp":{"name":"isEmpty","abstract":"

True if there is no prefetched associated rows.

","parent_name":"PrefetchedRowsView"},"Classes/Row/PrefetchedRowsView.html#/s:4GRDB3RowC18PrefetchedRowsViewV4keysShySSGvp":{"name":"keys","abstract":"

The keys for available prefetched rows

","parent_name":"PrefetchedRowsView"},"Classes/Row/PrefetchedRowsView.html#/s:4GRDB3RowC18PrefetchedRowsViewVySayACGSgSScip":{"name":"subscript(_:)","abstract":"

Returns the prefetched rows associated with the given key.

","parent_name":"PrefetchedRowsView"},"Classes/Row/ScopesTreeView.html#/s:4GRDB3RowC14ScopesTreeViewV5namesShySSGvp":{"name":"names","abstract":"

The scopes defined on this row, recursively.

","parent_name":"ScopesTreeView"},"Classes/Row/ScopesTreeView.html#/s:4GRDB3RowC14ScopesTreeViewVyACSgSScip":{"name":"subscript(_:)","abstract":"

Returns the row associated with the given scope.

","parent_name":"ScopesTreeView"},"Classes/Row/ScopesView.html#/s:Sl5IndexQa":{"name":"Index","parent_name":"ScopesView"},"Classes/Row/ScopesView.html#/s:4GRDB3RowC10ScopesViewV5namesSD4KeysVySSAA09_LayoutedB7Adapter_p_Gvp":{"name":"names","abstract":"

The scopes defined on this row.

","parent_name":"ScopesView"},"Classes/Row/ScopesView.html#/s:4GRDB3RowC10ScopesViewVyACSgSScip":{"name":"subscript(_:)","abstract":"

Returns the row associated with the given scope, or nil if the","parent_name":"ScopesView"},"Classes/Row.html#/s:4GRDB3RowC5countSivp":{"name":"count","abstract":"

The number of columns in the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC14prefetchedRowsAC010PrefetchedD4ViewVvp":{"name":"prefetchedRows","abstract":"

A view on the prefetched associated rows.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCACycfc":{"name":"init()","abstract":"

Creates an empty row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyACSDySSAA24DatabaseValueConvertible_pSgGcfc":{"name":"init(_:)","abstract":"

Creates a row from a dictionary of values.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyACSgSDys11AnyHashableVypGcfc":{"name":"init(_:)","abstract":"

Creates a row from [AnyHashable: Any].

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC17dictionaryLiteralACSS_AA24DatabaseValueConvertible_pSgtd_tcfc":{"name":"init(dictionaryLiteral:)","abstract":"

Creates a row initialized with elements. Column order is preserved, and","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC4copyACyF":{"name":"copy()","abstract":"

Returns an immutable copy of the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11columnNamess15LazyMapSequenceVyACSSGvp":{"name":"columnNames","abstract":"

The names of columns in the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC9hasColumnySbSSF":{"name":"hasColumn(_:)","abstract":"

Returns true if and only if the row has that column.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC20containsNonNullValueSbvp":{"name":"containsNonNullValue","abstract":"

Returns true if and only if one column contains a non-null value, or if","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC7hasNull7atIndexSbSi_tF":{"name":"hasNull(atIndex:)","abstract":"

Returns true if the row contains null at given index.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyAA24DatabaseValueConvertible_pSgSicip":{"name":"subscript(_:)","abstract":"

Returns Int64, Double, String, Data or nil, depending on the value","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSicAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSicAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSicAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSicAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given index, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyAA24DatabaseValueConvertible_pSgSScip":{"name":"subscript(_:)","abstract":"

Returns Int64, Double, String, Data or nil, depending on the value","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSScAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSScAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScAA24DatabaseValueConvertibleRzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScAA24DatabaseValueConvertibleRzAA015StatementColumnE0Rzluip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyAA24DatabaseValueConvertible_pSgxcAA16ColumnExpressionRzluip":{"name":"subscript(_:)","abstract":"

Returns Int64, Double, String, NSData or nil, depending on the value","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgq_cAA24DatabaseValueConvertibleRzAA16ColumnExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgq_cAA24DatabaseValueConvertibleRzAA015StatementColumnE0RzAA0G10ExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxq_cAA24DatabaseValueConvertibleRzAA16ColumnExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxq_cAA24DatabaseValueConvertibleRzAA015StatementColumnE0RzAA0G10ExpressionR_r0_luip":{"name":"subscript(_:)","abstract":"

Returns the value at given column, converted to the requested type.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10dataNoCopy7atIndex10Foundation4DataVSgSi_tF":{"name":"dataNoCopy(atIndex:)","abstract":"

Returns the optional Data at given index.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10dataNoCopy5named10Foundation4DataVSgSS_tF":{"name":"dataNoCopy(named:)","abstract":"

Returns the optional Data at given column.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10dataNoCopyy10Foundation4DataVSgxAA16ColumnExpressionRzlF":{"name":"dataNoCopy(_:)","abstract":"

Returns the optional NSData at given column.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC14databaseValuess15LazyMapSequenceVyAcA13DatabaseValueVGvp":{"name":"databaseValues","abstract":"

The database values in the row.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScAA15FetchableRecordRzluip":{"name":"subscript(_:)","abstract":"

Returns the record associated with the given scope.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSgSScAA15FetchableRecordRzluip":{"name":"subscript(_:)","abstract":"

Returns the eventual record associated with the given scope.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyxSScSmRzAA15FetchableRecord7ElementRpzluip":{"name":"subscript(_:)","abstract":"

Returns the records encoded in the given prefetched rows.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCyShyxGSScAA15FetchableRecordRzSHRzluip":{"name":"subscript(_:)","abstract":"

Returns the set of records encoded in the given prefetched rows.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC6scopesAC10ScopesViewVvp":{"name":"scopes","abstract":"

Returns a view on the scopes defined by row adapters.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC10scopesTreeAC06ScopesD4ViewVvp":{"name":"scopesTree","abstract":"

Returns a view on the scopes tree defined by row adapters.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8unscopedACvp":{"name":"unscoped","abstract":"

Returns a copy of the row, without any scopes.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC9unadaptedACvp":{"name":"unadapted","abstract":"

Return the raw row fetched from the database.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11fetchCursor_9arguments7adapterAA0bD0CAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchCursor(_:arguments:adapter:)","abstract":"

Returns a cursor over rows fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchAll_9arguments7adapterSayACGAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchAll(_:arguments:adapter:)","abstract":"

Returns an array of rows fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchSet_9arguments7adapterShyACGAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchSet(_:arguments:adapter:)","abstract":"

Returns a set of rows fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchOne_9arguments7adapterACSgAA9StatementC_AA0G9ArgumentsVSgAA0B7Adapter_pSgtKFZ":{"name":"fetchOne(_:arguments:adapter:)","abstract":"

Returns a single row fetched from a prepared statement.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11fetchCursor_3sql9arguments7adapterAA0bD0CAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchCursor(_:sql:arguments:adapter:)","abstract":"

Returns a cursor over rows fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchAll_3sql9arguments7adapterSayACGAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchAll(_:sql:arguments:adapter:)","abstract":"

Returns an array of rows fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchSet_3sql9arguments7adapterShyACGAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchSet(_:sql:arguments:adapter:)","abstract":"

Returns a set of rows fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchOne_3sql9arguments7adapterACSgAA8DatabaseC_SSAA18StatementArgumentsVAA0B7Adapter_pSgtKFZ":{"name":"fetchOne(_:sql:arguments:adapter:)","abstract":"

Returns a single row fetched from an SQL query.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC11fetchCursoryAA0bD0CAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchCursor(_:_:)","abstract":"

Returns a cursor over rows fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchAllySayACGAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchAll(_:_:)","abstract":"

Returns an array of rows fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchSetyShyACGAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchSet(_:_:)","abstract":"

Returns a set of rows fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowC8fetchOneyACSgAA8DatabaseC_xtKAA12FetchRequestRzlFZ":{"name":"fetchOne(_:_:)","abstract":"

Returns a single row fetched from a fetch request.

","parent_name":"Row"},"Classes/Row.html#/s:4GRDB3RowCySS_AA13DatabaseValueVtAA0B5IndexVcip":{"name":"subscript(_:)","abstract":"

Accesses the (ColumnName, DatabaseValue) pair at given index.

","parent_name":"Row"},"Classes/Row/ScopesView.html":{"name":"ScopesView","abstract":"

A view of the scopes defined by row adapters. It is a collection of","parent_name":"Row"},"Classes/Row/ScopesTreeView.html":{"name":"ScopesTreeView","abstract":"

A view on the scopes tree defined by row adapters.

","parent_name":"Row"},"Classes/Row/PrefetchedRowsView.html":{"name":"PrefetchedRowsView","abstract":"

A view on the prefetched associated rows.

","parent_name":"Row"},"Classes/AnyDatabaseWriter.html#/s:4GRDB17AnyDatabaseWriterCyAcA0cD0_pcfc":{"name":"init(_:)","abstract":"

Creates a database writer that wraps a base database writer.

","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP13configurationAA13ConfigurationVvp":{"name":"configuration","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP5writeyqd__qd__AA0B0CKXEKlF":{"name":"write(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP10asyncWrite_10completionyqd__AA0B0CKc_yAG_s6ResultOyqd__s5Error_pGtctlF":{"name":"asyncWrite(_:completion:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","parent_name":"AnyDatabaseWriter"},"Classes/AnyDatabaseWriter.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","parent_name":"AnyDatabaseWriter"},"Classes/DatabaseFuture.html#/s:4GRDB14DatabaseFutureC4waitxyKF":{"name":"wait()","abstract":"

Blocks the current thread until the value is available, and returns it.

","parent_name":"DatabaseFuture"},"Classes/NullableDatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"NullableDatabaseValueCursor"},"Classes/DatabaseValueCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"DatabaseValueCursor"},"Classes/DatabaseSnapshot.html#/s:4GRDB16DatabaseSnapshotC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"DatabaseSnapshot"},"Classes/DatabaseSnapshot.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"DatabaseSnapshot"},"Classes/AnyDatabaseReader.html#/s:4GRDB17AnyDatabaseReaderCyAcA0cD0_pcfc":{"name":"init(_:)","abstract":"

Creates a database reader that wraps a base database reader.

","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP13configurationAA13ConfigurationVvp":{"name":"configuration","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"AnyDatabaseReader"},"Classes/AnyDatabaseReader.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"AnyDatabaseReader"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC4pathSSvp":{"name":"path","abstract":"

The path to the database file; it is “:memory:” for in-memory databases.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC4path13configurationACSS_AA13ConfigurationVtKcfc":{"name":"init(path:configuration:)","abstract":"

Opens the SQLite database at path path.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13configurationAcA13ConfigurationV_tcfc":{"name":"init(configuration:)","abstract":"

Opens an in-memory SQLite database.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13releaseMemoryyyF":{"name":"releaseMemory()","abstract":"

Free as much memory as possible.

","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC13inTransactionyyAA0B0C0E4KindOSg_AF0E10CompletionOAFKXEtKF":{"name":"inTransaction(_:_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB13DatabaseQueueC02inB0yxxAA0B0CKXEKlF":{"name":"inDatabase(_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","parent_name":"DatabaseQueue"},"Classes/DatabaseQueue.html#/s:4GRDB14DatabaseWriterP28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","parent_name":"DatabaseQueue"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC4pathSSvp":{"name":"path","abstract":"

The path to the database.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC4path13configurationACSS_AA13ConfigurationVtKcfc":{"name":"init(path:configuration:)","abstract":"

Opens the SQLite database at path path.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC13releaseMemoryyyF":{"name":"releaseMemory()","abstract":"

Free as much memory as possible.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP5closeyyKF":{"name":"close()","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP9interruptyyF":{"name":"interrupt()","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP4readyqd__qd__AA0B0CKXEKlF":{"name":"read(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP9asyncReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP10unsafeReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseReaderP19unsafeReentrantReadyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP14concurrentReadyAA0B6FutureCyqd__Gqd__AA0B0CKclF":{"name":"concurrentRead(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC19asyncConcurrentReadyyys6ResultOyAA0B0Cs5Error_pGcF":{"name":"asyncConcurrentRead(_:)","abstract":"

Asynchronously executes a read-only function in a protected","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC29invalidateReadOnlyConnectionsyyF":{"name":"invalidateReadOnlyConnections()","abstract":"

Invalidates open read-only SQLite connections.

","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP23writeWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"writeWithoutTransaction(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP30barrierWriteWithoutTransactionyqd__qd__AA0B0CKXEKlF":{"name":"barrierWriteWithoutTransaction(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP35asyncBarrierWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncBarrierWriteWithoutTransaction(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC18writeInTransactionyyAA0B0C0F4KindOSg_AF0F10CompletionOAFKXEtKF":{"name":"writeInTransaction(_:_:)","abstract":"

Synchronously executes database updates in a protected dispatch queue,","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB14DatabaseWriterP20unsafeReentrantWriteyqd__qd__AA0B0CKXEKlF":{"name":"unsafeReentrantWrite(_:)","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC28asyncWriteWithoutTransactionyyyAA0B0CcF":{"name":"asyncWriteWithoutTransaction(_:)","abstract":"

Asynchronously executes database updates in a protected dispatch queue,","parent_name":"DatabasePool"},"Classes/DatabasePool.html#/s:4GRDB12DatabasePoolC12makeSnapshotAA0bE0CyKF":{"name":"makeSnapshot()","abstract":"

Creates a database snapshot.

","parent_name":"DatabasePool"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC4nameSSvp":{"name":"name","abstract":"

The name of the SQL function

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC_13argumentCount4pure8functionACSS_s5Int32VSgSbAA0B16ValueConvertible_pSgSayAA0bI0VGKctcfc":{"name":"init(_:argumentCount:pure:function:)","abstract":"

Creates an SQL function.

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC_13argumentCount4pure9aggregateACSS_s5Int32VSgSbxmtcAA0B9AggregateRzlufc":{"name":"init(_:argumentCount:pure:aggregate:)","abstract":"

Creates an SQL aggregate function.

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC06callAsC0yAA13SQLExpressionVAA14SQLExpressible_pd_tF":{"name":"callAsFunction(_:)","abstract":"

Returns an SQL expression that applies the function.

","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC10capitalizeACvpZ":{"name":"capitalize","abstract":"

An SQL function that returns the Swift built-in capitalized","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC9lowercaseACvpZ":{"name":"lowercase","abstract":"

An SQL function that returns the Swift built-in lowercased","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC9uppercaseACvpZ":{"name":"uppercase","abstract":"

An SQL function that returns the Swift built-in uppercased","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC19localizedCapitalizeACvpZ":{"name":"localizedCapitalize","abstract":"

An SQL function that returns the Swift built-in","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC18localizedLowercaseACvpZ":{"name":"localizedLowercase","abstract":"

An SQL function that returns the Swift built-in","parent_name":"DatabaseFunction"},"Classes/DatabaseFunction.html#/s:4GRDB16DatabaseFunctionC18localizedUppercaseACvpZ":{"name":"localizedUppercase","abstract":"

An SQL function that returns the Swift built-in","parent_name":"DatabaseFunction"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC4nameSSvp":{"name":"name","abstract":"

The name of the collation

","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC_8functionACSS_So18NSComparisonResultVSS_SStctcfc":{"name":"init(_:function:)","abstract":"

Creates a collation.

","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC14unicodeCompareACvpZ":{"name":"unicodeCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC22caseInsensitiveCompareACvpZ":{"name":"caseInsensitiveCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC31localizedCaseInsensitiveCompareACvpZ":{"name":"localizedCaseInsensitiveCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC16localizedCompareACvpZ":{"name":"localizedCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/DatabaseCollation.html#/s:4GRDB17DatabaseCollationC24localizedStandardCompareACvpZ":{"name":"localizedStandardCompare","abstract":"

A collation, or SQL string comparison function, that compares strings","parent_name":"DatabaseCollation"},"Classes/SQLStatementCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"SQLStatementCursor"},"Classes/Database/TransactionObservationExtent.html#/s:4GRDB8DatabaseC28TransactionObservationExtentO16observerLifetimeyA2EmF":{"name":"observerLifetime","abstract":"

Observation lasts until observer is deallocated

","parent_name":"TransactionObservationExtent"},"Classes/Database/TransactionObservationExtent.html#/s:4GRDB8DatabaseC28TransactionObservationExtentO04nextC0yA2EmF":{"name":"nextTransaction","abstract":"

Observation lasts until the next transaction

","parent_name":"TransactionObservationExtent"},"Classes/Database/TransactionObservationExtent.html#/s:4GRDB8DatabaseC28TransactionObservationExtentO16databaseLifetimeyA2EmF":{"name":"databaseLifetime","abstract":"

Observation lasts until the database is closed

","parent_name":"TransactionObservationExtent"},"Classes/Database/TransactionKind.html#/s:4GRDB8DatabaseC15TransactionKindO8deferredyA2EmF":{"name":"deferred","abstract":"

The DEFERRED transaction kind

","parent_name":"TransactionKind"},"Classes/Database/TransactionKind.html#/s:4GRDB8DatabaseC15TransactionKindO9immediateyA2EmF":{"name":"immediate","abstract":"

The IMMEDIATE transaction kind

","parent_name":"TransactionKind"},"Classes/Database/TransactionKind.html#/s:4GRDB8DatabaseC15TransactionKindO9exclusiveyA2EmF":{"name":"exclusive","abstract":"

The EXCLUSIVE transaction kind

","parent_name":"TransactionKind"},"Classes/Database/TransactionCompletion.html#/s:4GRDB8DatabaseC21TransactionCompletionO6commityA2EmF":{"name":"commit","abstract":"

Confirms changes

","parent_name":"TransactionCompletion"},"Classes/Database/TransactionCompletion.html#/s:4GRDB8DatabaseC21TransactionCompletionO8rollbackyA2EmF":{"name":"rollback","abstract":"

Cancel changes

","parent_name":"TransactionCompletion"},"Classes/Database/TraceEvent/Statement.html#/s:4GRDB8DatabaseC10TraceEventO9StatementV3sqlSSvp":{"name":"sql","abstract":"

The executed SQL, where bound parameters are not expanded.

","parent_name":"Statement"},"Classes/Database/TraceEvent/Statement.html#/s:4GRDB8DatabaseC10TraceEventO9StatementV11expandedSQLSSvp":{"name":"expandedSQL","abstract":"

The executed SQL, where bound parameters are expanded.

","parent_name":"Statement"},"Classes/Database/TraceEvent/Statement.html":{"name":"Statement","abstract":"

Information about a statement reported by Database.trace(options:_:)

","parent_name":"TraceEvent"},"Classes/Database/TraceEvent.html#/s:4GRDB8DatabaseC10TraceEventO9statementyA2E9StatementVcAEmF":{"name":"statement(_:)","abstract":"

An event reported by TracingOptions.statement.

","parent_name":"TraceEvent"},"Classes/Database/TraceEvent.html#/s:4GRDB8DatabaseC10TraceEventO7profileyA2E9StatementV_SdtcAEmF":{"name":"profile(statement:duration:)","abstract":"

An event reported by TracingOptions.profile.

","parent_name":"TraceEvent"},"Classes/Database/TraceEvent.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"TraceEvent"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV8rawValues5Int32Vvp":{"name":"rawValue","abstract":"

The raw “Trace Event Code”.

","parent_name":"TracingOptions"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV8rawValueAEs5Int32V_tcfc":{"name":"init(rawValue:)","abstract":"

Creates a TracingOptions from a raw “Trace Event Code”.

","parent_name":"TracingOptions"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV9statementAEvpZ":{"name":"statement","abstract":"

Reports executed statements.

","parent_name":"TracingOptions"},"Classes/Database/TracingOptions.html#/s:4GRDB8DatabaseC14TracingOptionsV7profileAEvpZ":{"name":"profile","abstract":"

Reports executed statements and the estimated duration that the","parent_name":"TracingOptions"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO7cascadeyA2EmF":{"name":"cascade","abstract":"

The CASCADE foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO8restrictyA2EmF":{"name":"restrict","abstract":"

The RESTRICT foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO7setNullyA2EmF":{"name":"setNull","abstract":"

The SET NULL foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ForeignKeyAction.html#/s:4GRDB8DatabaseC16ForeignKeyActionO10setDefaultyA2EmF":{"name":"setDefault","abstract":"

The SET DEFAULT foreign key action

","parent_name":"ForeignKeyAction"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO8rollbackyA2EmF":{"name":"rollback","abstract":"

The ROLLBACK conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO5abortyA2EmF":{"name":"abort","abstract":"

The ABORT conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO4failyA2EmF":{"name":"fail","abstract":"

The FAIL conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO6ignoreyA2EmF":{"name":"ignore","abstract":"

The IGNORE conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ConflictResolution.html#/s:4GRDB8DatabaseC18ConflictResolutionO7replaceyA2EmF":{"name":"replace","abstract":"

The REPLACE conflict resolution

","parent_name":"ConflictResolution"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV8rawValueAESS_tcfc":{"name":"init(rawValue:)","abstract":"

Creates an SQL column type.

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV4textAEvpZ":{"name":"text","abstract":"

The TEXT SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV7integerAEvpZ":{"name":"integer","abstract":"

The INTEGER SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV6doubleAEvpZ":{"name":"double","abstract":"

The DOUBLE SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV7numericAEvpZ":{"name":"numeric","abstract":"

The NUMERIC SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV7booleanAEvpZ":{"name":"boolean","abstract":"

The BOOLEAN SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV4blobAEvpZ":{"name":"blob","abstract":"

The BLOB SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV4dateAEvpZ":{"name":"date","abstract":"

The DATE SQL column type

","parent_name":"ColumnType"},"Classes/Database/ColumnType.html#/s:4GRDB8DatabaseC10ColumnTypeV8datetimeAEvpZ":{"name":"datetime","abstract":"

The DATETIME SQL column type

","parent_name":"ColumnType"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV8rawValueAESS_tcfc":{"name":"init(rawValue:)","abstract":"

Creates a built-in collation name.

","parent_name":"CollationName"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV6binaryAEvpZ":{"name":"binary","abstract":"

The BINARY built-in SQL collation

","parent_name":"CollationName"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV6nocaseAEvpZ":{"name":"nocase","abstract":"

The NOCASE built-in SQL collation

","parent_name":"CollationName"},"Classes/Database/CollationName.html#/s:4GRDB8DatabaseC13CollationNameV5rtrimAEvpZ":{"name":"rtrim","abstract":"

The RTRIM built-in SQL collation

","parent_name":"CollationName"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO7passiveyA2EmF":{"name":"passive","abstract":"

The SQLITE_CHECKPOINT_PASSIVE mode

","parent_name":"CheckpointMode"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO4fullyA2EmF":{"name":"full","abstract":"

The SQLITE_CHECKPOINT_FULL mode

","parent_name":"CheckpointMode"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO7restartyA2EmF":{"name":"restart","abstract":"

The SQLITE_CHECKPOINT_RESTART mode

","parent_name":"CheckpointMode"},"Classes/Database/CheckpointMode.html#/s:4GRDB8DatabaseC14CheckpointModeO8truncateyA2EmF":{"name":"truncate","abstract":"

The SQLITE_CHECKPOINT_TRUNCATE mode

","parent_name":"CheckpointMode"},"Classes/Database/BusyMode.html#/s:4GRDB8DatabaseC8BusyModeO14immediateErroryA2EmF":{"name":"immediateError","abstract":"

The SQLITE_BUSY error is immediately returned to the connection that","parent_name":"BusyMode"},"Classes/Database/BusyMode.html#/s:4GRDB8DatabaseC8BusyModeO7timeoutyAESdcAEmF":{"name":"timeout(_:)","abstract":"

The SQLITE_BUSY error will be returned only if the database remains","parent_name":"BusyMode"},"Classes/Database/BusyMode.html#/s:4GRDB8DatabaseC8BusyModeO8callbackyAESbSiccAEmF":{"name":"callback(_:)","abstract":"

A custom callback that is called when a database is locked.","parent_name":"BusyMode"},"Classes/Database.html#/s:4GRDB8DatabaseC16sqliteConnections13OpaquePointerVSgvp":{"name":"sqliteConnection","abstract":"

The raw SQLite connection, suitable for the SQLite C API.","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC8logErroryAA10ResultCodeV_SStcSgvpZ":{"name":"logError","abstract":"

The error logging function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13configurationAA13ConfigurationVvp":{"name":"configuration","abstract":"

The database configuration

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11descriptionSSvp":{"name":"description","abstract":"

See Configuration.label

","parent_name":"Database"},"Classes/Database.html#/s:s28CustomDebugStringConvertibleP16debugDescriptionSSvp":{"name":"debugDescription","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC17lastInsertedRowIDs5Int64Vvp":{"name":"lastInsertedRowID","abstract":"

The rowID of the most recently inserted row.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC12changesCountSivp":{"name":"changesCount","abstract":"

The number of rows modified, inserted or deleted by the most recent","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC17totalChangesCountSivp":{"name":"totalChangesCount","abstract":"

The total number of rows modified, inserted or deleted by all successful","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19isInsideTransactionSbvp":{"name":"isInsideTransaction","abstract":"

True if the database connection is currently in a transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13lastErrorCodeAA06ResultE0Vvp":{"name":"lastErrorCode","abstract":"

The last error code

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16lastErrorMessageSSSgvp":{"name":"lastErrorMessage","abstract":"

The last error message

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC29maximumStatementArgumentCountSivp":{"name":"maximumStatementArgumentCount","abstract":"

The maximum number of arguments accepted by an SQLite statement.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC3add8functionyAA0B8FunctionC_tF":{"name":"add(function:)","abstract":"

Add or redefine an SQL function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6remove8functionyAA0B8FunctionC_tF":{"name":"remove(function:)","abstract":"

Remove an SQL function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC3add9collationyAA0B9CollationC_tF":{"name":"add(collation:)","abstract":"

Add or redefine a collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6remove9collationyAA0B9CollationC_tF":{"name":"remove(collation:)","abstract":"

Remove a collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC5trace7options_yAC14TracingOptionsV_yAC10TraceEventOcSgtF":{"name":"trace(options:_:)","abstract":"

Registers a tracing function.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC10checkpoint_2onSi13walFrameCount_Si012checkpointedfG0tAC14CheckpointModeO_SSSgtKF":{"name":"checkpoint(_:on:)","abstract":"

Runs a WAL checkpoint.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19suspendNotificationSo18NSNotificationNameavpZ":{"name":"suspendNotification","abstract":"

When this notification is posted, databases which were opened with the","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC18resumeNotificationSo18NSNotificationNameavpZ":{"name":"resumeNotification","abstract":"

When this notification is posted, databases which were opened with the","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13inTransactionyyAC0D4KindOSg_AC0D10CompletionOyKXEtKF":{"name":"inTransaction(_:_:)","abstract":"

Executes a block inside a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11inSavepointyyAC21TransactionCompletionOyKXEKF":{"name":"inSavepoint(_:)","abstract":"

Executes a block inside a savepoint.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16beginTransactionyyAC0D4KindOSgKF":{"name":"beginTransaction(_:)","abstract":"

Begins a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC8rollbackyyKF":{"name":"rollback()","abstract":"

Rollbacks a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6commityyKF":{"name":"commit()","abstract":"

Commits a database transaction.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16clearSchemaCacheyyF":{"name":"clearSchemaCache()","abstract":"

Clears the database schema cache.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11tableExistsySbSSKF":{"name":"tableExists(_:)","abstract":"

Returns whether a table exists in the main or temp schema.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21isSQLiteInternalTableySbSSFZ":{"name":"isSQLiteInternalTable(_:)","abstract":"

Returns whether a table is an internal SQLite table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21isSQLiteInternalTableySbSSF":{"name":"isSQLiteInternalTable(_:)","abstract":"

Returns whether a table is an internal SQLite table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19isGRDBInternalTableySbSSFZ":{"name":"isGRDBInternalTable(_:)","abstract":"

Returns whether a table is an internal GRDB table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19isGRDBInternalTableySbSSF":{"name":"isGRDBInternalTable(_:)","abstract":"

Returns whether a table is an internal GRDB table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC10viewExistsySbSSKF":{"name":"viewExists(_:)","abstract":"

Returns whether a view exists in the main or temp schema.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13triggerExistsySbSSKF":{"name":"triggerExists(_:)","abstract":"

Returns whether a trigger exists in the main or temp schema.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC10primaryKeyyAA07PrimaryD4InfoVSSKF":{"name":"primaryKey(_:)","abstract":"

The primary key for table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7indexes2onSayAA9IndexInfoVGSS_tKF":{"name":"indexes(on:)","abstract":"

The indexes on table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC5table_12hasUniqueKeySbSS_xtKSTRzSS7ElementRtzlF":{"name":"table(_:hasUniqueKey:)","abstract":"

True if a sequence of columns uniquely identifies a row, that is to say","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC11foreignKeys2onSayAA14ForeignKeyInfoVGSS_tKF":{"name":"foreignKeys(on:)","abstract":"

The foreign keys defined on table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC20foreignKeyViolationsAA12RecordCursorCyAA07ForeignD9ViolationVGyKF":{"name":"foreignKeyViolations()","abstract":"

Returns a cursor over foreign key violations in the database.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC20foreignKeyViolations2inAA12RecordCursorCyAA07ForeignD9ViolationVGSS_tKF":{"name":"foreignKeyViolations(in:)","abstract":"

Returns a cursor over foreign key violations in the table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16checkForeignKeysyyKF":{"name":"checkForeignKeys()","abstract":"

Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16checkForeignKeys2inySS_tKF":{"name":"checkForeignKeys(in:)","abstract":"

Throws a DatabaseError of extended code SQLITE_CONSTRAINT_FOREIGNKEY","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7columns2inSayAA10ColumnInfoVGSS_tKF":{"name":"columns(in:)","abstract":"

The columns in the table named tableName.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13makeStatement3sqlAA0D0CSS_tKF":{"name":"makeStatement(sql:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13makeStatement7literalAA0D0CAA3SQLV_tKF":{"name":"makeStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeSelectStatement3sqlAA0E0CSS_tKF":{"name":"makeSelectStatement(sql:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeSelectStatement7literalAA0E0CAA3SQLV_tKF":{"name":"makeSelectStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC15cachedStatement3sqlAA0D0CSS_tKF":{"name":"cachedStatement(sql:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC15cachedStatement7literalAA0D0CAA3SQLV_tKF":{"name":"cachedStatement(literal:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedSelectStatement3sqlAA0E0CSS_tKF":{"name":"cachedSelectStatement(sql:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedSelectStatement7literalAA0E0CAA3SQLV_tKF":{"name":"cachedSelectStatement(literal:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeUpdateStatement3sqlAA0E0CSS_tKF":{"name":"makeUpdateStatement(sql:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC19makeUpdateStatement7literalAA0E0CAA3SQLV_tKF":{"name":"makeUpdateStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedUpdateStatement3sqlAA0E0CSS_tKF":{"name":"cachedUpdateStatement(sql:)","abstract":"

Returns a prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC21cachedUpdateStatement7literalAA0E0CAA3SQLV_tKF":{"name":"cachedUpdateStatement(literal:)","abstract":"

Returns a new prepared statement that can be reused.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13allStatements3sql9argumentsAA18SQLStatementCursorCSS_AA18StatementArgumentsVSgtKF":{"name":"allStatements(sql:arguments:)","abstract":"

Returns a cursor of all SQL statements separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC13allStatements7literalAA18SQLStatementCursorCAA3SQLV_tKF":{"name":"allStatements(literal:)","abstract":"

Returns a cursor of all SQL statements separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7execute3sql9argumentsySS_AA18StatementArgumentsVtKF":{"name":"execute(sql:arguments:)","abstract":"

Executes one or several SQL statements, separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7execute7literalyAA3SQLV_tKF":{"name":"execute(literal:)","abstract":"

Executes one or several SQL statements, separated by semi-colons.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC12BusyCallbacka":{"name":"BusyCallback","abstract":"

See BusyMode and https://www.sqlite.org/c3ref/busy_handler.html

","parent_name":"Database"},"Classes/Database/BusyMode.html":{"name":"BusyMode","abstract":"

When there are several connections to a database, a connection may try","parent_name":"Database"},"Classes/Database/CheckpointMode.html":{"name":"CheckpointMode","abstract":"

The available checkpoint modes.

","parent_name":"Database"},"Classes/Database/CollationName.html":{"name":"CollationName","abstract":"

A built-in SQLite collation.

","parent_name":"Database"},"Classes/Database/ColumnType.html":{"name":"ColumnType","abstract":"

An SQL column type.

","parent_name":"Database"},"Classes/Database/ConflictResolution.html":{"name":"ConflictResolution","abstract":"

An SQLite conflict resolution.

","parent_name":"Database"},"Classes/Database/ForeignKeyAction.html":{"name":"ForeignKeyAction","abstract":"

A foreign key action.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC16LogErrorFunctiona":{"name":"LogErrorFunction","abstract":"

An error log function that takes an error code and message.

","parent_name":"Database"},"Classes/Database/TracingOptions.html":{"name":"TracingOptions","abstract":"

An option for Database.trace(options:_:)

","parent_name":"Database"},"Classes/Database/TraceEvent.html":{"name":"TraceEvent","abstract":"

An event reported by Database.trace(options:_:)

","parent_name":"Database"},"Classes/Database/TransactionCompletion.html":{"name":"TransactionCompletion","abstract":"

Confirms or cancels the changes performed by a transaction or savepoint.

","parent_name":"Database"},"Classes/Database/TransactionKind.html":{"name":"TransactionKind","abstract":"

An SQLite transaction kind. See https://www.sqlite.org/lang_transaction.html

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC3add19transactionObserver6extentyAA011TransactionE0_p_AC0G17ObservationExtentOtF":{"name":"add(transactionObserver:extent:)","abstract":"

Add a transaction observer, so that it gets notified of","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6remove19transactionObserveryAA011TransactionE0_p_tF":{"name":"remove(transactionObserver:)","abstract":"

Remove a transaction observer.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC26afterNextTransactionCommityyyACcF":{"name":"afterNextTransactionCommit(_:)","abstract":"

Registers a closure to be executed after the next or current","parent_name":"Database"},"Classes/Database/TransactionObservationExtent.html":{"name":"TransactionObservationExtent","abstract":"

The extent of a transaction observation

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC31dropFTS4SynchronizationTriggers8forTableySS_tKF":{"name":"dropFTS4SynchronizationTriggers(forTable:)","abstract":"

Deletes the synchronization triggers for a synchronized FTS4 table

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create5table9temporary11ifNotExists12withoutRowID4bodyySS_S3byAA15TableDefinitionCXEtKF":{"name":"create(table:temporary:ifNotExists:withoutRowID:body:)","abstract":"

Creates a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6rename5table2toySS_SStKF":{"name":"rename(table:to:)","abstract":"

Renames a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC5alter5table4bodyySS_yAA15TableAlterationCXEtKF":{"name":"alter(table:body:)","abstract":"

Modifies a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC4drop5tableySS_tKF":{"name":"drop(table:)","abstract":"

Deletes a database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create5index2on7columns6unique11ifNotExists9conditionySS_SSSaySSGS2bAA14SQLExpressible_pSgtKF":{"name":"create(index:on:columns:unique:ifNotExists:condition:)","abstract":"

Creates an index.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC4drop5indexySS_tKF":{"name":"drop(index:)","abstract":"

Deletes a database index.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7reindex9collationyAC13CollationNameV_tKF":{"name":"reindex(collation:)","abstract":"

Delete and recreate from scratch all indices that use this collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC7reindex9collationyAA0B9CollationC_tKF":{"name":"reindex(collation:)","abstract":"

Delete and recreate from scratch all indices that use this collation.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create12virtualTable11ifNotExists5usingySS_SbSStKF":{"name":"create(virtualTable:ifNotExists:using:)","abstract":"

Creates a virtual database table.

","parent_name":"Database"},"Classes/Database.html#/s:4GRDB8DatabaseC6create12virtualTable11ifNotExists5using_ySS_Sbxy0E10DefinitionQzcSgtKAA07VirtualE6ModuleRzlF":{"name":"create(virtualTable:ifNotExists:using:_:)","abstract":"

Creates a virtual database table.

","parent_name":"Database"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorCyACyxGqd__c7ElementQyd__RszAA0C0Rd__lufc":{"name":"init(_:)","abstract":"

Creates a cursor that wraps a base cursor but whose type depends only on","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorC8iteratorACyxGqd___tc7ElementQyd__RszStRd__lufc":{"name":"init(iterator:)","abstract":"

Creates a cursor that wraps a base iterator but whose type depends only","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorCyACyxGqd__c7ElementQyd__RszSTRd__lufc":{"name":"init(_:)","abstract":"

Creates a cursor that wraps a base sequence but whose type depends only","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB9AnyCursorCyACyxGxSgyKccfc":{"name":"init(_:)","abstract":"

Creates a cursor that wraps the given closure in its next() method

","parent_name":"AnyCursor"},"Classes/AnyCursor.html#/s:4GRDB6CursorP4next7ElementQzSgyKF":{"name":"next()","parent_name":"AnyCursor"},"Classes/AnyCursor.html":{"name":"AnyCursor","abstract":"

A type-erased cursor of Element.

"},"Classes/Database.html":{"name":"Database","abstract":"

A Database connection.

"},"Classes/SQLStatementCursor.html":{"name":"SQLStatementCursor","abstract":"

Undocumented

"},"Classes/DatabaseCollation.html":{"name":"DatabaseCollation","abstract":"

A Collation is a string comparison function used by SQLite.

"},"Classes/DatabaseFunction.html":{"name":"DatabaseFunction","abstract":"

An SQL function or aggregate.

"},"Classes/DatabasePool.html":{"name":"DatabasePool","abstract":"

A DatabasePool grants concurrent accesses to an SQLite database.

"},"Classes/DatabaseQueue.html":{"name":"DatabaseQueue","abstract":"

A DatabaseQueue serializes access to an SQLite database.

"},"Classes/AnyDatabaseReader.html":{"name":"AnyDatabaseReader","abstract":"

A type-erased DatabaseReader

"},"Classes/DatabaseSnapshot.html":{"name":"DatabaseSnapshot","abstract":"

A DatabaseSnapshot sees an unchanging database content, as it existed at the"},"Classes/DatabaseValueCursor.html":{"name":"DatabaseValueCursor","abstract":"

A cursor of database values extracted from a single column."},"Classes/NullableDatabaseValueCursor.html":{"name":"NullableDatabaseValueCursor","abstract":"

A cursor of optional database values extracted from a single column."},"Classes/DatabaseFuture.html":{"name":"DatabaseFuture","abstract":"

A future database value, returned by the DatabaseWriter.concurrentRead(_:)"},"Classes/AnyDatabaseWriter.html":{"name":"AnyDatabaseWriter","abstract":"

A type-erased DatabaseWriter

"},"Classes/Row.html":{"name":"Row","abstract":"

A database row.

"},"Classes/RowCursor.html":{"name":"RowCursor","abstract":"

A cursor of database rows. For example:

"},"Classes/Statement.html":{"name":"Statement","abstract":"

A statement represents an SQL query.

"},"Classes/FastDatabaseValueCursor.html":{"name":"FastDatabaseValueCursor","abstract":"

A cursor of database values extracted from a single column."},"Classes/FastNullableDatabaseValueCursor.html":{"name":"FastNullableDatabaseValueCursor","abstract":"

A cursor of optional database values extracted from a single column."},"Classes/FTS3TableDefinition.html":{"name":"FTS3TableDefinition","abstract":"

The FTS3TableDefinition class lets you define columns of a FTS3 virtual table.

"},"Classes/FTS4TableDefinition.html":{"name":"FTS4TableDefinition","abstract":"

The FTS4TableDefinition class lets you define columns of a FTS4 virtual table.

"},"Classes/FTS4ColumnDefinition.html":{"name":"FTS4ColumnDefinition","abstract":"

The FTS4ColumnDefinition class lets you refine a column of an FTS4"},"Classes/FTS5TableDefinition.html":{"name":"FTS5TableDefinition","abstract":"

The FTS5TableDefinition class lets you define columns of a FTS5 virtual table.

"},"Classes/FTS5ColumnDefinition.html":{"name":"FTS5ColumnDefinition","abstract":"

The FTS5ColumnDefinition class lets you refine a column of an FTS5"},"Classes/TableAlias.html":{"name":"TableAlias","abstract":"

Experimental

"},"Classes/TableDefinition.html":{"name":"TableDefinition","abstract":"

The TableDefinition class lets you define table columns and constraints.

"},"Classes/TableAlteration.html":{"name":"TableAlteration","abstract":"

The TableAlteration class lets you alter database tables.

"},"Classes/ColumnDefinition.html":{"name":"ColumnDefinition","abstract":"

The ColumnDefinition class lets you refine a table column.

"},"Classes/RecordCursor.html":{"name":"RecordCursor","abstract":"

A cursor of records. For example:

"},"Classes/Record.html":{"name":"Record","abstract":"

Record is a class that wraps a table row, or the result of any query. It is"},"Classes/AnyDatabaseCancellable.html":{"name":"AnyDatabaseCancellable","abstract":"

A type-erasing cancellable object that executes a provided closure"},"Classes/SharedValueObservation.html":{"name":"SharedValueObservation","abstract":"

Experimental

"},"Classes/ValueObservationScheduler.html":{"name":"ValueObservationScheduler","abstract":"

ValueObservationScheduler determines how ValueObservation notifies its"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Enums.html":{"name":"Enumerations","abstract":"

The following enumerations are available globally.

"},"Extensions.html":{"name":"Extensions","abstract":"

The following extensions are available globally.

"},"Functions.html":{"name":"Functions","abstract":"

The following functions are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"},"Structs.html":{"name":"Structures","abstract":"

The following structures are available globally.

"},"Typealiases.html":{"name":"Type Aliases","abstract":"

The following type aliases are available globally.

"}} \ No newline at end of file diff --git a/docs/5.16/undocumented.json b/docs/5.16/undocumented.json new file mode 100644 index 000000000..1557b170d --- /dev/null +++ b/docs/5.16/undocumented.json @@ -0,0 +1,1531 @@ +{ + "warnings": [ + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/Database+Statements.swift", + "line": 470, + "symbol": "SQLStatementCursor", + "symbol_kind": "source.lang.swift.decl.class", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 48, + "symbol": "ResultCode.SQLITE_OK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 49, + "symbol": "ResultCode.SQLITE_ERROR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 50, + "symbol": "ResultCode.SQLITE_INTERNAL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 51, + "symbol": "ResultCode.SQLITE_PERM", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 52, + "symbol": "ResultCode.SQLITE_ABORT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 53, + "symbol": "ResultCode.SQLITE_BUSY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 54, + "symbol": "ResultCode.SQLITE_LOCKED", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 55, + "symbol": "ResultCode.SQLITE_NOMEM", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 56, + "symbol": "ResultCode.SQLITE_READONLY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 57, + "symbol": "ResultCode.SQLITE_INTERRUPT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 58, + "symbol": "ResultCode.SQLITE_IOERR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 59, + "symbol": "ResultCode.SQLITE_CORRUPT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 60, + "symbol": "ResultCode.SQLITE_NOTFOUND", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 61, + "symbol": "ResultCode.SQLITE_FULL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 62, + "symbol": "ResultCode.SQLITE_CANTOPEN", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 63, + "symbol": "ResultCode.SQLITE_PROTOCOL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 64, + "symbol": "ResultCode.SQLITE_EMPTY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 65, + "symbol": "ResultCode.SQLITE_SCHEMA", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 66, + "symbol": "ResultCode.SQLITE_TOOBIG", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 67, + "symbol": "ResultCode.SQLITE_CONSTRAINT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 68, + "symbol": "ResultCode.SQLITE_MISMATCH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 69, + "symbol": "ResultCode.SQLITE_MISUSE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 70, + "symbol": "ResultCode.SQLITE_NOLFS", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 71, + "symbol": "ResultCode.SQLITE_AUTH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 72, + "symbol": "ResultCode.SQLITE_FORMAT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 73, + "symbol": "ResultCode.SQLITE_RANGE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 74, + "symbol": "ResultCode.SQLITE_NOTADB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 75, + "symbol": "ResultCode.SQLITE_NOTICE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 76, + "symbol": "ResultCode.SQLITE_WARNING", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 77, + "symbol": "ResultCode.SQLITE_ROW", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 78, + "symbol": "ResultCode.SQLITE_DONE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 85, + "symbol": "ResultCode.SQLITE_ERROR_MISSING_COLLSEQ", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 86, + "symbol": "ResultCode.SQLITE_ERROR_RETRY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 87, + "symbol": "ResultCode.SQLITE_ERROR_SNAPSHOT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 88, + "symbol": "ResultCode.SQLITE_IOERR_READ", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 89, + "symbol": "ResultCode.SQLITE_IOERR_SHORT_READ", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 90, + "symbol": "ResultCode.SQLITE_IOERR_WRITE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 91, + "symbol": "ResultCode.SQLITE_IOERR_FSYNC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 92, + "symbol": "ResultCode.SQLITE_IOERR_DIR_FSYNC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 93, + "symbol": "ResultCode.SQLITE_IOERR_TRUNCATE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 94, + "symbol": "ResultCode.SQLITE_IOERR_FSTAT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 95, + "symbol": "ResultCode.SQLITE_IOERR_UNLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 96, + "symbol": "ResultCode.SQLITE_IOERR_RDLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 97, + "symbol": "ResultCode.SQLITE_IOERR_DELETE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 98, + "symbol": "ResultCode.SQLITE_IOERR_BLOCKED", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 99, + "symbol": "ResultCode.SQLITE_IOERR_NOMEM", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 100, + "symbol": "ResultCode.SQLITE_IOERR_ACCESS", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 101, + "symbol": "ResultCode.SQLITE_IOERR_CHECKRESERVEDLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 102, + "symbol": "ResultCode.SQLITE_IOERR_LOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 103, + "symbol": "ResultCode.SQLITE_IOERR_CLOSE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 104, + "symbol": "ResultCode.SQLITE_IOERR_DIR_CLOSE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 105, + "symbol": "ResultCode.SQLITE_IOERR_SHMOPEN", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 106, + "symbol": "ResultCode.SQLITE_IOERR_SHMSIZE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 107, + "symbol": "ResultCode.SQLITE_IOERR_SHMLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 108, + "symbol": "ResultCode.SQLITE_IOERR_SHMMAP", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 109, + "symbol": "ResultCode.SQLITE_IOERR_SEEK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 110, + "symbol": "ResultCode.SQLITE_IOERR_DELETE_NOENT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 111, + "symbol": "ResultCode.SQLITE_IOERR_MMAP", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 112, + "symbol": "ResultCode.SQLITE_IOERR_GETTEMPPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 113, + "symbol": "ResultCode.SQLITE_IOERR_CONVPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 114, + "symbol": "ResultCode.SQLITE_IOERR_VNODE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 115, + "symbol": "ResultCode.SQLITE_IOERR_AUTH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 116, + "symbol": "ResultCode.SQLITE_IOERR_BEGIN_ATOMIC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 117, + "symbol": "ResultCode.SQLITE_IOERR_COMMIT_ATOMIC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 118, + "symbol": "ResultCode.SQLITE_IOERR_ROLLBACK_ATOMIC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 119, + "symbol": "ResultCode.SQLITE_LOCKED_SHAREDCACHE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 120, + "symbol": "ResultCode.SQLITE_LOCKED_VTAB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 121, + "symbol": "ResultCode.SQLITE_BUSY_RECOVERY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 122, + "symbol": "ResultCode.SQLITE_BUSY_SNAPSHOT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 123, + "symbol": "ResultCode.SQLITE_CANTOPEN_NOTEMPDIR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 124, + "symbol": "ResultCode.SQLITE_CANTOPEN_ISDIR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 125, + "symbol": "ResultCode.SQLITE_CANTOPEN_FULLPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 126, + "symbol": "ResultCode.SQLITE_CANTOPEN_CONVPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 127, + "symbol": "ResultCode.SQLITE_CANTOPEN_DIRTYWAL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 128, + "symbol": "ResultCode.SQLITE_CORRUPT_VTAB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 129, + "symbol": "ResultCode.SQLITE_CORRUPT_SEQUENCE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 130, + "symbol": "ResultCode.SQLITE_READONLY_RECOVERY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 131, + "symbol": "ResultCode.SQLITE_READONLY_CANTLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 132, + "symbol": "ResultCode.SQLITE_READONLY_ROLLBACK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 133, + "symbol": "ResultCode.SQLITE_READONLY_DBMOVED", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 134, + "symbol": "ResultCode.SQLITE_READONLY_CANTINIT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 135, + "symbol": "ResultCode.SQLITE_READONLY_DIRECTORY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 136, + "symbol": "ResultCode.SQLITE_ABORT_ROLLBACK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 137, + "symbol": "ResultCode.SQLITE_CONSTRAINT_CHECK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 138, + "symbol": "ResultCode.SQLITE_CONSTRAINT_COMMITHOOK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 139, + "symbol": "ResultCode.SQLITE_CONSTRAINT_FOREIGNKEY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 140, + "symbol": "ResultCode.SQLITE_CONSTRAINT_FUNCTION", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 141, + "symbol": "ResultCode.SQLITE_CONSTRAINT_NOTNULL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 142, + "symbol": "ResultCode.SQLITE_CONSTRAINT_PRIMARYKEY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 143, + "symbol": "ResultCode.SQLITE_CONSTRAINT_TRIGGER", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 144, + "symbol": "ResultCode.SQLITE_CONSTRAINT_UNIQUE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 145, + "symbol": "ResultCode.SQLITE_CONSTRAINT_VTAB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 146, + "symbol": "ResultCode.SQLITE_CONSTRAINT_ROWID", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 147, + "symbol": "ResultCode.SQLITE_NOTICE_RECOVER_WAL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 148, + "symbol": "ResultCode.SQLITE_NOTICE_RECOVER_ROLLBACK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 149, + "symbol": "ResultCode.SQLITE_WARNING_AUTOINDEX", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 150, + "symbol": "ResultCode.SQLITE_AUTH_USER", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 151, + "symbol": "ResultCode.SQLITE_OK_LOAD_PERMANENTLY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 269, + "symbol": "DatabaseError.SQLITE_OK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 270, + "symbol": "DatabaseError.SQLITE_ERROR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 271, + "symbol": "DatabaseError.SQLITE_INTERNAL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 272, + "symbol": "DatabaseError.SQLITE_PERM", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 273, + "symbol": "DatabaseError.SQLITE_ABORT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 274, + "symbol": "DatabaseError.SQLITE_BUSY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 275, + "symbol": "DatabaseError.SQLITE_LOCKED", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 276, + "symbol": "DatabaseError.SQLITE_NOMEM", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 277, + "symbol": "DatabaseError.SQLITE_READONLY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 278, + "symbol": "DatabaseError.SQLITE_INTERRUPT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 279, + "symbol": "DatabaseError.SQLITE_IOERR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 280, + "symbol": "DatabaseError.SQLITE_CORRUPT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 281, + "symbol": "DatabaseError.SQLITE_NOTFOUND", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 282, + "symbol": "DatabaseError.SQLITE_FULL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 283, + "symbol": "DatabaseError.SQLITE_CANTOPEN", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 284, + "symbol": "DatabaseError.SQLITE_PROTOCOL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 285, + "symbol": "DatabaseError.SQLITE_EMPTY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 286, + "symbol": "DatabaseError.SQLITE_SCHEMA", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 287, + "symbol": "DatabaseError.SQLITE_TOOBIG", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 288, + "symbol": "DatabaseError.SQLITE_CONSTRAINT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 289, + "symbol": "DatabaseError.SQLITE_MISMATCH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 290, + "symbol": "DatabaseError.SQLITE_MISUSE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 291, + "symbol": "DatabaseError.SQLITE_NOLFS", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 292, + "symbol": "DatabaseError.SQLITE_AUTH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 293, + "symbol": "DatabaseError.SQLITE_FORMAT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 294, + "symbol": "DatabaseError.SQLITE_RANGE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 295, + "symbol": "DatabaseError.SQLITE_NOTADB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 296, + "symbol": "DatabaseError.SQLITE_NOTICE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 297, + "symbol": "DatabaseError.SQLITE_WARNING", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 298, + "symbol": "DatabaseError.SQLITE_ROW", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 299, + "symbol": "DatabaseError.SQLITE_DONE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 300, + "symbol": "DatabaseError.SQLITE_ERROR_MISSING_COLLSEQ", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 301, + "symbol": "DatabaseError.SQLITE_ERROR_RETRY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 302, + "symbol": "DatabaseError.SQLITE_ERROR_SNAPSHOT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 303, + "symbol": "DatabaseError.SQLITE_IOERR_READ", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 304, + "symbol": "DatabaseError.SQLITE_IOERR_SHORT_READ", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 305, + "symbol": "DatabaseError.SQLITE_IOERR_WRITE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 306, + "symbol": "DatabaseError.SQLITE_IOERR_FSYNC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 307, + "symbol": "DatabaseError.SQLITE_IOERR_DIR_FSYNC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 308, + "symbol": "DatabaseError.SQLITE_IOERR_TRUNCATE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 309, + "symbol": "DatabaseError.SQLITE_IOERR_FSTAT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 310, + "symbol": "DatabaseError.SQLITE_IOERR_UNLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 311, + "symbol": "DatabaseError.SQLITE_IOERR_RDLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 312, + "symbol": "DatabaseError.SQLITE_IOERR_DELETE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 313, + "symbol": "DatabaseError.SQLITE_IOERR_BLOCKED", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 314, + "symbol": "DatabaseError.SQLITE_IOERR_NOMEM", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 315, + "symbol": "DatabaseError.SQLITE_IOERR_ACCESS", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 316, + "symbol": "DatabaseError.SQLITE_IOERR_CHECKRESERVEDLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 317, + "symbol": "DatabaseError.SQLITE_IOERR_LOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 318, + "symbol": "DatabaseError.SQLITE_IOERR_CLOSE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 319, + "symbol": "DatabaseError.SQLITE_IOERR_DIR_CLOSE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 320, + "symbol": "DatabaseError.SQLITE_IOERR_SHMOPEN", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 321, + "symbol": "DatabaseError.SQLITE_IOERR_SHMSIZE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 322, + "symbol": "DatabaseError.SQLITE_IOERR_SHMLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 323, + "symbol": "DatabaseError.SQLITE_IOERR_SHMMAP", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 324, + "symbol": "DatabaseError.SQLITE_IOERR_SEEK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 325, + "symbol": "DatabaseError.SQLITE_IOERR_DELETE_NOENT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 326, + "symbol": "DatabaseError.SQLITE_IOERR_MMAP", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 327, + "symbol": "DatabaseError.SQLITE_IOERR_GETTEMPPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 328, + "symbol": "DatabaseError.SQLITE_IOERR_CONVPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 329, + "symbol": "DatabaseError.SQLITE_IOERR_VNODE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 330, + "symbol": "DatabaseError.SQLITE_IOERR_AUTH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 331, + "symbol": "DatabaseError.SQLITE_IOERR_BEGIN_ATOMIC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 332, + "symbol": "DatabaseError.SQLITE_IOERR_COMMIT_ATOMIC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 333, + "symbol": "DatabaseError.SQLITE_IOERR_ROLLBACK_ATOMIC", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 334, + "symbol": "DatabaseError.SQLITE_LOCKED_SHAREDCACHE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 335, + "symbol": "DatabaseError.SQLITE_LOCKED_VTAB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 336, + "symbol": "DatabaseError.SQLITE_BUSY_RECOVERY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 337, + "symbol": "DatabaseError.SQLITE_BUSY_SNAPSHOT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 338, + "symbol": "DatabaseError.SQLITE_CANTOPEN_NOTEMPDIR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 339, + "symbol": "DatabaseError.SQLITE_CANTOPEN_ISDIR", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 340, + "symbol": "DatabaseError.SQLITE_CANTOPEN_FULLPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 341, + "symbol": "DatabaseError.SQLITE_CANTOPEN_CONVPATH", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 342, + "symbol": "DatabaseError.SQLITE_CANTOPEN_DIRTYWAL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 343, + "symbol": "DatabaseError.SQLITE_CORRUPT_VTAB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 344, + "symbol": "DatabaseError.SQLITE_CORRUPT_SEQUENCE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 345, + "symbol": "DatabaseError.SQLITE_READONLY_RECOVERY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 346, + "symbol": "DatabaseError.SQLITE_READONLY_CANTLOCK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 347, + "symbol": "DatabaseError.SQLITE_READONLY_ROLLBACK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 348, + "symbol": "DatabaseError.SQLITE_READONLY_DBMOVED", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 349, + "symbol": "DatabaseError.SQLITE_READONLY_CANTINIT", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 350, + "symbol": "DatabaseError.SQLITE_READONLY_DIRECTORY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 351, + "symbol": "DatabaseError.SQLITE_ABORT_ROLLBACK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 352, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_CHECK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 353, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_COMMITHOOK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 354, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 355, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_FUNCTION", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 356, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_NOTNULL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 357, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_PRIMARYKEY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 358, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_TRIGGER", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 359, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_UNIQUE", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 360, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_VTAB", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 361, + "symbol": "DatabaseError.SQLITE_CONSTRAINT_ROWID", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 362, + "symbol": "DatabaseError.SQLITE_NOTICE_RECOVER_WAL", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 363, + "symbol": "DatabaseError.SQLITE_NOTICE_RECOVER_ROLLBACK", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 364, + "symbol": "DatabaseError.SQLITE_WARNING_AUTOINDEX", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 365, + "symbol": "DatabaseError.SQLITE_AUTH_USER", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseError.swift", + "line": 366, + "symbol": "DatabaseError.SQLITE_OK_LOAD_PERMANENTLY", + "symbol_kind": "source.lang.swift.decl.var.static", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseRegion.swift", + "line": 371, + "symbol": "AnyDatabaseRegionConvertible.init(_:)", + "symbol_kind": "source.lang.swift.decl.function.method.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseRegion.swift", + "line": 375, + "symbol": "AnyDatabaseRegionConvertible.init(_:)", + "symbol_kind": "source.lang.swift.decl.function.method.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/DatabaseWriter.swift", + "line": 298, + "symbol": "DatabaseWriter.remove(transactionObserver:)", + "symbol_kind": "source.lang.swift.decl.function.method.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/FetchRequest.swift", + "line": 96, + "symbol": "AdaptedFetchRequest.sqlSubquery", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/FetchRequest.swift", + "line": 138, + "symbol": "AnyFetchRequest.sqlSubquery", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/SQLRequest.swift", + "line": 143, + "symbol": "SQLRequest.sqlSubquery", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/Statement.swift", + "line": 20, + "symbol": "StatementBinding", + "symbol_kind": "source.lang.swift.decl.extension", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/Statement.swift", + "line": 294, + "symbol": "SelectStatement", + "symbol_kind": "source.lang.swift.decl.typealias", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/Statement.swift", + "line": 297, + "symbol": "UpdateStatement", + "symbol_kind": "source.lang.swift.decl.typealias", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/Statement.swift", + "line": 438, + "symbol": "StatementBinding", + "symbol_kind": "source.lang.swift.decl.protocol", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Core/Statement.swift", + "line": 534, + "symbol": "StatementArguments.isEmpty", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Fixit/GRDB-5.0.swift", + "line": 195, + "symbol": "SQLLiteral", + "symbol_kind": "source.lang.swift.decl.typealias", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Fixit/GRDB-5.0.swift", + "line": 218, + "symbol": "SQLiteral", + "symbol_kind": "source.lang.swift.decl.typealias", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift", + "line": 38, + "symbol": "QueryInterfaceRequest.sqlSubquery", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/SQL/SQLExpression.swift", + "line": 366, + "symbol": "SQLAssociativeBinaryOperator", + "symbol_kind": "source.lang.swift.decl.typealias", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/SQL/SQLSubquery.swift", + "line": 90, + "symbol": "SQLSubqueryable.sqlSubquery", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/SQL/SQLSubquery.swift", + "line": 96, + "symbol": "SQLSubquery.sqlSubquery", + "symbol_kind": "source.lang.swift.decl.var.instance", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/Schema/TableDefinition.swift", + "line": 748, + "symbol": "ColumnDefinition.GeneratedColumnQualification.virtual", + "symbol_kind": "source.lang.swift.decl.enumelement", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/Schema/TableDefinition.swift", + "line": 749, + "symbol": "ColumnDefinition.GeneratedColumnQualification.stored", + "symbol_kind": "source.lang.swift.decl.enumelement", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/QueryInterface/Schema/VirtualTableModule.swift", + "line": 60, + "symbol": "VirtualTableConfiguration", + "symbol_kind": "source.lang.swift.decl.struct", + "warning": "undocumented" + }, + { + "file": "/Users/groue/Documents/git/groue/GRDB.swift/GRDB/Utils/Inflections.swift", + "line": 54, + "symbol": "Inflections.init()", + "symbol_kind": "source.lang.swift.decl.function.method.instance", + "warning": "undocumented" + } + ], + "source_directory": "/Users/groue/Documents/git/groue/GRDB.swift" +} \ No newline at end of file