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:
Extension methodarguments: ) 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 = StatementArguments()) -> Self
-
filter(literal:
Extension method) Creates a request with the provided predicate added to the eventual set of already applied predicates.
Literals allow you to safely embed raw values in your SQL, without any risk of syntax errors or SQL injection:
// SELECT * FROM player WHERE name = 'O''Brien' let name = "O'Brien" var request = Player.all() request = request.filter(literal: "email = \(email)")
Declaration
Swift
public func filter(literal sqlLiteral: SQL) -> Self
-
none()
Extension methodCreates a request that matches nothing.
// SELECT * FROM player WHERE 0 var request = Player.all() request = request.none()
Declaration
Swift
public func none() -> Self