[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:
committed by
Simon Detheridge
co-authored by
Eric Mc Sween
Simon Detheridge
parent
1e7fa2246d
commit
54a82b8c62
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user