-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd965d4
commit f282450
Showing
3 changed files
with
11 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import { MongoClient } from "mongodb"; | ||
import { Db, MongoClient } from "mongodb"; | ||
|
||
const connectionString = | ||
process.env.MONGO_CONNECTION_STRING || "noconnectionstringpassed"; | ||
|
||
const dbName = "soulector"; | ||
|
||
let cachedClient: Db; | ||
|
||
export async function createDbConnection() { | ||
if (cachedClient) { | ||
return cachedClient; | ||
} | ||
|
||
const client = new MongoClient(connectionString); | ||
await client.connect(); | ||
const db = client.db(dbName); | ||
cachedClient = db; | ||
return db; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f282450
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for soulector ready!
✅ Preview
https://soulector-qu46a4c4j-jalvarado91.vercel.app
Built with commit f282450.
This pull request is being automatically deployed with vercel-action