diff --git a/services/web/app/src/infrastructure/mongodb.js b/services/web/app/src/infrastructure/mongodb.js index 1a9051d77e..8a3c54f5d4 100644 --- a/services/web/app/src/infrastructure/mongodb.js +++ b/services/web/app/src/infrastructure/mongodb.js @@ -70,9 +70,23 @@ async function setupDb() { db.users = internalDb.collection('users') db.userstubs = internalDb.collection('userstubs') } +async function addCollection(name) { + await waitForDb() + const internalDb = (await clientPromise).db() + + db[name] = internalDb.collection(name) +} +async function getCollectionNames() { + const internalDb = (await clientPromise).db() + + const collections = await internalDb.collections() + return collections.map(collection => collection.collectionName) +} module.exports = { db, ObjectId, + addCollection, + getCollectionNames, waitForDb }