Required Instance Methodgrdb 7.4.0GRDB

filterWhenConnected(_:)

Filters the fetched rows with a boolean SQL expression.

RequestProtocols.swift:249
func filterWhenConnected(_ predicate: @escaping (Database) throws -> any SQLExpressible) -> Self

Parameters

predicate

A closure that accepts a database connection and returns a boolean SQL expression.

The predicate parameter is a closure that accepts a database connection and returns a boolean SQL expression. It is evaluated when the request has an access to the database, and can perform database requests in order to build its result.

For example:

// SELECT * FROM player WHERE name = 'O''Brien'
let name = "O'Brien"
let request = Player.all().filterWhenConnected { db in
    Column("name") == name
}