trying with the store and such

This commit is contained in:
talksik
2022-03-17 20:13:49 -04:00
parent 453121c987
commit 34fe8e0c29
21 changed files with 478 additions and 35758 deletions
+26
View File
@@ -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}`
);
}