[misc] mongodb: export a helper for adding new collections to db

Co-Authored-By: Eric Mc Sween <eric.mcsween@overleaf.com>
Co-Authored-By: Simon Detheridge <s@sd.ai>
This commit is contained in:
Jakob Ackermann
2020-09-17 15:39:46 +01:00
committed by Simon Detheridge
co-authored by Eric Mc Sween Simon Detheridge
parent 1e7fa2246d
commit 54a82b8c62
+7
View File
@@ -18,9 +18,16 @@ async function setupDb() {
db.docs = internalDb.collection('docs')
db.docOps = internalDb.collection('docOps')
}
async function addCollection(name) {
await waitForDb()
const internalDb = (await clientPromise).db()
db[name] = internalDb.collection(name)
}
module.exports = {
db,
ObjectId,
addCollection,
waitForDb
}