mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #17004 from overleaf/bg-mongoose-mongo-compatibility
Ensure Mongoose and mongodb modules use the same mongodb instance GitOrigin-RevId: fb55f3dfcff73919a4c5d26a354ba7c55b1e63c1
This commit is contained in:
@@ -1,7 +1,20 @@
|
|||||||
const { ObjectId, ReadPreference } = require('mongodb')
|
const mongodb = require('mongodb')
|
||||||
const OError = require('@overleaf/o-error')
|
const OError = require('@overleaf/o-error')
|
||||||
const Settings = require('@overleaf/settings')
|
const Settings = require('@overleaf/settings')
|
||||||
const { getNativeDb } = require('./Mongoose')
|
const Mongoose = require('./Mongoose')
|
||||||
|
|
||||||
|
// Ensure Mongoose is using the same mongodb instance as the mongodb module,
|
||||||
|
// otherwise we will get multiple versions of the ObjectId class. Mongoose
|
||||||
|
// patches ObjectId, so loading multiple versions of the mongodb module can
|
||||||
|
// cause problems with ObjectId comparisons.
|
||||||
|
if (Mongoose.mongo !== mongodb) {
|
||||||
|
throw new OError(
|
||||||
|
'FATAL ERROR: Mongoose is using a different mongodb instance'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const { getNativeDb } = Mongoose
|
||||||
|
const { ObjectId, ReadPreference } = mongodb
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof global.beforeEach === 'function' &&
|
typeof global.beforeEach === 'function' &&
|
||||||
|
|||||||
Reference in New Issue
Block a user