Skip to content

Commit

Permalink
chore: update mongoose
Browse files Browse the repository at this point in the history
  • Loading branch information
meabed committed Nov 2, 2023
1 parent ecdfc81 commit aff45d1
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/__mocks__/mongooseCommon.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable no-param-reassign, no-console */

import mongoose, { version } from 'mongoose';
import mongoose from 'mongoose';
import MongoMemoryServer from 'mongodb-memory-server-core';

const versionNumber = Number(version.charAt(0));

const { Schema, Types } = mongoose;

mongoose.Promise = Promise;
Expand All @@ -14,17 +12,7 @@ mongoose.createConnection = (async () => {
const mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();

// originalConnect.bind(mongoose)(mongoUri, { useMongoClient: true }); // mongoose 4
originalConnect.bind(mongoose)(
mongoUri,
versionNumber > 7
? {}
: ({
useNewUrlParser: true,
useUnifiedTopology: true,
} as any) /* for tests compatibility with mongoose v5 & v6 */
); // mongoose 5
// originalConnect.bind(mongoose)(mongoUri, {}); // mongoose 6
originalConnect.bind(mongoose)(mongoUri, {});

mongoose.connection.on('error', (e) => {
if (e.message.code === 'ETIMEDOUT') {
Expand Down

0 comments on commit aff45d1

Please sign in to comment.