Merge pull request #3200 from overleaf/jpa-mongodb-native-migrations

[misc] migrate the migrations to the latest native mongo driver

GitOrigin-RevId: eedfa71571910adf7cc205a1f69e27492fe80883
This commit is contained in:
Jakob Ackermann 2020-10-07 15:17:10 +02:00 committed by Copybot
parent a096d98956
commit 370ee79a30

View file

@ -70,9 +70,23 @@ async function setupDb() {
db.users = internalDb.collection('users')
db.userstubs = internalDb.collection('userstubs')
}
async function addCollection(name) {
await waitForDb()
const internalDb = (await clientPromise).db()
db[name] = internalDb.collection(name)
}
async function getCollectionNames() {
const internalDb = (await clientPromise).db()
const collections = await internalDb.collections()
return collections.map(collection => collection.collectionName)
}
module.exports = {
db,
ObjectId,
addCollection,
getCollectionNames,
waitForDb
}