Sequence

extension Sequence
extension Sequence where Element == SQL
extension Sequence where Element: SQLSpecificExpressible
extension Sequence where Element == SQLSpecificExpressible
extension Sequence where Self.Iterator.Element: SQLExpressible
extension Sequence where Self.Iterator.Element == SQLExpressible
  • Returns a cursor over the concatenated results of mapping transform over self.

    Declaration

    Swift

    public func flatMap<SegmentOfResult: Cursor>(
        _ transform: @escaping (Iterator.Element) throws -> SegmentOfResult)
    -> FlattenCursor<MapCursor<AnyCursor<Iterator.Element>, SegmentOfResult>>

Available where Element == SQL

  • Returns the concatenated SQL literal of this sequence of literals, inserting the given separator between each element.

    let components: [SQL] = [
        "UPDATE player",
        "SET name = \(name)",
        "WHERE id = \(id)"
    ]
    let query = components.joined(separator: " ")
    

    Declaration

    Swift

    public func joined(separator: String = "") -> SQL

Available where Element: SQLSpecificExpressible

  • Returns an expression by joining all elements with an associative SQL binary operator.

    For example:

    // SELECT * FROM player
    // WHERE (registered
    //        AND (score >= 1000)
    //        AND (name IS NOT NULL))
    let conditions = [
        Column("registered"),
        Column("score") >= 1000,
        Column("name") != nil]
    Player.filter(conditions.joined(operator: .and))
    

    When the sequence is empty, joined(operator:) returns the neutral value of the operator. It is 0 (zero) for .add, 1 for ‘.multiply, false for.or, and true for.and`.

    Declaration

    Swift

    public func joined(operator: SQLExpression.AssociativeBinaryOperator) -> SQLExpression

Available where Element == SQLSpecificExpressible

  • Returns an expression by joining all elements with an associative SQL binary operator.

    For example:

    // SELECT * FROM player
    // WHERE (registered
    //        AND (score >= 1000)
    //        AND (name IS NOT NULL))
    let conditions = [
        Column("registered"),
        Column("score") >= 1000,
        Column("name") != nil]
    Player.filter(conditions.joined(operator: .and))
    

    When the sequence is empty, joined(operator:) returns the neutral value of the operator. It is 0 (zero) for .add, 1 for ‘.multiply, false for.or, and true for.and`.

    Declaration

    Swift

    public func joined(operator: SQLExpression.AssociativeBinaryOperator) -> SQLExpression

Available where Self.Iterator.Element: SQLExpressible

Available where Self.Iterator.Element == SQLExpressible