Type MethodFluentKit
postgres(client:encodingContext:decodingContext:sqlLogLevel:logger:)
iOS 16.0+
iPadOS 16.0+
Mac Catalyst 16.0+
macOS 13.0+
tvOS 16.0+
watchOS 9.0+
Create a PostgreSQL database configuration from a PostgresClient.
static func postgres(client: PostgresClient, encodingContext: PostgresEncodingContext<some PostgresJSONEncoder> = .default, decodingContext: PostgresDecodingContext<some PostgresJSONDecoder> = .default, sqlLogLevel: Logger.Level = .debug, logger: Logger) -> DatabaseConfigurationFactory
Parameters
clientA
PostgresClient.encodingContextEncoding context to use for serializing data.
decodingContextDecoding context to use for deserializing data.
sqlLogLevelLevel at which to log SQL queries.
loggerLogger to use in the client.
Discussion
This is different to the other configuration factories as it uses PostgresNIO’s modern PostgresClient connection pool under the hood instead of the AsyncKit pool. The client’s lifecycle is expected to be managed by the caller.
Warning
The database that’s returned using this configuration is not castable to a PostgresDatabase, and TransactionControlDatabase is to be used inside withConnection.