Merge pull request #21442 from overleaf/jpa-align-mongo-version

[misc] align all the mongodb dependency versions

GitOrigin-RevId: 1194fe57601af98bb61250a285bfc85b4b8179dd
This commit is contained in:
Jakob Ackermann
2024-10-31 13:19:53 +01:00
committed by Copybot
parent f9300a4595
commit fa95775a5c
16 changed files with 511 additions and 1440 deletions

View File

@@ -3,30 +3,29 @@ const {
connectionPromise,
db,
} = require('../../../app/src/infrastructure/mongodb')
const { getMongoClient } = require('../../../app/src/infrastructure/Mongoose')
const MIN_MONGO_VERSION = [5, 0]
async function main() {
let mongoClient
try {
await connectionPromise
mongoClient = await connectionPromise
} catch (err) {
console.error('Cannot connect to mongodb')
throw err
}
await checkMongoVersion()
await checkMongoVersion(mongoClient)
try {
await testTransactions()
await testTransactions(mongoClient)
} catch (err) {
console.error("Mongo instance doesn't support transactions")
throw err
}
}
async function testTransactions() {
const mongoClient = await getMongoClient()
async function testTransactions(mongoClient) {
const session = mongoClient.startSession()
try {
await session.withTransaction(async () => {
@@ -37,8 +36,7 @@ async function testTransactions() {
}
}
async function checkMongoVersion() {
const mongoClient = await getMongoClient()
async function checkMongoVersion(mongoClient) {
const buildInfo = await mongoClient.db().admin().buildInfo()
const [major, minor] = buildInfo.versionArray
const [minMajor, minMinor] = MIN_MONGO_VERSION