Classes
The following classes are available globally.
-
An enumeration of the elements of a cursor.
To create an instance of
EnumeratedCursor
, call theenumerated()
method on a cursor:
See morelet cursor = try String.fetchCursor(db, "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"
-
A cursor whose elements consist of the elements of some base cursor that also satisfy a given predicate.
See more -
A cursor consisting of all the elements contained in each segment contained in some Base cursor.
See Cursor.joined(), Cursor.flatMap(:), Sequence.flatMap(:)
See moreDeclaration
-
A Cursor whose elements consist of those in a Base Cursor passed through a transform function returning Element.
See Cursor.map(_:)
See more
-
A Database connection.
You don’t create a database directly. Instead, you use a DatabaseQueue, or a DatabasePool:
See morelet dbQueue = DatabaseQueue(...) // The Database is the `db` in the closure: try dbQueue.inDatabase { db in try db.execute(...) }
Declaration
Swift
public final class Database
-
An SQL function.
See moreDeclaration
Swift
public final class DatabaseFunction
-
A Collation is a string comparison function used by SQLite.
See moreDeclaration
Swift
public final class DatabaseCollation
-
A DatabasePool grants concurrent accesses to an SQLite database.
See moreDeclaration
Swift
public final class DatabasePool
-
A DatabaseQueue serializes access to an SQLite database.
See moreDeclaration
Swift
public final class DatabaseQueue
-
You use FetchedRecordsController to track changes in the results of an SQLite request.
See https://github.com/groue/GRDB.swift#fetchedrecordscontroller for more information.
See moreDeclaration
Swift
public final class FetchedRecordsController<Record: RowConvertible>
-
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:
See moretry db.create(virtualTable: "documents", using: FTS3()) { t in // t is FTS3TableDefinition t.column("content") }
Declaration
Swift
public final class FTS3TableDefinition
-
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: "documents", using: FTS4()) { t in // t is FTS4TableDefinition t.column("content") }
See https://www.sqlite.org/fts3.html
See moreDeclaration
Swift
public final class FTS4TableDefinition
-
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: "persons", using: FTS4()) { t in t.column("content") // FTS4ColumnDefinition }
See https://www.sqlite.org/fts3.html
See moreDeclaration
Swift
public final class FTS4ColumnDefinition
-
Record is a class that wraps a table row, or the result of any query. It is designed to be subclassed.
See moreDeclaration
Swift
open class Record : RowConvertible, TableMapping, Persistable
-
A database row.
See moreDeclaration
Swift
public final class Row
-
A subclass of Statement that fetches database rows.
You create SelectStatement with the Database.makeSelectStatement() method:
See moretry dbQueue.inDatabase { db in let statement = try db.makeSelectStatement("SELECT COUNT(*) FROM persons WHERE age > ?") let moreThanTwentyCount = try Int.fetchOne(statement, arguments: [20])! let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])! }
Declaration
Swift
public final class SelectStatement : Statement
-
A statement represents an SQL query.
It is the base class of UpdateStatement that executes update statements, and SelectStatement that fetches rows.
See moreDeclaration
Swift
public class Statement
-
A subclass of Statement that executes SQL queries.
You create UpdateStatement with the Database.makeUpdateStatement() method:
See moretry dbQueue.inTransaction { db in let statement = try db.makeUpdateStatement("INSERT INTO persons (name) VALUES (?)") try statement.execute(arguments: ["Arthur"]) try statement.execute(arguments: ["Barbara"]) return .commit }
Declaration
Swift
public final class UpdateStatement : Statement
-
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: "persons") { t in // t is TableDefinition t.column(...) }
See https://www.sqlite.org/lang_createtable.html
See moreDeclaration
Swift
public final class TableDefinition
-
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: "persons") { t in // t is TableAlteration t.add(column: ...) }
See https://www.sqlite.org/lang_altertable.html
See moreDeclaration
Swift
public final class TableAlteration
-
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: "persons") { t in t.column(...) // ColumnDefinition } try db.alter(table: "persons") { t in t.add(column: ...) // ColumnDefinition }
See https://www.sqlite.org/lang_createtable.html and https://www.sqlite.org/lang_altertable.html
See moreDeclaration
Swift
public final class ColumnDefinition