|
|
@@ -1,15 +1,19 @@
|
|
|
const Settings = require('settings-sharelatex')
|
|
|
const { MongoClient, ObjectId } = require('mongodb')
|
|
|
|
|
|
-const clientConnecting = MongoClient.connect(Settings.mongo.url)
|
|
|
-const dbPromise = clientConnecting.then((client) => client.db())
|
|
|
+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 = {
|
|
|
- clientConnecting,
|
|
|
ObjectId,
|
|
|
- getCollection
|
|
|
+ getCollection,
|
|
|
+ waitForDb
|
|
|
}
|