trying with the store and such
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// External Dependencies
|
||||
import * as mongoDB from "mongodb";
|
||||
// import * as dotenv from "dotenv";
|
||||
|
||||
// Global Variables
|
||||
|
||||
export const collections: { users?: mongoDB.Collection } = {};
|
||||
|
||||
// Initialize Connection
|
||||
export async function connectToDatabase() {
|
||||
const client: mongoDB.MongoClient = new mongoDB.MongoClient(
|
||||
process.env.DB_CONN_STRING!
|
||||
);
|
||||
|
||||
await client.connect();
|
||||
|
||||
const db: mongoDB.Db = client.db(process.env.DB_NAME);
|
||||
|
||||
const usersCollection: mongoDB.Collection = db.collection("users");
|
||||
|
||||
collections.users = usersCollection;
|
||||
|
||||
console.log(
|
||||
`Successfully connected to database: ${db.databaseName} and collection: ${usersCollection.collectionName}`
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user