Index
public struct Index
The SQL INDEX.
-
Initialize an instance of Index.
Declaration
Swift
public init(_ name: String, unique: Bool = false, on table: Table, columns: [IndexColumn])Parameters
nameThe name of the index.
uniqueAn indication whether the index has to be unique.
columnsAn array of columns of the index.
-
Initialize an instance of Index.
Declaration
Swift
public init(_ name: String, unique: Bool = false, on table: Table, columns: IndexColumn...)Parameters
nameThe name of the index.
uniqueAn indication whether the index has to be unique.
columnsA list of columns of the index.
-
Create the index in the database.
Declaration
Swift
public func create(connection: Connection, onCompletion: @escaping ((QueryResult) -> ()))Parameters
connectionThe connection to the database.
onCompletionThe function to be called when the execution of the query has completed.
-
Drop the index from the database.
Declaration
Swift
public func drop(connection: Connection, onCompletion: @escaping ((QueryResult) -> ()))Parameters
connectionThe connection to the database.
onCompletionThe function to be called when the execution of the query has completed.
-
Return a String representation of the index create statement.
Throws
QueryError.syntaxError if statement build fails.Declaration
Swift
public func description(connection: Connection) throws -> StringReturn Value
A String representation of the index create statement.
View on GitHub
Index Structure Reference