mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 10:10:08 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user