cleaning up api and adding in conversation create route
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import Conversation from '@nirvana/core/models/conversation.model';
|
||||
import { collections } from './database.service';
|
||||
|
||||
export default class ConversationService {
|
||||
static async createConversation(newConversation: Conversation) {
|
||||
return await collections.conversations?.insertOne(newConversation);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import environmentVariables from '../config/config';
|
||||
// Global Variables
|
||||
export const collections: {
|
||||
users?: mongoDB.Collection;
|
||||
conversations?: mongoDB.Collection;
|
||||
} = {};
|
||||
|
||||
// Initialize Connection
|
||||
@@ -19,6 +20,7 @@ client.connect();
|
||||
const db: mongoDB.Db = client.db(process.env.DB_NAME);
|
||||
|
||||
const usersCollection: mongoDB.Collection = db.collection('users');
|
||||
const conversationsCollection: mongoDB.Collection = db.collection('conversations');
|
||||
|
||||
// client.on('connection', () => {
|
||||
// db.command({
|
||||
@@ -27,5 +29,6 @@ const usersCollection: mongoDB.Collection = db.collection('users');
|
||||
// });
|
||||
|
||||
collections.users = usersCollection;
|
||||
collections.conversations = conversationsCollection;
|
||||
|
||||
console.log(`Successfully connected to database: ${db.databaseName} and collections`);
|
||||
|
||||
Reference in New Issue
Block a user