Co-Authored-By: Eric Mc Sween <eric.mcsween@overleaf.com> Co-Authored-By: Miguel Serrano <mserranom@gmail.com> Co-Authored-By: Simon Detheridge <s@sd.ai>
20 lines
427 B
JavaScript
20 lines
427 B
JavaScript
const Settings = require('settings-sharelatex')
|
|
const { MongoClient, ObjectId } = require('mongodb')
|
|
|
|
const clientPromise = MongoClient.connect(Settings.mongo.url)
|
|
const dbPromise = clientPromise.then((client) => client.db())
|
|
|
|
async function getCollection(name) {
|
|
return (await dbPromise).collection(name)
|
|
}
|
|
|
|
async function waitForDb() {
|
|
await clientPromise
|
|
}
|
|
|
|
module.exports = {
|
|
ObjectId,
|
|
getCollection,
|
|
waitForDb
|
|
}
|