Instance Method
deleteDB(_:eventLoopGroup:)
Deletes a database from the CouchDB server.
@discardableResult func deleteDB(_ dbName: String, eventLoopGroup: (any EventLoopGroup)? = nil) async throws -> UpdateDBResponse
Parameters
- dbName
The name of the database to delete.
- eventLoopGroup
An optional EventLoopGroup used for executing network operations. If not provided, the function defaults to using a shared instance of HTTPClient.
Return Value
An UpdateDBResponse object that contains the result of the database deletion operation.
Discussion
This method sends a DELETE request for the specified database and decodes CouchDB’s update response. It supports using a custom EventLoopGroup for managing network operations.
Throws
A CouchDBClientError if authentication fails, the response body is missing, or CouchDB returns an error payload that maps to .deleteError(error:). Non-CouchDB decoding failures are propagated as the underlying decoding error.
Example Usage:
let deletionResult = try await couchDBClient.deleteDB("obsoleteDatabase")
print("Database deletion successful: \(deletionResult.ok)")
Note
Ensure that the CouchDB server is running and accessible before calling this function. Handle thrown errors appropriately, especially authentication issues and conflicts if the database does not exist.