mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 16:21:35 -05:00
3626243692
mongojs was enabling it by default as well.
28 lines
533 B
JavaScript
28 lines
533 B
JavaScript
const Settings = require('settings-sharelatex')
|
|
const { MongoClient, ObjectId } = require('mongodb')
|
|
|
|
const clientPromise = MongoClient.connect(
|
|
Settings.mongo.url,
|
|
Settings.mongo.options
|
|
)
|
|
|
|
let setupDbPromise
|
|
async function waitForDb() {
|
|
if (!setupDbPromise) {
|
|
setupDbPromise = setupDb()
|
|
}
|
|
await setupDbPromise
|
|
}
|
|
|
|
const db = {}
|
|
async function setupDb() {
|
|
const internalDb = (await clientPromise).db()
|
|
|
|
db.notifications = internalDb.collection('notifications')
|
|
}
|
|
|
|
module.exports = {
|
|
db,
|
|
ObjectId,
|
|
waitForDb
|
|
}
|