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

    name

    The name of the index.

    unique

    An indication whether the index has to be unique.

    columns

    An 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

    name

    The name of the index.

    unique

    An indication whether the index has to be unique.

    columns

    A list of columns of the index.

  • Create the index in the database.

    Declaration

    Swift

    public func create(connection: Connection, onCompletion: @escaping ((QueryResult) -> ()))

    Parameters

    connection

    The connection to the database.

    onCompletion

    The 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

    connection

    The connection to the database.

    onCompletion

    The 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 -> String

    Return Value

    A String representation of the index create statement.