Skip to content

Commit f49e2b0

Browse files
committed
chore: style changes, use a getter for isConnectedToMongoDB
1 parent f7ec158 commit f49e2b0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/common/session.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,22 @@ export class Session extends EventEmitter<SessionEvents> {
105105
await this.apiClient.close();
106106
}
107107

108-
async connectToMongoDB(settings: ConnectionSettings): Promise<AnyConnectionState> {
108+
async connectToMongoDB(settings: ConnectionSettings): Promise<void> {
109109
try {
110-
return await this.connectionManager.connect({ ...settings });
110+
await this.connectionManager.connect({ ...settings });
111111
} catch (error: unknown) {
112112
const message = error instanceof Error ? error.message : (error as string);
113113
this.emit("connection-error", message);
114114
throw error;
115115
}
116116
}
117117

118-
isConnectedToMongoDB(): boolean {
118+
get isConnectedToMongoDB(): boolean {
119119
return this.connectionManager.currentConnectionState.tag === "connected";
120120
}
121121

122122
get serviceProvider(): NodeDriverServiceProvider {
123-
if (this.isConnectedToMongoDB()) {
123+
if (this.isConnectedToMongoDB) {
124124
const state = this.connectionManager.currentConnectionState as ConnectionStateConnected;
125125
return state.serviceProvider;
126126
}

src/tools/mongodb/connect/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class ConnectTool extends MongoDBToolBase {
8787
}
8888

8989
private updateMetadata(): void {
90-
if (this.session.isConnectedToMongoDB()) {
90+
if (this.session.isConnectedToMongoDB) {
9191
this.update?.({
9292
name: connectedName,
9393
description: connectedDescription,

src/tools/mongodb/mongodbTool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export abstract class MongoDBToolBase extends ToolBase {
1717
public category: ToolCategory = "mongodb";
1818

1919
protected async ensureConnected(): Promise<NodeDriverServiceProvider> {
20-
if (!this.session.isConnectedToMongoDB()) {
20+
if (!this.session.isConnectedToMongoDB) {
2121
if (this.session.connectedAtlasCluster) {
2222
throw new MongoDBError(
2323
ErrorCodes.NotConnectedToMongoDB,
@@ -39,7 +39,7 @@ export abstract class MongoDBToolBase extends ToolBase {
3939
}
4040
}
4141

42-
if (!this.session.isConnectedToMongoDB()) {
42+
if (!this.session.isConnectedToMongoDB) {
4343
throw new MongoDBError(ErrorCodes.NotConnectedToMongoDB, "Not connected to MongoDB");
4444
}
4545

@@ -117,7 +117,7 @@ export abstract class MongoDBToolBase extends ToolBase {
117117
return super.handleError(error, args);
118118
}
119119

120-
protected connectToMongoDB(connectionString: string): Promise<AnyConnectionState> {
120+
protected connectToMongoDB(connectionString: string): Promise<void> {
121121
return this.session.connectToMongoDB({ connectionString, ...this.config.connectOptions });
122122
}
123123

0 commit comments

Comments
 (0)