Skip to content

Instance Method

query(_:_:logger:_:)

Execute a query on the connection, calling the provided closure for each result row (if any).
@preconcurrency func query(_ query: String, _ binds: [SQLiteData], logger: Logger, _ onRow: @escaping @Sendable (SQLiteRow) -> Void) -> EventLoopFuture<Void>

Parameters

query

The query string to execute.

binds

An ordered list of SQLiteData items to use as bound parameters for the query.

logger

Ignored. See above discussion for details.

onRow

A closure to invoke for each result row returned by the query, if any.

Return Value

A future completed when the query has executed and returned all results (if any).

Discussion

This is the primary interface to connections vended via this protocol.

Warning

The logger parameter of this method is a holdover from Fluent 4’s development cycle that should have been removed before the final release. Unfortunately, this didn’t happen, and semantic versioning has left the API stuck with it ever single. Callers of this API should either always pass the value of the logger property or use query(_:_:_:) instead. Implementations that wish to conform to this protocol should ignore the parameter entirely in favor of the logger property. At no time during SQLiteNIO’s lifetime has this parameter ever been honored; indeed, at the time of this writing, SQLiteConnection‘s implementation of this method doesn’t use any logger at all.