Skip to content

Commit a816284

Browse files
committed
chore: some minor changes to make deno2 happy
1 parent dfbd1b3 commit a816284

File tree

6 files changed

+272
-237
lines changed

6 files changed

+272
-237
lines changed

.github/workflows/jsr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
3434
- name: Publish to JSR
3535
run: |
36-
deno publish
36+
deno publish

deps.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export {
1616
Timestamp,
1717
UUID,
1818
} from "jsr:@lucsoft/web-bson@^0.3.1";
19-
export { crypto as stdCrypto } from "jsr:@std/crypto@^0.224.0/crypto";
20-
export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^0.224.0/base64";
21-
export { encodeHex } from "jsr:@std/encoding@^0.224.0/hex";
19+
export { crypto as stdCrypto } from "jsr:@std/crypto@^1.0.3/crypto";
20+
export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^1.0.5/base64";
21+
export { encodeHex } from "jsr:@std/encoding@^1.0.5/hex";

src/client.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class MongoClient {
2929
getCluster(): Cluster {
3030
if (!this.#cluster) {
3131
throw new MongoDriverError(
32-
"MongoClient is not connected to the Database",
32+
"MongoClient is not connected to the Database"
3333
);
3434
}
3535

@@ -41,13 +41,10 @@ export class MongoClient {
4141
*
4242
* @param options Connection options or a MongoDB URI
4343
*/
44-
async connect(
45-
options: ConnectOptions | string,
46-
): Promise<Database> {
44+
async connect(options: ConnectOptions | string): Promise<Database> {
4745
try {
48-
const parsedOptions = typeof options === "string"
49-
? await parse(options)
50-
: options;
46+
const parsedOptions =
47+
typeof options === "string" ? await parse(options) : options;
5148

5249
this.#defaultDbName = parsedOptions.db;
5350
const cluster = new Cluster(parsedOptions);
@@ -59,8 +56,10 @@ export class MongoClient {
5956
this.#buildInfo = await this.runCommand(this.#defaultDbName, {
6057
buildInfo: 1,
6158
});
62-
} catch (e) {
63-
throw new MongoDriverError(`Connection failed: ${e.message || e}`);
59+
} catch (e: unknown) {
60+
throw new MongoDriverError(
61+
`Connection failed: ${e instanceof Error ? e.message : "unknown"}`
62+
);
6463
}
6564
return this.database((options as ConnectOptions).db);
6665
}
@@ -71,18 +70,20 @@ export class MongoClient {
7170
* @param options Options to pass to the `listDatabases` command
7271
* @returns A list of databases including their name, size on disk, and whether they are empty
7372
*/
74-
async listDatabases(options: {
75-
filter?: Document;
76-
nameOnly?: boolean;
77-
authorizedCollections?: boolean;
78-
comment?: Document;
79-
} = {}): Promise<ListDatabaseInfo[]> {
73+
async listDatabases(
74+
options: {
75+
filter?: Document;
76+
nameOnly?: boolean;
77+
authorizedCollections?: boolean;
78+
comment?: Document;
79+
} = {}
80+
): Promise<ListDatabaseInfo[]> {
8081
const { databases } = await this.getCluster().protocol.commandSingle(
8182
"admin",
8283
{
8384
listDatabases: 1,
8485
...options,
85-
},
86+
}
8687
);
8788
return databases;
8889
}

src/error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class MongoRuntimeError extends MongoDriverError {
7373
super(message);
7474
}
7575

76-
get name(): string {
76+
override get name(): string {
7777
return "MongoRuntimeError";
7878
}
7979
}

0 commit comments

Comments
 (0)