mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-29 20:03:42 +00:00
c630cbb4e3
acceptance tests to follow in a separate commit.
30 lines
669 B
JavaScript
30 lines
669 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.docHistory = internalDb.collection('docHistory')
|
|
db.docHistoryIndex = internalDb.collection('docHistoryIndex')
|
|
db.projectHistoryMetaData = internalDb.collection('projectHistoryMetaData')
|
|
}
|
|
|
|
module.exports = {
|
|
db,
|
|
ObjectId,
|
|
waitForDb
|
|
}
|