Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added close connection method, so the API is similar to the official one #26

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 13 additions & 0 deletions src/duckdb-async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const connAllAsync = methodPromisify<duckdb.Connection, duckdb.TableData>(
duckdb.Connection.prototype.all
);

const connCloseAsync = methodPromisify<duckdb.Connection, void>(
duckdb.Connection.prototype.close
);

const connArrowIPCAll = methodPromisify<duckdb.Connection, duckdb.ArrowArray>(
duckdb.Connection.prototype.arrowIPCAll
);
Expand Down Expand Up @@ -100,6 +104,15 @@ export class Connection {
});
}

async close(): Promise<void> {
if (!this.conn) {
throw new Error("Connection.close: uninitialized connection");
}
await connCloseAsync(this.conn);
this.conn = null;
return;
}

async all(sql: string, ...args: any[]): Promise<duckdb.TableData> {
if (!this.conn) {
throw new Error("Connection.all: uninitialized connection");
Expand Down