mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #10753 from overleaf/em-upgrade-mongo-driver
Upgrade the Mongo driver in the chat service GitOrigin-RevId: 12808e624b75f0adc7fd474f774b855dc2eadefd
This commit is contained in:
@@ -1,29 +1,16 @@
|
||||
const Settings = require('@overleaf/settings')
|
||||
const { MongoClient, ObjectId } = require('mongodb')
|
||||
|
||||
const clientPromise = MongoClient.connect(
|
||||
Settings.mongo.url,
|
||||
Settings.mongo.options
|
||||
)
|
||||
const client = new MongoClient(Settings.mongo.url)
|
||||
const db = client.db()
|
||||
|
||||
let setupDbPromise
|
||||
async function waitForDb() {
|
||||
if (!setupDbPromise) {
|
||||
setupDbPromise = setupDb()
|
||||
}
|
||||
await setupDbPromise
|
||||
}
|
||||
|
||||
const db = {}
|
||||
async function setupDb() {
|
||||
const internalDb = (await clientPromise).db()
|
||||
|
||||
db.messages = internalDb.collection('messages')
|
||||
db.rooms = internalDb.collection('rooms')
|
||||
const collections = {
|
||||
messages: db.collection('messages'),
|
||||
rooms: db.collection('rooms'),
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
db,
|
||||
db: collections,
|
||||
mongoClient: client,
|
||||
ObjectId,
|
||||
waitForDb,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user