Instance Method
getAllDBs(eventLoopGroup:)
Retrieves a list of all database names from the CouchDB server.
func getAllDBs(eventLoopGroup: (any EventLoopGroup)? = nil) async throws -> [String]
Parameters
- eventLoopGroup
An optional EventLoopGroup for executing network operations. If not provided, the function uses a shared instance of HTTPClient.
Return Value
An array of String containing the names of all databases available on the server.
Discussion
This asynchronous function sends a GET request to the CouchDB server to fetch the names of all databases. It supports using a custom NIO EventLoopGroup for network operations.
Throws
A CouchDBClientError if authentication fails, the response body is missing, or the returned JSON cannot be decoded into [String].
Example Usage:
let dbNames = try await couchDBClient.getAllDBs()
print("Available databases: \(dbNames)")
Note
Ensure that the CouchDB server is running and accessible before calling this function. Handle any thrown errors appropriately, particularly authentication-related issues.