[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-07 09:44:19 +01:00 committed by Simon Detheridge
parent 1e7fa2246d
commit 54a82b8c62

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
}