overleaf/services/spelling/app/js/mongodb.js
Jakob Ackermann baaf376128 [misc] mongodb: use the new db connector by default
mongojs was enabling it by default as well.
2020-09-10 10:57:29 +01:00

28 lines
545 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.spellingPreferences = internalDb.collection('spellingPreferences')
}
module.exports = {
db,
ObjectId,
waitForDb
}