-
Notifications
You must be signed in to change notification settings - Fork 1
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
6095a4f
commit fcbc4af
Showing
4 changed files
with
192 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import * as mongodb from "mongodb"; | ||
|
||
const MongoClient = mongodb.MongoClient; | ||
|
||
let cachedDb: mongodb.Db | null = null; | ||
|
||
const connectToDatabase = async (): Promise<mongodb.Db> => { | ||
if (cachedDb) { | ||
return cachedDb; | ||
} | ||
|
||
const client = await MongoClient.connect(process.env.MONGODB_URI); | ||
cachedDb = await client.db("main"); | ||
|
||
return cachedDb; | ||
}; | ||
|
||
const db = await connectToDatabase(); | ||
|
||
export default db; | ||
// import * as mongodb from "mongodb"; | ||
// | ||
// const MongoClient = mongodb.MongoClient; | ||
// | ||
// let cachedDb: mongodb.Db | null = null; | ||
// | ||
// const connectToDatabase = async (): Promise<mongodb.Db> => { | ||
// if (cachedDb) { | ||
// return cachedDb; | ||
// } | ||
// | ||
// const client = await MongoClient.connect(process.env.MONGODB_URI); | ||
// cachedDb = await client.db("main"); | ||
// | ||
// return cachedDb; | ||
// }; | ||
// | ||
// const db = await connectToDatabase(); | ||
// | ||
// export default 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* tslint:disable *//* eslint-disable */import "sst" | ||
declare module "sst" { | ||
export interface Resource { | ||
Database: import("@cloudflare/workers-types").D1Database | ||
} | ||
} | ||
export {} |
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