Skip to content

Commit 9b1ff1f

Browse files
committed
chore: release 7.0.0
1 parent 73cea77 commit 9b1ff1f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
7.0.0 / 2023-02-27
2+
==================
3+
* BREAKING CHANGE: copy schema options when merging schemas using new Schema() or Schema.prototype.add() #13092
4+
* feat(types): export mongodb types more robustly #12948 [simon-abbott](https://github.com/simon-abbott)
5+
* docs: fix populate docs #13090 [hasezoey](https://github.com/hasezoey)
6+
* docs(migrating_to_6): added info about removal of reconnectTries and reconnectInterval options #13083 [lpizzinidev](https://github.com/lpizzinidev)
7+
18
7.0.0-rc0 / 2023-02-23
29
======================
310
* BREAKING CHANGE: remove support for callbacks #11431

docs/migrating_to_7.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ If you're still on Mongoose 5.x, please read the [Mongoose 5.x to 6.x migration
1717
* [Removed `update()`](#removed-update)
1818
* [Discriminator schemas use base schema options by default](#discriminator-schemas-use-base-schema-options-by-default)
1919
* [Removed `castForQueryWrapper()`, updated `castForQuery()` signature](#removed-castforquerywrapper)
20+
* [Copy schema options in `Schema.prototype.add()`](#copy-schema-options-in-schema-prototype-add)
2021
* [ObjectId bsontype now has lowercase d](#objectid-bsontype-now-has-lowercase-d)
2122
* [TypeScript-specific changes](#typescript-specific-changes)
2223
* [Removed `LeanDocument` and support for `extends Document`](#removed-leandocument-and-support-for-extends-document)
@@ -217,6 +218,26 @@ MySchemaType.prototype.castForQuery = function($conditional, value, context) {
217218
};
218219
```
219220

221+
<h3 id="copy-schema-options-in-schema-prototype-add"><a href="#copy-schema-options-in-schema-prototype-add">Copy Schema options in <code>Schema.prototype.add()</code></a></h3>
222+
223+
Mongoose now copies user defined schema options when adding one schema to another.
224+
For example, `childSchema` below will get `baseSchema`'s `id` and `toJSON` options.
225+
226+
```javascript
227+
const baseSchema = new Schema({ created: Date }, { id: true, toJSON: { virtuals: true } });
228+
const childSchema = new Schema([baseSchema, { name: String }]);
229+
230+
childSchema.options.toJSON; // { virtuals: true } in Mongoose 7. undefined in Mongoose 6.
231+
```
232+
233+
This applies both when creating a new schema using an array of schemas, as well as when calling `add()` as follows.
234+
235+
```javascript
236+
childSchema.add(new Schema({}, { toObject: { virtuals: true } }));
237+
238+
childSchema.options.toObject; // { virtuals: true } in Mongoose 7. undefined in Mongoose 6.
239+
```
240+
220241
<h3 id="objectid-bsontype-now-has-lowercase-d"><a href="#objectid-bsontype-now-has-lowercase-d">ObjectId bsontype now has lowercase d</a></h3>
221242

222243
The internal `_bsontype` property on ObjectIds is equal to `'ObjectId'` in Mongoose 7, as opposed to `'ObjectID'` in Mongoose 6.

0 commit comments

Comments
 (0)