overleaf/services/chat/app/js/mongodb.js

20 lines
427 B
JavaScript
Raw Normal View History

2020-08-19 08:00:01 -04:00
const Settings = require('settings-sharelatex')
const { MongoClient, ObjectId } = require('mongodb')
const clientPromise = MongoClient.connect(Settings.mongo.url)
const dbPromise = clientPromise.then((client) => client.db())
2020-08-19 08:00:01 -04:00
async function getCollection(name) {
return (await dbPromise).collection(name)
}
async function waitForDb() {
await clientPromise
}
2020-08-19 08:00:01 -04:00
module.exports = {
ObjectId,
getCollection,
waitForDb
2020-08-19 08:00:01 -04:00
}