mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 13:49:00 +02:00
[misc] mongodb: refactor the process of setting up the db construct
Co-Authored-By: John Lees-Miller <jdleesmiller@gmail.com>
This commit is contained in:
@@ -11,16 +11,20 @@ async function healthCheck() {
|
||||
}
|
||||
}
|
||||
|
||||
let setupDbPromise
|
||||
async function waitForDb() {
|
||||
await clientPromise
|
||||
if (!setupDbPromise) {
|
||||
setupDbPromise = setupDb()
|
||||
}
|
||||
await setupDbPromise
|
||||
}
|
||||
|
||||
const db = {}
|
||||
waitForDb().then(async function () {
|
||||
async function setupDb() {
|
||||
const internalDb = (await clientPromise).db()
|
||||
|
||||
db.docSnapshots = internalDb.collection('docSnapshots')
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
db,
|
||||
|
||||
Reference in New Issue
Block a user