fixing things regarding bson error with node and such...now working?
This commit is contained in:
@@ -6,25 +6,34 @@ import { loadConfig } from "../config";
|
||||
// Global Variables
|
||||
export const collections: {
|
||||
users?: mongoDB.Collection;
|
||||
conversations?: mongoDB.Collection;
|
||||
conversationMembers?: mongoDB.Collection;
|
||||
audioClips?: mongoDB.Collection;
|
||||
} = {};
|
||||
|
||||
// Initialize Connection
|
||||
export async function connectToDatabase() {
|
||||
const config = loadConfig();
|
||||
const config = loadConfig();
|
||||
|
||||
const client: mongoDB.MongoClient = new mongoDB.MongoClient(
|
||||
config.MONGO_CONNECTION_STRING
|
||||
);
|
||||
export const client: mongoDB.MongoClient = new mongoDB.MongoClient(
|
||||
config.MONGO_CONNECTION_STRING
|
||||
);
|
||||
|
||||
await client.connect();
|
||||
client.connect();
|
||||
|
||||
const db: mongoDB.Db = client.db(process.env.DB_NAME);
|
||||
const db: mongoDB.Db = client.db(process.env.DB_NAME);
|
||||
|
||||
const usersCollection: mongoDB.Collection = db.collection("users");
|
||||
const usersCollection: mongoDB.Collection = db.collection("users");
|
||||
const convoCollection: mongoDB.Collection = db.collection("conversations");
|
||||
const convoMembersCollection: mongoDB.Collection = db.collection(
|
||||
"conversationMembers"
|
||||
);
|
||||
const audioClipsCollection: mongoDB.Collection = db.collection("audioClips");
|
||||
|
||||
collections.users = usersCollection;
|
||||
collections.users = usersCollection;
|
||||
collections.conversations = convoCollection;
|
||||
collections.conversationMembers = convoMembersCollection;
|
||||
collections.audioClips = audioClipsCollection;
|
||||
|
||||
console.log(
|
||||
`Successfully connected to database: ${db.databaseName} and collections`
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
`Successfully connected to database: ${db.databaseName} and collections`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user