mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[misc] mongodb: drop the getCollection helper
This commit is contained in:
@@ -3,23 +3,20 @@ const { MongoClient, ObjectId } = require('mongodb')
|
||||
|
||||
const clientPromise = MongoClient.connect(Settings.mongo.url)
|
||||
|
||||
async function getCollection(name) {
|
||||
return (await clientPromise).db().collection(name)
|
||||
}
|
||||
|
||||
async function waitForDb() {
|
||||
await clientPromise
|
||||
}
|
||||
|
||||
const db = {}
|
||||
waitForDb().then(async function () {
|
||||
db.messages = await getCollection('messages')
|
||||
db.rooms = await getCollection('rooms')
|
||||
const internalDb = (await clientPromise).db()
|
||||
|
||||
db.messages = internalDb.collection('messages')
|
||||
db.rooms = internalDb.collection('rooms')
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
db,
|
||||
ObjectId,
|
||||
getCollection,
|
||||
waitForDb
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user