Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/PostgreSQL/Database/PostgreSQLDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public final class PostgreSQLDatabase: Database {
do {
let client = try PostgreSQLConnection.connect(hostname: config.hostname, port: config.port, on: worker)
client.logger = logger
return client.authenticate(username: config.username).transform(to: client)
return client.authenticate(
username: config.username,
database: config.database,
password: config.password
).transform(to: client)
} catch {
return Future(error: error)
}
Expand Down
13 changes: 11 additions & 2 deletions Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ public struct PostgreSQLDatabaseConfig {

/// Username to authenticate.
public let username: String


/// Optional database name to use during authentication.
/// Defaults to the username.
public let database: String?

/// Optional password to use for authentication.
public let password: String?

/// Creates a new `PostgreSQLDatabaseConfig`.
public init(hostname: String, port: UInt16, username: String) {
public init(hostname: String, port: UInt16, username: String, database: String? = nil, password: String? = nil) {
self.hostname = hostname
self.port = port
self.username = username
self.database = database
self.password = password
}
}