Skip to content

Commit 1b44118

Browse files
committed
fix: update MongoClient import to use npm package and adjust initialization
1 parent eeac869 commit 1b44118

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/backend/db.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { MongoClient } from "./dependencies.ts";
22
import getProviderUser from "./utils/get-user.ts";
33
import DfContentMap from "./types/maps_interface.ts";
44

5-
// Initialize MongoClient
6-
const client = new MongoClient();
5+
// Initialize MongoClient with npm driver
76
const MONGO_URI = Deno.env.get("MONGO_URI");
7+
const client = MONGO_URI ? new MongoClient(MONGO_URI) : null;
88

99
console.log("--- DB INIT DEBUG ---");
1010
console.log("CWD:", Deno.cwd());
@@ -18,10 +18,10 @@ let userAuthCollection: any;
1818
let contentMapsCollection: any;
1919

2020
try {
21-
if (MONGO_URI) {
21+
if (MONGO_URI && client) {
2222
console.log("Attempting to connect to MongoDB...");
23-
await client.connect(MONGO_URI);
24-
db = client.database("df_test");
23+
await client.connect();
24+
db = client.db("df_test");
2525
userAuthCollection = db.collection("user_auth");
2626
contentMapsCollection = db.collection("content_maps");
2727
console.log("✅ Connected to MongoDB successfully");

src/backend/dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { exec } from "https://deno.land/x/exec@0.0.5/mod.ts";
1111
import * as Sentry from 'https://deno.land/x/sentry/index.mjs';
1212
import { oakCors } from "https://deno.land/x/cors@v1.2.2/mod.ts";
1313
import { load } from "https://deno.land/std@0.224.0/dotenv/mod.ts";
14-
import { MongoClient, ObjectId } from "https://deno.land/x/mongo@v0.33.0/mod.ts";
14+
import { MongoClient, ObjectId } from "npm:mongodb@6.1.0";
1515

1616
try {
1717
await load({ export: true }); // Try default .env in CWD

0 commit comments

Comments
 (0)