mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05: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:
parent
1d57706d44
commit
c337cf1c4f
1 changed files with 7 additions and 3 deletions
|
@ -11,16 +11,20 @@ async function healthCheck() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let setupDbPromise
|
||||||
async function waitForDb() {
|
async function waitForDb() {
|
||||||
await clientPromise
|
if (!setupDbPromise) {
|
||||||
|
setupDbPromise = setupDb()
|
||||||
|
}
|
||||||
|
await setupDbPromise
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = {}
|
const db = {}
|
||||||
waitForDb().then(async function () {
|
async function setupDb() {
|
||||||
const internalDb = (await clientPromise).db()
|
const internalDb = (await clientPromise).db()
|
||||||
|
|
||||||
db.docSnapshots = internalDb.collection('docSnapshots')
|
db.docSnapshots = internalDb.collection('docSnapshots')
|
||||||
})
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
db,
|
db,
|
||||||
|
|
Loading…
Reference in a new issue