overleaf/services/chat/app/js/mongodb.js
Jakob Ackermann 39ea30355e [misc] simplify the naming around waiting for a mongo connection
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>
2020-08-24 17:41:03 +01:00

19 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
}