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

Support Deno 2 #416

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Deno
uses: denolib/setup-deno@master
with:
deno-version: 1.x.x
deno-version: 2.x.x

- name: Log versions
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:

- name: Publish to JSR
run: |
deno publish
deno publish
6 changes: 3 additions & 3 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export {
Timestamp,
UUID,
} from "jsr:@lucsoft/web-bson@^0.3.1";
export { crypto as stdCrypto } from "jsr:@std/crypto@^0.224.0/crypto";
export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^0.224.0/base64";
export { encodeHex } from "jsr:@std/encoding@^0.224.0/hex";
export { crypto as stdCrypto } from "jsr:@std/crypto@^1.0.3/crypto";
export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^1.0.5/base64";
export { encodeHex } from "jsr:@std/encoding@^1.0.5/hex";
24 changes: 13 additions & 11 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export class MongoClient {
*
* @param options Connection options or a MongoDB URI
*/
async connect(
options: ConnectOptions | string,
): Promise<Database> {
async connect(options: ConnectOptions | string): Promise<Database> {
try {
const parsedOptions = typeof options === "string"
? await parse(options)
Expand All @@ -59,8 +57,10 @@ export class MongoClient {
this.#buildInfo = await this.runCommand(this.#defaultDbName, {
buildInfo: 1,
});
} catch (e) {
throw new MongoDriverError(`Connection failed: ${e.message || e}`);
} catch (e: unknown) {
throw new MongoDriverError(
`Connection failed: ${e instanceof Error ? e.message : "unknown"}`,
);
}
return this.database((options as ConnectOptions).db);
}
Expand All @@ -71,12 +71,14 @@ export class MongoClient {
* @param options Options to pass to the `listDatabases` command
* @returns A list of databases including their name, size on disk, and whether they are empty
*/
async listDatabases(options: {
filter?: Document;
nameOnly?: boolean;
authorizedCollections?: boolean;
comment?: Document;
} = {}): Promise<ListDatabaseInfo[]> {
async listDatabases(
options: {
filter?: Document;
nameOnly?: boolean;
authorizedCollections?: boolean;
comment?: Document;
} = {},
): Promise<ListDatabaseInfo[]> {
const { databases } = await this.getCluster().protocol.commandSingle(
"admin",
{
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class MongoRuntimeError extends MongoDriverError {
super(message);
}

get name(): string {
override get name(): string {
return "MongoRuntimeError";
}
}
Loading
Loading