overleaf/services/docstore/app/js/mongodb.js
Jakob Ackermann df0747ec48 [misc] migrate the app to the native mongo driver
acceptance tests to follow in a separate commit
2020-08-25 09:40:59 +01:00

19 lines
427 B
JavaScript

const Settings = require('settings-sharelatex')
const { MongoClient, ObjectId } = require('mongodb')
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 = {
ObjectId,
getCollection,
waitForDb
}