FilteredRequest

public protocol FilteredRequest

The protocol for all requests that can be filtered.

  • filter(_:) Default implementation

    Creates a request with the provided predicate promise added to the eventual set of already applied predicates.

    // SELECT * FROM player WHERE 1
    var request = Player.all()
    request = request.filter { db in true }
    

    Default Implementation

    Creates a request with the provided predicate added to the eventual set of already applied predicates.

    // SELECT * FROM player WHERE email = 'arthur@example.com'
    var request = Player.all()
    request = request.filter(Column("email") == "arthur@example.com")
    

    Declaration

    Swift

    func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self
  • filter(sql:arguments:) Extension method

    Creates a request with the provided predicate added to the eventual set of already applied predicates.

    // SELECT * FROM player WHERE email = 'arthur@example.com'
    var request = Player.all()
    request = request.filter(sql: "email = ?", arguments: ["arthur@example.com"])
    

    Declaration

    Swift

    public func filter(sql: String, arguments: StatementArguments? = nil) -> Self
  • none() Extension method

    Creates a request that matches nothing.

    // SELECT * FROM player WHERE 0
    var request = Player.all()
    request = request.none()
    

    Declaration

    Swift

    public func none() -> Self