mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[misc] mongodb: drop the getCollection helper
This commit is contained in:
parent
4080784310
commit
0cf5cad3b8
1 changed files with 4 additions and 7 deletions
|
@ -3,23 +3,20 @@ const { MongoClient, ObjectId } = require('mongodb')
|
||||||
|
|
||||||
const clientPromise = MongoClient.connect(Settings.mongo.url)
|
const clientPromise = MongoClient.connect(Settings.mongo.url)
|
||||||
|
|
||||||
async function getCollection(name) {
|
|
||||||
return (await clientPromise).db().collection(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function waitForDb() {
|
async function waitForDb() {
|
||||||
await clientPromise
|
await clientPromise
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = {}
|
const db = {}
|
||||||
waitForDb().then(async function () {
|
waitForDb().then(async function () {
|
||||||
db.messages = await getCollection('messages')
|
const internalDb = (await clientPromise).db()
|
||||||
db.rooms = await getCollection('rooms')
|
|
||||||
|
db.messages = internalDb.collection('messages')
|
||||||
|
db.rooms = internalDb.collection('rooms')
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
db,
|
db,
|
||||||
ObjectId,
|
ObjectId,
|
||||||
getCollection,
|
|
||||||
waitForDb
|
waitForDb
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue