Update

public struct Update : Query

The SQL UPDATE statement.

  • The table to update.

    Declaration

    Swift

    public let table: Table
  • The SQL WHERE clause containing the filter for the rows to update. Could be represented with a Filter clause or a String containing raw SQL.

    Declaration

    Swift

    public private(set) var whereClause: QueryFilterProtocol? { get }
  • A String with a clause to be appended to the end of the query.

    Declaration

    Swift

    public private(set) var suffix: QuerySuffixProtocol? { get }
  • An array of AuxiliaryTable which will be used in a query with a WITH clause.

    Declaration

    Swift

    public private(set) var with: [AuxiliaryTable]? { get }
  • Initialize an instance of Update.

    Declaration

    Swift

    public init(_ table: Table, set: [(Column, Any)], where conditions: QueryFilterProtocol? = nil)

    Parameters

    table

    The table to update.

    set

    An array of (column, value) tuples to set.

    conditions

    An optional where clause to apply.

  • Build the query using QueryBuilder.

    Throws

    QueryError.syntaxError if query build fails.

    Declaration

    Swift

    public func build(queryBuilder: QueryBuilder) throws -> String

    Parameters

    queryBuilder

    The QueryBuilder to use.

    Return Value

    A String representation of the query.

  • Add an SQL WHERE clause to the update statement.

    Declaration

    Swift

    public func `where`(_ conditions: QueryFilterProtocol) -> Update

    Parameters

    conditions

    The Filter clause or a String containing the SQL WHERE to apply.

    Return Value

    A new instance of Update.

  • Add a raw suffix to the update statement.

    Declaration

    Swift

    public func suffix(_ raw: String) -> Update

    Parameters

    raw

    A String with a clause to be appended to the end of the query.

    Return Value

    A new instance of Update.