From 0cf5cad3b8c52ed642f0902d08eac5c3c5504141 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 28 Aug 2020 09:26:06 +0100 Subject: [PATCH] [misc] mongodb: drop the getCollection helper --- services/chat/app/js/mongodb.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/services/chat/app/js/mongodb.js b/services/chat/app/js/mongodb.js index 928a3222d1..432c39fb03 100644 --- a/services/chat/app/js/mongodb.js +++ b/services/chat/app/js/mongodb.js @@ -3,23 +3,20 @@ const { MongoClient, ObjectId } = require('mongodb') const clientPromise = MongoClient.connect(Settings.mongo.url) -async function getCollection(name) { - return (await clientPromise).db().collection(name) -} - async function waitForDb() { await clientPromise } const db = {} waitForDb().then(async function () { - db.messages = await getCollection('messages') - db.rooms = await getCollection('rooms') + const internalDb = (await clientPromise).db() + + db.messages = internalDb.collection('messages') + db.rooms = internalDb.collection('rooms') }) module.exports = { db, ObjectId, - getCollection, waitForDb }