From 003246f62a324c733eb4dd4614d883ce6f7ec027 Mon Sep 17 00:00:00 2001
From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com>
Date: Fri, 20 Sep 2024 16:45:36 -0400
Subject: [PATCH 1/9] Update migrating_to_6.md
---
docs/migrating_to_6.md | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md
index 2aa3a3a8bd4..35973574536 100644
--- a/docs/migrating_to_6.md
+++ b/docs/migrating_to_6.md
@@ -52,6 +52,7 @@ If you're still on Mongoose 4.x, please read the [Mongoose 4.x to 5.x migration
* [`toObject()` and `toJSON()` Use Nested Schema `minimize`](#toobject-and-tojson-use-nested-schema-minimize)
* [TypeScript changes](#typescript-changes)
* [Removed `reconnectTries` and `reconnectInterval` options](#removed-reconnecttries-and-reconnectinterval-options)
+* [Lodash `.isEmpty()` returns false for ObjectIds](#lodash-object-id)
@@ -541,3 +542,19 @@ The `reconnectTries` and `reconnectInterval` options have been removed since the
The MongoDB node driver will always attempt to retry any operation for up to `serverSelectionTimeoutMS`, even if MongoDB is down for a long period of time.
So, it will never run out of retries or try to reconnect to MongoDB.
+
+
+
+
+Lodash's `isEmpty()` function returns true for primitives and primitive wrappers. `ObjectId()` is an object wrapper that is treated as a primitive by Mongoose.
+As a result, `isEmpty()` will return `true` for `ObjectId()`.
+
+An ObjectId in mongoose is never empty, so if using lodash here is a workaround when dealing with ObjectIds:
+
+```javascript
+if (!(a instanceof Types.ObjectId) && (_.isEmpty(a) || !Types.ObjectId.isValid(a))) {
+ throw new Error('Error.');
+}
+```
+
+
From f45e28cf1e547209ee27479867425df47adb6dae Mon Sep 17 00:00:00 2001
From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com>
Date: Fri, 20 Sep 2024 16:46:41 -0400
Subject: [PATCH 2/9] formatting
---
docs/migrating_to_6.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md
index 35973574536..8c3dc2ec9f9 100644
--- a/docs/migrating_to_6.md
+++ b/docs/migrating_to_6.md
@@ -553,7 +553,7 @@ An ObjectId in mongoose is never empty, so if using lodash here is a workaround
```javascript
if (!(a instanceof Types.ObjectId) && (_.isEmpty(a) || !Types.ObjectId.isValid(a))) {
- throw new Error('Error.');
+ throw new Error('Error.');
}
```
From f86bda75ff0c67411a600dfe9485ffc8b2210ca4 Mon Sep 17 00:00:00 2001
From: Valeri Karpov
Date: Mon, 23 Sep 2024 12:19:28 -0400
Subject: [PATCH 3/9] quick clarification
---
docs/migrating_to_6.md | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md
index 8c3dc2ec9f9..69945f4eb01 100644
--- a/docs/migrating_to_6.md
+++ b/docs/migrating_to_6.md
@@ -546,14 +546,15 @@ So, it will never run out of retries or try to reconnect to MongoDB.
-Lodash's `isEmpty()` function returns true for primitives and primitive wrappers. `ObjectId()` is an object wrapper that is treated as a primitive by Mongoose.
-As a result, `isEmpty()` will return `true` for `ObjectId()`.
+Lodash's `isEmpty()` function returns true for primitives and primitive wrappers.
+`ObjectId()` is an object wrapper that is treated as a primitive by Mongoose.
+But starting in Mongoose 6, `_.isEmpty()` will return true for ObjectIds because of Lodash implementation details.
-An ObjectId in mongoose is never empty, so if using lodash here is a workaround when dealing with ObjectIds:
+An ObjectId in mongoose is never empty, so if you're using `isEmpty()` you should check for `instanceof ObjectId`.
```javascript
-if (!(a instanceof Types.ObjectId) && (_.isEmpty(a) || !Types.ObjectId.isValid(a))) {
- throw new Error('Error.');
+if (!(val instanceof Types.ObjectId) && _.isEmpty(val)) {
+ // Handle empty object here
}
```
From 25da2cac60f7d286d94d1402fc07b46e259e2ad5 Mon Sep 17 00:00:00 2001
From: Valeri Karpov
Date: Mon, 23 Sep 2024 16:38:37 -0400
Subject: [PATCH 4/9] chore: release 6.13.3
---
CHANGELOG.md | 4 ++++
package.json | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f6cc66bffe..7fdcff087dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+6.13.3 / 2024-09-23
+===================
+ * docs(migrating_to_6): document that Lodash _.isEmpty() with ObjectId() as a parameter returns true in Mongoose 6 #11152
+
6.13.2 / 2024-09-12
===================
* fix(document): make set() respect merge option on deeply nested objects #14870 #14878
diff --git a/package.json b/package.json
index 476d7371620..5e3f56c8bdb 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
- "version": "6.13.2",
+ "version": "6.13.3",
"author": "Guillermo Rauch ",
"keywords": [
"mongodb",
From fd2081c06da60644d927002f65b89c507d802c1a Mon Sep 17 00:00:00 2001
From: Mark Stosberg
Date: Mon, 30 Sep 2024 14:19:06 -0400
Subject: [PATCH 5/9] Update migrating_to_6.md about mongoose.modelSchemas
It was removed by this commit that first appeared in the 6.x series:
6865fea216220a88d2e7128d3a8eb8228f29155e
---
docs/migrating_to_6.md | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md
index 69945f4eb01..f92ac92957c 100644
--- a/docs/migrating_to_6.md
+++ b/docs/migrating_to_6.md
@@ -53,6 +53,7 @@ If you're still on Mongoose 4.x, please read the [Mongoose 4.x to 5.x migration
* [TypeScript changes](#typescript-changes)
* [Removed `reconnectTries` and `reconnectInterval` options](#removed-reconnecttries-and-reconnectinterval-options)
* [Lodash `.isEmpty()` returns false for ObjectIds](#lodash-object-id)
+* [mongoose.modelSchemas removed](#model-schemas)
@@ -557,5 +558,16 @@ if (!(val instanceof Types.ObjectId) && _.isEmpty(val)) {
// Handle empty object here
}
```
+
+
+The `mongoose.modelSchemas` property was removed. This may have been used to delete a model schema.
+
+```javascript
+// before
+delete mongoose.modelSchemas.User;
+
+// with Mongoose 6.x
+delete mongoose.deleteModel('User');
+```
From d98b2e7796d6d72ccf21f70d79f3e46d3b14a22f Mon Sep 17 00:00:00 2001
From: Mark Stosberg
Date: Wed, 30 Oct 2024 10:11:12 -0400
Subject: [PATCH 6/9] docs: Add missing closing tag for Lodash entry.
---
docs/migrating_to_6.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md
index 69945f4eb01..5f949f1366a 100644
--- a/docs/migrating_to_6.md
+++ b/docs/migrating_to_6.md
@@ -544,7 +544,7 @@ The MongoDB node driver will always attempt to retry any operation for up to `se
So, it will never run out of retries or try to reconnect to MongoDB.
-
+
Lodash's `isEmpty()` function returns true for primitives and primitive wrappers.
`ObjectId()` is an object wrapper that is treated as a primitive by Mongoose.
From 3e3dc2e140dd72de5a7b26d70577df0ea018b22a Mon Sep 17 00:00:00 2001
From: Mark Stosberg
Date: Wed, 30 Oct 2024 10:18:40 -0400
Subject: [PATCH 7/9] docs: clarify strictQuery default will flip-flop in
"Migrating to 6.x"
Save upgrading users the headache of `strictQuery:true` problems by
highlighting that the default is going to change back in Mongoose 7,
so they may wish to skip this default behavior change.
---
docs/migrating_to_6.md | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/docs/migrating_to_6.md b/docs/migrating_to_6.md
index 5f949f1366a..2de092f66be 100644
--- a/docs/migrating_to_6.md
+++ b/docs/migrating_to_6.md
@@ -144,9 +144,16 @@ if (existingUser) {
~Mongoose no longer supports a `strictQuery` option. You must now use `strict`.~
-As of Mongoose 6.0.10, we brought back the `strictQuery` option.
-However, `strictQuery` is tied to `strict` by default.
-This means that, by default, Mongoose will filter out query filter properties that are not in the schema.
+As of Mongoose 6.0.10, we brought back the `strictQuery` option. In Mongoose 6, `strictQuery` is set to `strict` by default. This means that, by default, Mongoose will filter out query filter properties that are not in the schema.
+
+However, this behavior was a source of confusion in some cases, so in Mongoose 7, this default changes back to `false`. So if you want to retain the default behavior of Mongoose 5 as well as Mongoose 7 and later, you can also disable `strictQuery` globally to override:
+
+```javascript
+mongoose.set('strictQuery', false);
+```
+In a test suite, it may be useful to set `strictQuery` to `throw`, which will throw exceptions any time a query references schema that doesn't exist, which could help identify a bug in your tests or code.
+
+Here's an example of the effect of `strictQuery`:
```javascript
const userSchema = new Schema({ name: String });
From 68377ff4e3c80f9fb261c651cc4b7f49944436ae Mon Sep 17 00:00:00 2001
From: Valeri Karpov
Date: Fri, 15 Nov 2024 10:15:07 -0500
Subject: [PATCH 8/9] fix: save execution stack in query as string
Backport #15039 to 6.x
---
lib/helpers/query/wrapThunk.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/helpers/query/wrapThunk.js b/lib/helpers/query/wrapThunk.js
index 1303a4708d6..cf5506b1681 100644
--- a/lib/helpers/query/wrapThunk.js
+++ b/lib/helpers/query/wrapThunk.js
@@ -21,10 +21,10 @@ module.exports = function wrapThunk(fn) {
str = str.slice(0, 60) + '...';
}
const err = new MongooseError('Query was already executed: ' + str);
- err.originalStack = this._executionStack.stack;
+ err.originalStack = this._executionStack;
return cb(err);
}
- this._executionStack = new Error();
+ this._executionStack = new Error().stack;
fn.call(this, cb);
};
From 22210b12edf6180fa4f0958ac3d2cd4f4c020793 Mon Sep 17 00:00:00 2001
From: Valeri Karpov
Date: Fri, 15 Nov 2024 14:23:40 -0500
Subject: [PATCH 9/9] chore: release 6.13.4
---
CHANGELOG.md | 5 +++++
package.json | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fdcff087dc..828b238c473 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+6.13.4 / 2024-11-15
+===================
+ * fix: save execution stack in query as string #15043 #15039
+ * docs: clarify strictQuery default will flip-flop in "Migrating to 6.x" #14998 [markstos](https://github.com/markstos)
+
6.13.3 / 2024-09-23
===================
* docs(migrating_to_6): document that Lodash _.isEmpty() with ObjectId() as a parameter returns true in Mongoose 6 #11152
diff --git a/package.json b/package.json
index 5e3f56c8bdb..93b9132f48b 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
- "version": "6.13.3",
+ "version": "6.13.4",
"author": "Guillermo Rauch ",
"keywords": [
"mongodb",