From 0645bdd69e5d55455c95766db8e46d020d5743df Mon Sep 17 00:00:00 2001
From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com>
Date: Thu, 20 Apr 2023 13:35:40 -0400
Subject: [PATCH 1/3] amend migration guide
no longer support custom promise libraries
---
docs/migrating_to_7.md | 18 ++++++++++++++++++
lib/schema.js | 1 +
2 files changed, 19 insertions(+)
diff --git a/docs/migrating_to_7.md b/docs/migrating_to_7.md
index 35a8c07d33..b4c8c62ba4 100644
--- a/docs/migrating_to_7.md
+++ b/docs/migrating_to_7.md
@@ -19,6 +19,7 @@ If you're still on Mongoose 5.x, please read the [Mongoose 5.x to 6.x migration
* [Removed `castForQueryWrapper()`, updated `castForQuery()` signature](#removed-castforquerywrapper)
* [Copy schema options in `Schema.prototype.add()`](#copy-schema-options-in-schema-prototype-add)
* [ObjectId bsontype now has lowercase d](#objectid-bsontype-now-has-lowercase-d)
+* [No more support for custom promise libraries](#removed-custom-promise)
* [TypeScript-specific changes](#typescript-specific-changes)
* [Removed `LeanDocument` and support for `extends Document`](#removed-leandocument-and-support-for-extends-document)
* [New parameters for `HydratedDocument`](#new-parameters-for-hydrateddocument)
@@ -252,6 +253,23 @@ oid._bsontype; // 'ObjectId' in Mongoose 7, 'ObjectID' in older versions of Mong
Please update any places where you use `_bsontype` to check if an object is an ObjectId.
This may also affect libraries that use Mongoose.
+
+
+Mongoose 7 no longer includes support for custom promise libraries. So now the following does not work.
+
+```javascript
+const mongoose = require('mongoose');
+
+mongoose.Promise = require('bluebird');
+```
+
+However, should this change be a dealbreaker for you to upgrade,
+the following is a workaround.
+
+```javascript
+global.Promise = YourCustomPromise;
+```
+
diff --git a/lib/schema.js b/lib/schema.js
index 8a7a7150e6..beef002a37 100644
--- a/lib/schema.js
+++ b/lib/schema.js
@@ -94,6 +94,7 @@ let id = 0;
* @api public
*/
+
function Schema(obj, options) {
if (!(this instanceof Schema)) {
return new Schema(obj, options);
From d9c8bf420fc0b1de57aca938d94811165e8c3fb5 Mon Sep 17 00:00:00 2001
From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com>
Date: Thu, 20 Apr 2023 13:36:10 -0400
Subject: [PATCH 2/3] Update schema.js
---
lib/schema.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/schema.js b/lib/schema.js
index beef002a37..8a7a7150e6 100644
--- a/lib/schema.js
+++ b/lib/schema.js
@@ -94,7 +94,6 @@ let id = 0;
* @api public
*/
-
function Schema(obj, options) {
if (!(this instanceof Schema)) {
return new Schema(obj, options);
From 0fde1065f986a7d35447eb0f8bbaa3f7372c01d0 Mon Sep 17 00:00:00 2001
From: Valeri Karpov
Date: Thu, 20 Apr 2023 14:22:25 -0400
Subject: [PATCH 3/3] Update migrating_to_7.md
---
docs/migrating_to_7.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/migrating_to_7.md b/docs/migrating_to_7.md
index b4c8c62ba4..096e640037 100644
--- a/docs/migrating_to_7.md
+++ b/docs/migrating_to_7.md
@@ -19,7 +19,7 @@ If you're still on Mongoose 5.x, please read the [Mongoose 5.x to 6.x migration
* [Removed `castForQueryWrapper()`, updated `castForQuery()` signature](#removed-castforquerywrapper)
* [Copy schema options in `Schema.prototype.add()`](#copy-schema-options-in-schema-prototype-add)
* [ObjectId bsontype now has lowercase d](#objectid-bsontype-now-has-lowercase-d)
-* [No more support for custom promise libraries](#removed-custom-promise)
+* [Removed support for custom promise libraries](#removed-support-for-custom-promise-libraries)
* [TypeScript-specific changes](#typescript-specific-changes)
* [Removed `LeanDocument` and support for `extends Document`](#removed-leandocument-and-support-for-extends-document)
* [New parameters for `HydratedDocument`](#new-parameters-for-hydrateddocument)
@@ -253,21 +253,21 @@ oid._bsontype; // 'ObjectId' in Mongoose 7, 'ObjectID' in older versions of Mong
Please update any places where you use `_bsontype` to check if an object is an ObjectId.
This may also affect libraries that use Mongoose.
-
+
-Mongoose 7 no longer includes support for custom promise libraries. So now the following does not work.
+Mongoose 7 no longer supports plugging in custom promise libraries. So the following no longer makes Mongoose return Bluebird promises in Mongoose 7.
```javascript
const mongoose = require('mongoose');
+// No-op on Mongoose 7
mongoose.Promise = require('bluebird');
```
-However, should this change be a dealbreaker for you to upgrade,
-the following is a workaround.
+If you want to use Bluebird for all promises globally, you can do the following:
```javascript
-global.Promise = YourCustomPromise;
+global.Promise = require('bluebird');
```