mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
28 lines
545 B
JavaScript
28 lines
545 B
JavaScript
const Settings = require('@overleaf/settings')
|
|
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.spellingPreferences = internalDb.collection('spellingPreferences')
|
|
}
|
|
|
|
module.exports = {
|
|
db,
|
|
ObjectId,
|
|
waitForDb,
|
|
}
|