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.
-
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
-
The name of the module.
Declaration
Swift
var moduleName: String { get }
-
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() }
Declaration
Swift
func makeTableDefinition() -> 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