Skip to content

Commit

Permalink
chore: release 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Feb 27, 2023
1 parent 73cea77 commit 9b1ff1f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
7.0.0 / 2023-02-27
==================
* BREAKING CHANGE: copy schema options when merging schemas using new Schema() or Schema.prototype.add() #13092
* feat(types): export mongodb types more robustly #12948 [simon-abbott](https://github.com/simon-abbott)
* docs: fix populate docs #13090 [hasezoey](https://github.com/hasezoey)
* docs(migrating_to_6): added info about removal of reconnectTries and reconnectInterval options #13083 [lpizzinidev](https://github.com/lpizzinidev)

7.0.0-rc0 / 2023-02-23
======================
* BREAKING CHANGE: remove support for callbacks #11431
Expand Down
21 changes: 21 additions & 0 deletions docs/migrating_to_7.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ If you're still on Mongoose 5.x, please read the [Mongoose 5.x to 6.x migration
* [Removed `update()`](#removed-update)
* [Discriminator schemas use base schema options by default](#discriminator-schemas-use-base-schema-options-by-default)
* [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)
* [TypeScript-specific changes](#typescript-specific-changes)
* [Removed `LeanDocument` and support for `extends Document`](#removed-leandocument-and-support-for-extends-document)
Expand Down Expand Up @@ -217,6 +218,26 @@ MySchemaType.prototype.castForQuery = function($conditional, value, context) {
};
```

<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>

Mongoose now copies user defined schema options when adding one schema to another.
For example, `childSchema` below will get `baseSchema`'s `id` and `toJSON` options.

```javascript
const baseSchema = new Schema({ created: Date }, { id: true, toJSON: { virtuals: true } });
const childSchema = new Schema([baseSchema, { name: String }]);

childSchema.options.toJSON; // { virtuals: true } in Mongoose 7. undefined in Mongoose 6.
```

This applies both when creating a new schema using an array of schemas, as well as when calling `add()` as follows.

```javascript
childSchema.add(new Schema({}, { toObject: { virtuals: true } }));

childSchema.options.toObject; // { virtuals: true } in Mongoose 7. undefined in Mongoose 6.
```

<h3 id="objectid-bsontype-now-has-lowercase-d"><a href="#objectid-bsontype-now-has-lowercase-d">ObjectId bsontype now has lowercase d</a></h3>

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

0 comments on commit 9b1ff1f

Please sign in to comment.