Automattic/mongoose
### [`v5.9.18`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5918--2020-06-05)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.17...5.9.18)
===================
- fix: improve atlas error in the event of incorrect password [#9095](https://togithub.com/Automattic/mongoose/issues/9095)
- docs: add edit link for all docs pages [#9058](https://togithub.com/Automattic/mongoose/issues/9058)
- fix(document): allow accessing `$locals` when initializing document [#9099](https://togithub.com/Automattic/mongoose/issues/9099) [#9098](https://togithub.com/Automattic/mongoose/issues/9098) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(query): make `setDefaultsOnInsert` a mongoose option so it doesn't end up in debug output [#9086](https://togithub.com/Automattic/mongoose/issues/9086)
- docs(connection+index): add serverSelectionTimeoutMS and heartbeatFrequencyMS to `connect()` and `openUri()` options [#9071](https://togithub.com/Automattic/mongoose/issues/9071)
- docs(geojson): add notes about geojson 2dsphere indexes [#9044](https://togithub.com/Automattic/mongoose/issues/9044)
- docs: make active page bold in navbar [#9062](https://togithub.com/Automattic/mongoose/issues/9062)
- docs: correct a typo in a code snippet [#9089](https://togithub.com/Automattic/mongoose/issues/9089) [Elvis-Sarfo](https://togithub.com/Elvis-Sarfo)
### [`v5.9.17`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5917--2020-06-02)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.16...5.9.17)
===================
- fix(document): avoid tracking changes like `splice()` on slice()-ed arrays [#9011](https://togithub.com/Automattic/mongoose/issues/9011)
- fix(populate): make populating a nested path a no-op [#9073](https://togithub.com/Automattic/mongoose/issues/9073)
- fix(document): clear nested cast errors when overwriting an array path [#9080](https://togithub.com/Automattic/mongoose/issues/9080)
- fix: upgrade mongodb to v3.5.8 [#9069](https://togithub.com/Automattic/mongoose/issues/9069) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(document): add validateModifiedOnly to Document#save(), Document#validateSync() and Document#validate() [#9078](https://togithub.com/Automattic/mongoose/issues/9078) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(faq): fix typo [#9075](https://togithub.com/Automattic/mongoose/issues/9075) [tigransimonyan](https://togithub.com/tigransimonyan)
- docs: document all parameters to .debug [#9029](https://togithub.com/Automattic/mongoose/issues/9029) [dandv](https://togithub.com/dandv)
- docs: fix property value in Getters example [#9061](https://togithub.com/Automattic/mongoose/issues/9061) [ismet](https://togithub.com/ismet)
### [`v5.9.16`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5916--2020-05-25)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.15...5.9.16)
===================
- perf(error): convert errors to classes extending Error for lower CPU overhead [#9021](https://togithub.com/Automattic/mongoose/issues/9021) [zbjornson](https://togithub.com/zbjornson)
- fix(query): throw CastError if filter `$and`, `$or`, `$nor` contain non-object values [#8948](https://togithub.com/Automattic/mongoose/issues/8948)
- fix(bulkwrite): cast filter & update to schema after applying timestamps [#9030](https://togithub.com/Automattic/mongoose/issues/9030) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(document): don't overwrite defaults with undefined keys in nested documents [#9039](https://togithub.com/Automattic/mongoose/issues/9039) [vitorhnn](https://togithub.com/vitorhnn)
- fix(discriminator): remove discriminator schema nested paths pulled from base schema underneath a mixed path in discriminator schema [#9042](https://togithub.com/Automattic/mongoose/issues/9042)
- fix(model): make syncIndexes() not drop index if all user-specified collation options are the same [#8994](https://togithub.com/Automattic/mongoose/issues/8994)
- fix(document): make internal `$__.scope` property a symbol instead to work around a bug with fast-safe-stringify [#8955](https://togithub.com/Automattic/mongoose/issues/8955)
- docs: model.findByIdAndUpdate() 'new' param fix [#9026](https://togithub.com/Automattic/mongoose/issues/9026) [dandv](https://togithub.com/dandv)
### [`v5.9.15`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5915--2020-05-18)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.14...5.9.15)
===================
- fix(schema): treat creating dotted path with no parent as creating a nested path [#9020](https://togithub.com/Automattic/mongoose/issues/9020)
- fix(documentarray): make sure you can call `unshift()` after `map()` [#9012](https://togithub.com/Automattic/mongoose/issues/9012) [philippejer](https://togithub.com/philippejer)
- fix(model): cast bulkwrite according to discriminator schema if discriminator key is present [#8982](https://togithub.com/Automattic/mongoose/issues/8982) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(schema): remove `db` from reserved keywords [#8940](https://togithub.com/Automattic/mongoose/issues/8940)
- fix(populate): treat populating a doc array that doesn't have a `ref` as a no-op [#8946](https://togithub.com/Automattic/mongoose/issues/8946)
- fix(timestamps): set createdAt and updatedAt on doubly nested subdocs when upserting [#8894](https://togithub.com/Automattic/mongoose/issues/8894)
- fix(model): allow POJOs as schemas for model.discriminator(...) [#8991](https://togithub.com/Automattic/mongoose/issues/8991) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(model): report `insertedDocs` on `insertMany()` errors [#8938](https://togithub.com/Automattic/mongoose/issues/8938)
- fix(model): ensure consistent `writeErrors` property on insertMany error with `ordered: false`, even if only one op failed [#8938](https://togithub.com/Automattic/mongoose/issues/8938)
- docs: add anchor tag to strictQuery and strict [#9014](https://togithub.com/Automattic/mongoose/issues/9014) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(faq): remove faq ipv6 [#9004](https://togithub.com/Automattic/mongoose/issues/9004)
- docs: add note about throwing error only after validation and fix broken reference to api/CastError [#8993](https://togithub.com/Automattic/mongoose/issues/8993) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: fix typos in documents.pug [#9005](https://togithub.com/Automattic/mongoose/issues/9005) [dandv](https://togithub.com/dandv)
### [`v5.9.14`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5914--2020-05-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.13...5.9.14)
===================
- fix(cursor): add index as second parameter to eachAsync callback [#8972](https://togithub.com/Automattic/mongoose/issues/8972) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(query): cast filter according to discriminator schema if discriminator key in filter [#8881](https://togithub.com/Automattic/mongoose/issues/8881)
- fix(model): fix throwing error when populating virtual path defined on child discriminator [#8924](https://togithub.com/Automattic/mongoose/issues/8924) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(errors): handle case when user has make `Error.prototype.toJSON` read only [#8986](https://togithub.com/Automattic/mongoose/issues/8986) [osher](https://togithub.com/osher)
- fix(model): add `kind` to cast errors thrown by query execution [#8953](https://togithub.com/Automattic/mongoose/issues/8953) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(update): use child schema strict on single nested updates if useNestedStrict not set [#8922](https://togithub.com/Automattic/mongoose/issues/8922)
- docs(model): improve `save()` docs [#8956](https://togithub.com/Automattic/mongoose/issues/8956) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: add immutable type to Schema Types [#8987](https://togithub.com/Automattic/mongoose/issues/8987) [Andrew5569](https://togithub.com/Andrew5569)
- docs: sort schema reserved keys in documentation [#8966](https://togithub.com/Automattic/mongoose/issues/8966) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
### [`v5.9.13`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5913--2020-05-08)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.12...5.9.13)
===================
- fix(schema): mark correct path as modified when setting a path underneath a nested array of documents [#8926](https://togithub.com/Automattic/mongoose/issues/8926)
- fix(query): Query#select({ field: false }) should not overwrite schema selection options [#8929](https://togithub.com/Automattic/mongoose/issues/8929) [#8923](https://togithub.com/Automattic/mongoose/issues/8923)
- fix(update): handle immutable properties are ignored in bulk upserts [#8952](https://togithub.com/Automattic/mongoose/issues/8952) [philippejer](https://togithub.com/philippejer)
- docs(browser): add back sample webpack config [#8890](https://togithub.com/Automattic/mongoose/issues/8890)
- docs(faq): fix broken reference in limit vs perDocumentLimit [#8937](https://togithub.com/Automattic/mongoose/issues/8937)
### [`v5.9.12`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5912--2020-05-04)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.11...5.9.12)
===================
- fix(document): report cast error on array elements with array index instead of just being a cast error for the whole array [#8888](https://togithub.com/Automattic/mongoose/issues/8888)
- fix(connection): throw more helpful error in case of IP whitelisting issue with Atlas [#8846](https://togithub.com/Automattic/mongoose/issues/8846)
- fix(schema): throw error on schema with reserved key with type of object [#8869](https://togithub.com/Automattic/mongoose/issues/8869) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(connection): inherit config for useDB from default connection [#8267](https://togithub.com/Automattic/mongoose/issues/8267) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(query): set mongodb options for `distinct()` [#8906](https://togithub.com/Automattic/mongoose/issues/8906) [clhuang](https://togithub.com/clhuang)
- fix(schema): allow adding descending indexes on schema [#8895](https://togithub.com/Automattic/mongoose/issues/8895) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(document): set defaults if setting nested path to empty object with `minimize: false` [#8829](https://togithub.com/Automattic/mongoose/issues/8829)
- fix(populate): check discriminator existence before accessing schema in getModelsMapForPopulate [#8837](https://togithub.com/Automattic/mongoose/issues/8837) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: fix broken references to Mongoose#Document API, and prefer mongoose.model(...) over Document#model(...) [#8914](https://togithub.com/Automattic/mongoose/issues/8914) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(model): adds options.limit to Model.insertMany(...) [#8864](https://togithub.com/Automattic/mongoose/issues/8864) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: add flattenMaps and aliases to Document#toObject() [#8901](https://togithub.com/Automattic/mongoose/issues/8901) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(model): add options.overwrite to findOneAndUpdate [#8865](https://togithub.com/Automattic/mongoose/issues/8865) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(populate+faq): separate limit-vs-perDocumentLimit into its own section, add FAQ for populate and limit [#8917](https://togithub.com/Automattic/mongoose/issues/8917) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
### [`v5.9.11`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5911--2020-04-30)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.10...5.9.11)
===================
- fix: upgrade mongodb driver -> 3.5.7 [#8842](https://togithub.com/Automattic/mongoose/issues/8842) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix: validate nested paths on Model.validate(...) [#8848](https://togithub.com/Automattic/mongoose/issues/8848) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(populate): make doc.execPopulate(options) a shorthand for doc.populate(options).execPopulate() [#8840](https://togithub.com/Automattic/mongoose/issues/8840) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(model): return validation errors when all docs are invalid & rawResult set [#8853](https://togithub.com/Automattic/mongoose/issues/8853) [tusharf5](https://togithub.com/tusharf5)
- fix(schemaType): treat select: null or select: undefined as not specified [#8850](https://togithub.com/Automattic/mongoose/issues/8850) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix: fix stream close event listener being called multiple times in Node 14 [#8835](https://togithub.com/Automattic/mongoose/issues/8835) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(populate): handle `clone` with `lean` when setting a path to `null` [#8807](https://togithub.com/Automattic/mongoose/issues/8807)
- docs(faq): clarify setting paths under document arrays with `markModified()` [#8854](https://togithub.com/Automattic/mongoose/issues/8854)
- docs: fix race condition in creating connection for lambda [#8845](https://togithub.com/Automattic/mongoose/issues/8845) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: add options.path for Model.populate(...) [#8833](https://togithub.com/Automattic/mongoose/issues/8833) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: use ES6 classes for custom schema type example [#8802](https://togithub.com/Automattic/mongoose/issues/8802)
### [`v5.9.10`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5910--2020-04-20)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.9...5.9.10)
===================
- fix: upgrade mongodb -> 3.5.6, bson -> 1.1.4 [#8719](https://togithub.com/Automattic/mongoose/issues/8719)
- fix(document): avoid calling `$set()` on object keys if object path isn't in schema [#8751](https://togithub.com/Automattic/mongoose/issues/8751)
- fix(timestamps): handle timestamps on doubly nested subdocuments [#8799](https://togithub.com/Automattic/mongoose/issues/8799)
- fix(schematype): throw error if default is set to a schema instance [#8751](https://togithub.com/Automattic/mongoose/issues/8751)
- fix: handle $elemMatch projection with `select: false` in schema [#8818](https://togithub.com/Automattic/mongoose/issues/8818) [#8806](https://togithub.com/Automattic/mongoose/issues/8806) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: make FAQ questions more linkable [#8825](https://togithub.com/Automattic/mongoose/issues/8825) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(validation): use `init()` as opposed to `once('index')` in `unique` example [#8816](https://togithub.com/Automattic/mongoose/issues/8816)
- docs: clarify `insertMany()` return value [#8820](https://togithub.com/Automattic/mongoose/issues/8820) [dandv](https://togithub.com/dandv)
- docs(populate+query): fix typos [#8793](https://togithub.com/Automattic/mongoose/issues/8793) [#8794](https://togithub.com/Automattic/mongoose/issues/8794) [dandv](https://togithub.com/dandv)
- docs(model): document skipId parameter [#8791](https://togithub.com/Automattic/mongoose/issues/8791) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
### [`v5.9.9`](https://togithub.com/Automattic/mongoose/blob/master/History.md#599--2020-04-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.7...5.9.9)
==================
- fix(model): make Model.bulkWrite accept `strict` option [#8782](https://togithub.com/Automattic/mongoose/issues/8782) [#8788](https://togithub.com/Automattic/mongoose/issues/8788) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(virtual): make populated virtual getter return value when it is passed in [#8775](https://togithub.com/Automattic/mongoose/issues/8775) [#8774](https://togithub.com/Automattic/mongoose/issues/8774) [makinde](https://togithub.com/makinde)
- fix(document): handle validating document array whose docs contain maps and nested paths [#8767](https://togithub.com/Automattic/mongoose/issues/8767)
- fix(document): skip discriminator key when overwriting a document [#8765](https://togithub.com/Automattic/mongoose/issues/8765)
- fix(populate): support `clone` option with `lean` [#8761](https://togithub.com/Automattic/mongoose/issues/8761) [#8760](https://togithub.com/Automattic/mongoose/issues/8760)
- docs(transactions): use `endSession()` in all transactions examples [#8741](https://togithub.com/Automattic/mongoose/issues/8741)
- docs(queries): expand streaming section to include async iterators, cursor timeouts, and sesssion idle timeouts [#8720](https://togithub.com/Automattic/mongoose/issues/8720)
- docs(model+query+findoneandupdate): add docs for `returnOriginal` option [#8766](https://togithub.com/Automattic/mongoose/issues/8766)
- docs(model): fix punctuation [#8788](https://togithub.com/Automattic/mongoose/issues/8788) [dandv](https://togithub.com/dandv)
- docs: fix typos [#8780](https://togithub.com/Automattic/mongoose/issues/8780) [#8799](https://togithub.com/Automattic/mongoose/issues/8799) [dandv](https://togithub.com/dandv)
### [`v5.9.7`](https://togithub.com/Automattic/mongoose/blob/master/History.md#597--2020-03-30)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.6...5.9.7)
==================
- fix(map): avoid infinite loop when setting a map of documents to a document copied using spread operator [#8722](https://togithub.com/Automattic/mongoose/issues/8722)
- fix(query): clean stack trace for filter cast errors so they include the calling file [#8691](https://togithub.com/Automattic/mongoose/issues/8691)
- fix(model): make bulkWrite updates error if `strict` and `upsert` are set and `filter` contains a non-schema path [#8698](https://togithub.com/Automattic/mongoose/issues/8698)
- fix(cast): make internal `castToNumber()` allow undefined [#8725](https://togithub.com/Automattic/mongoose/issues/8725) [p3x-robot](https://togithub.com/p3x-robot)
### [`v5.9.6`](https://togithub.com/Automattic/mongoose/blob/master/History.md#596--2020-03-23)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.5...5.9.6)
==================
- fix(document): allow saving document with nested document array after setting `nestedArr.0` [#8689](https://togithub.com/Automattic/mongoose/issues/8689)
- docs(connections): expand section about multiple connections to describe patterns for exporting schemas [#8679](https://togithub.com/Automattic/mongoose/issues/8679)
- docs(populate): add note about `execPopulate()` to "populate an existing document" section [#8671](https://togithub.com/Automattic/mongoose/issues/8671) [#8275](https://togithub.com/Automattic/mongoose/issues/8275)
- docs: fix broken links [#8690](https://togithub.com/Automattic/mongoose/issues/8690) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(guide): fix typos [#8704](https://togithub.com/Automattic/mongoose/issues/8704) [MateRyze](https://togithub.com/MateRyze)
- docs(guide): fix minor typo [#8683](https://togithub.com/Automattic/mongoose/issues/8683) [pkellz](https://togithub.com/pkellz)
### [`v5.9.5`](https://togithub.com/Automattic/mongoose/blob/master/History.md#595--2020-03-16)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.4...5.9.5)
==================
- fix: upgrade mongodb driver -> 3.5.5 [#8667](https://togithub.com/Automattic/mongoose/issues/8667) [#8664](https://togithub.com/Automattic/mongoose/issues/8664) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(connection): emit "disconnected" after losing connectivity to every member of a replica set with `useUnifiedTopology: true` [#8643](https://togithub.com/Automattic/mongoose/issues/8643)
- fix(array): allow calling `slice()` after `push()` [#8668](https://togithub.com/Automattic/mongoose/issues/8668) [#8655](https://togithub.com/Automattic/mongoose/issues/8655) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(map): avoid marking map as modified if setting `key` to the same value [#8652](https://togithub.com/Automattic/mongoose/issues/8652)
- fix(updateValidators): don't run `Mixed` update validator on dotted path underneath mixed type [#8659](https://togithub.com/Automattic/mongoose/issues/8659)
- fix(populate): ensure top-level `limit` applies if one document being populated has more than `limit` results [#8657](https://togithub.com/Automattic/mongoose/issues/8657)
- fix(populate): throw error if both `limit` and `perDocumentLimit` are set [#8661](https://togithub.com/Automattic/mongoose/issues/8661) [#8658](https://togithub.com/Automattic/mongoose/issues/8658) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(findOneAndUpdate): add a section about the `rawResult` option [#8662](https://togithub.com/Automattic/mongoose/issues/8662)
- docs(guide): add section about `loadClass()` [#8623](https://togithub.com/Automattic/mongoose/issues/8623)
- docs(query): improve `Query#populate()` example to clarify that `sort` doesn't affect the original result's order [#8647](https://togithub.com/Automattic/mongoose/issues/8647)
### [`v5.9.4`](https://togithub.com/Automattic/mongoose/blob/master/History.md#594--2020-03-09)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.3...5.9.4)
==================
- fix(document): allow `new Model(doc)` to set immutable properties when doc is a mongoose document [#8642](https://togithub.com/Automattic/mongoose/issues/8642)
- fix(array): make sure you can call `unshift()` after `slice()` [#8482](https://togithub.com/Automattic/mongoose/issues/8482)
- fix(schema): propagate `typePojoToMixed` to implicitly created arrays [#8627](https://togithub.com/Automattic/mongoose/issues/8627)
- fix(schema): also propagate `typePojoToMixed` option to schemas implicitly created because of `typePojoToMixed` [#8627](https://togithub.com/Automattic/mongoose/issues/8627)
- fix(model): support passing `background` option to `syncIndexes()` [#8645](https://togithub.com/Automattic/mongoose/issues/8645)
- docs(schema): add a section about the `_id` path in schemas [#8625](https://togithub.com/Automattic/mongoose/issues/8625)
- docs(virtualtype+populate): document using `match` with virtual populate [#8616](https://togithub.com/Automattic/mongoose/issues/8616)
- docs(guide): fix typo [#8648](https://togithub.com/Automattic/mongoose/issues/8648) [sauzy34](https://togithub.com/sauzy34)
### [`v5.9.3`](https://togithub.com/Automattic/mongoose/blob/master/History.md#593--2020-03-02)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.2...5.9.3)
==================
- fix: upgrade mongodb driver -> 3.5.4 [#8620](https://togithub.com/Automattic/mongoose/issues/8620)
- fix(document): set subpath defaults when overwriting single nested subdoc [#8603](https://togithub.com/Automattic/mongoose/issues/8603)
- fix(document): make calling `validate()` with single nested subpath only validate that single nested subpath [#8626](https://togithub.com/Automattic/mongoose/issues/8626)
- fix(browser): make `mongoose.model()` return a class in the browser to allow hydrating populated data in the browser [#8605](https://togithub.com/Automattic/mongoose/issues/8605)
- fix(model): make `syncIndexes()` and `cleanIndexes()` drop compound indexes with `_id` that aren't in the schema [#8559](https://togithub.com/Automattic/mongoose/issues/8559)
- docs(connection+index): add warnings to explain that bufferMaxEntries does nothing with `useUnifiedTopology` [#8604](https://togithub.com/Automattic/mongoose/issues/8604)
- docs(document+model+query): add `options.timestamps` parameter docs to `findOneAndUpdate()` and `findByIdAndUpdate()` [#8619](https://togithub.com/Automattic/mongoose/issues/8619)
- docs: fix out of date links to tumblr [#8599](https://togithub.com/Automattic/mongoose/issues/8599)
### [`v5.9.2`](https://togithub.com/Automattic/mongoose/blob/master/History.md#592--2020-02-21)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.1...5.9.2)
==================
- fix(model): add discriminator key to bulkWrite filters [#8590](https://togithub.com/Automattic/mongoose/issues/8590)
- fix(document): when setting nested array path to non-nested array, wrap values top-down rather than bottom up when possible [#8544](https://togithub.com/Automattic/mongoose/issues/8544)
- fix(document): dont leave nested key as undefined when setting nested key to empty object with minimize [#8565](https://togithub.com/Automattic/mongoose/issues/8565)
- fix(document): avoid throwing error if setting path to Mongoose document with nullish `_doc` [#8565](https://togithub.com/Automattic/mongoose/issues/8565)
- fix(update): handle Binary type correctly with `runValidators` [#8580](https://togithub.com/Automattic/mongoose/issues/8580)
- fix(query): run `deleteOne` hooks only on `Document#deleteOne()` when setting `options.document = true` for `Schema#pre()` [#8555](https://togithub.com/Automattic/mongoose/issues/8555)
- fix(document): allow calling `validate()` in post validate hook without causing parallel validation error [#8597](https://togithub.com/Automattic/mongoose/issues/8597)
- fix(virtualtype): correctly copy options when cloning [#8587](https://togithub.com/Automattic/mongoose/issues/8587)
- fix(collection): skip creating capped collection if `autoCreate` set to `false` [#8566](https://togithub.com/Automattic/mongoose/issues/8566)
- docs(middleware): clarify that updateOne and deleteOne hooks are query middleware by default, not document middleware [#8581](https://togithub.com/Automattic/mongoose/issues/8581)
- docs(aggregate): clarify that `Aggregate#unwind()` can take object parameters as well as strings [#8594](https://togithub.com/Automattic/mongoose/issues/8594)
### [`v5.9.1`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5918--2020-06-05)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.0...5.9.1)
===================
- fix: improve atlas error in the event of incorrect password [#9095](https://togithub.com/Automattic/mongoose/issues/9095)
- docs: add edit link for all docs pages [#9058](https://togithub.com/Automattic/mongoose/issues/9058)
- fix(document): allow accessing `$locals` when initializing document [#9099](https://togithub.com/Automattic/mongoose/issues/9099) [#9098](https://togithub.com/Automattic/mongoose/issues/9098) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(query): make `setDefaultsOnInsert` a mongoose option so it doesn't end up in debug output [#9086](https://togithub.com/Automattic/mongoose/issues/9086)
- docs(connection+index): add serverSelectionTimeoutMS and heartbeatFrequencyMS to `connect()` and `openUri()` options [#9071](https://togithub.com/Automattic/mongoose/issues/9071)
- docs(geojson): add notes about geojson 2dsphere indexes [#9044](https://togithub.com/Automattic/mongoose/issues/9044)
- docs: make active page bold in navbar [#9062](https://togithub.com/Automattic/mongoose/issues/9062)
- docs: correct a typo in a code snippet [#9089](https://togithub.com/Automattic/mongoose/issues/9089) [Elvis-Sarfo](https://togithub.com/Elvis-Sarfo)
### [`v5.9.0`](https://togithub.com/Automattic/mongoose/blob/master/History.md#590--2020-02-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.13...5.9.0)
==================
- fix: upgrade to MongoDB driver 3.5 [#8520](https://togithub.com/Automattic/mongoose/issues/8520) [#8563](https://togithub.com/Automattic/mongoose/issues/8563)
- feat(schematype): support setting default options for schema type (`trim` on all strings, etc.) [#8487](https://togithub.com/Automattic/mongoose/issues/8487)
- feat(populate): add `perDocumentLimit` option that limits per document in `find()` result, rather than across all documents [#7318](https://togithub.com/Automattic/mongoose/issues/7318)
- feat(schematype): enable setting `transform` option on individual schematypes [#8403](https://togithub.com/Automattic/mongoose/issues/8403)
- feat(timestamps): allow setting `currentTime` option for setting custom function to get the current time [#3957](https://togithub.com/Automattic/mongoose/issues/3957)
- feat(connection): add `Connection#watch()` to watch for changes on an entire database [#8425](https://togithub.com/Automattic/mongoose/issues/8425)
- feat(document): add `Document#$op` property to make it easier to tell what operation is running in middleware [#8439](https://togithub.com/Automattic/mongoose/issues/8439)
- feat(populate): support `limit` as top-level populate option [#8445](https://togithub.com/Automattic/mongoose/issues/8445)
### [`v5.8.13`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5813--2020-02-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.12...5.8.13)
===================
- fix(populate): use safe get to avoid crash if schematype doesn't have options [#8586](https://togithub.com/Automattic/mongoose/issues/8586)
### [`v5.8.12`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5812--2020-02-12)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.11...5.8.12)
===================
- fix(query): correctly cast dbref `$id` with `$elemMatch` [#8577](https://togithub.com/Automattic/mongoose/issues/8577)
- fix(populate): handle populating when some embedded discriminator schemas have `refPath` but none of the subdocs have `refPath` [#8553](https://togithub.com/Automattic/mongoose/issues/8553)
- docs: add useUnifiedTopology to homepage example [#8558](https://togithub.com/Automattic/mongoose/issues/8558) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- refactor(utils): moving promiseOrCallback to helpers/promiseOrCallback [#8573](https://togithub.com/Automattic/mongoose/issues/8573) [hugosenari](https://togithub.com/hugosenari)
### [`v5.8.11`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5811--2020-01-31)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.10...5.8.11)
===================
- fix(document): allow calling `validate()` multiple times in parallel on subdocs to avoid errors if Mongoose double-validates [taxilian](https://togithub.com/taxilian) [#8548](https://togithub.com/Automattic/mongoose/issues/8548) [#8539](https://togithub.com/Automattic/mongoose/issues/8539)
- fix(connection): allow calling initial `mongoose.connect()` after connection helpers on the same tick [#8534](https://togithub.com/Automattic/mongoose/issues/8534)
- fix(connection): throw helpful error when callback param to `mongoose.connect()` or `mongoose.createConnection()` is not a function [#8556](https://togithub.com/Automattic/mongoose/issues/8556)
- fix(drivers): avoid unnecessary caught error when importing [#8528](https://togithub.com/Automattic/mongoose/issues/8528)
- fix(discriminator): remove unnecessary `utils.merge()` [samgladstone](https://togithub.com/samgladstone) [#8542](https://togithub.com/Automattic/mongoose/issues/8542)
- docs: add "built with mongoose" page [#8540](https://togithub.com/Automattic/mongoose/issues/8540)
### [`v5.8.10`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5810--2020-01-27)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.9...5.8.10)
===================
- perf(document): improve performance of document creation by skipping unnecessary split() calls [#8533](https://togithub.com/Automattic/mongoose/issues/8533) [igrunert-atlassian](https://togithub.com/igrunert-atlassian)
- fix(document): only call validate once for deeply nested subdocuments [#8532](https://togithub.com/Automattic/mongoose/issues/8532) [#8531](https://togithub.com/Automattic/mongoose/issues/8531) [taxilian](https://togithub.com/taxilian)
- fix(document): create document array defaults in forward order, not reverse [#8514](https://togithub.com/Automattic/mongoose/issues/8514)
- fix(document): allow function as message for date min/max validator [#8512](https://togithub.com/Automattic/mongoose/issues/8512)
- fix(populate): don't try to populate embedded discriminator that has populated path but no `refPath` [#8527](https://togithub.com/Automattic/mongoose/issues/8527)
- fix(document): plugins from base schema when creating a discriminator [#8536](https://togithub.com/Automattic/mongoose/issues/8536) [samgladstone](https://togithub.com/samgladstone)
- fix(document): ensure parent and ownerDocument are set for subdocs in document array defaults [#8509](https://togithub.com/Automattic/mongoose/issues/8509)
- fix(document): dont set undefined keys to null if minimize is false [#8504](https://togithub.com/Automattic/mongoose/issues/8504)
- fix(update): bump timestamps when using update aggregation pipelines [#8524](https://togithub.com/Automattic/mongoose/issues/8524)
- fix(model): ensure `cleanIndexes()` drops indexes with different collations [#8521](https://togithub.com/Automattic/mongoose/issues/8521)
- docs(model): document `insertMany` `lean` option [#8522](https://togithub.com/Automattic/mongoose/issues/8522)
- docs(connections): document `authSource` option [#8517](https://togithub.com/Automattic/mongoose/issues/8517)
### [`v5.8.9`](https://togithub.com/Automattic/mongoose/blob/master/History.md#589--2020-01-17)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.7...5.8.9)
==================
- fix(populate): skip populating embedded discriminator array values that don't have a `refPath` [#8499](https://togithub.com/Automattic/mongoose/issues/8499)
- docs(queries): clarify when to use queries versus aggregations [#8494](https://togithub.com/Automattic/mongoose/issues/8494)
### [`v5.8.7`](https://togithub.com/Automattic/mongoose/blob/master/History.md#587--2020-01-10)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.6...5.8.7)
==================
- fix(documentarray): modify ownerDocument when setting doc array to a doc array thats part of another document [#8479](https://togithub.com/Automattic/mongoose/issues/8479)
- fix(document): ensure that you can call `splice()` after `slice()` on an array [#8482](https://togithub.com/Automattic/mongoose/issues/8482)
- docs(populate): improve cross-db populate docs to include model refs [#8497](https://togithub.com/Automattic/mongoose/issues/8497)
### [`v5.8.6`](https://togithub.com/Automattic/mongoose/blob/master/History.md#586--2020-01-07)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.5...5.8.6)
====================
- chore: merge changes from 4.13.20 and override mistaken publish to latest tag
### [`v5.8.5`](https://togithub.com/Automattic/mongoose/blob/master/History.md#585--2020-01-06)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.4...5.8.5)
==================
- fix(document): throw error when running `validate()` multiple times on the same document [#8468](https://togithub.com/Automattic/mongoose/issues/8468)
- fix(model): ensure deleteOne() and deleteMany() set discriminator filter even if no conditions passed [#8471](https://togithub.com/Automattic/mongoose/issues/8471)
- fix(document): allow pre('validate') hooks to throw errors with `name = 'ValidationError'` [#8466](https://togithub.com/Automattic/mongoose/issues/8466)
- fix(update): move top level $set of immutable properties to $setOnInsert so upserting with immutable properties actually sets the property [#8467](https://togithub.com/Automattic/mongoose/issues/8467)
- fix(document): avoid double-running validators on single nested subdocs within single nested subdocs [#8468](https://togithub.com/Automattic/mongoose/issues/8468)
- fix(populate): support top-level match option for virtual populate [#8475](https://togithub.com/Automattic/mongoose/issues/8475)
- fix(model): avoid applying skip when populating virtual with count [#8476](https://togithub.com/Automattic/mongoose/issues/8476)
### [`v5.8.4`](https://togithub.com/Automattic/mongoose/blob/master/History.md#584--2020-01-02)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.3...5.8.4)
==================
- fix(populate): ensure populate virtual gets set to empty array if `localField` is undefined in the database [#8455](https://togithub.com/Automattic/mongoose/issues/8455)
- fix(connection): wrap `mongoose.connect()` server selection timeouts in MongooseTimeoutError for more readable stack traces [#8451](https://togithub.com/Automattic/mongoose/issues/8451)
- fix(populate): allow deselecting `foreignField` from projection by prefixing with `-` [#8460](https://togithub.com/Automattic/mongoose/issues/8460)
- fix(populate): support embedded discriminators with `refPath` when not all discriminator schemas have `refPath` [#8452](https://togithub.com/Automattic/mongoose/issues/8452)
- fix(array): allow defining `enum` on array if an array of numbers [#8449](https://togithub.com/Automattic/mongoose/issues/8449)
### [`v5.8.3`](https://togithub.com/Automattic/mongoose/blob/master/History.md#583--2019-12-23)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.2...5.8.3)
==================
- fix: upgrade mongodb -> 3.4.1 [#8430](https://togithub.com/Automattic/mongoose/issues/8430) [jaschaio](https://togithub.com/jaschaio)
- fix(populate): don't add empty subdocument to array when populating path underneath a non-existent document array [#8432](https://togithub.com/Automattic/mongoose/issues/8432)
- fix(schema): handle `_id` option for document array schematypes [#8450](https://togithub.com/Automattic/mongoose/issues/8450)
- fix(update): call setters when updating mixed type [#8444](https://togithub.com/Automattic/mongoose/issues/8444)
- docs(connections): add note about MongoTimeoutError.reason [#8402](https://togithub.com/Automattic/mongoose/issues/8402)
### [`v5.8.2`](https://togithub.com/Automattic/mongoose/blob/master/History.md#582--2019-12-20)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.1...5.8.2)
==================
- fix(schema): copy `.add()`-ed paths when calling `.add()` with schema argument [#8429](https://togithub.com/Automattic/mongoose/issues/8429)
- fix(cursor): pull schema-level readPreference when using `Query#cursor()` [#8421](https://togithub.com/Automattic/mongoose/issues/8421)
- fix(cursor): wait for all promises to resolve if `parallel` is greater than number of documents [#8422](https://togithub.com/Automattic/mongoose/issues/8422)
- fix(document): depopulate entire array when setting array path to a partially populated array [#8443](https://togithub.com/Automattic/mongoose/issues/8443)
- fix: handle setDefaultsOnInsert with deeply nested subdocs [#8392](https://togithub.com/Automattic/mongoose/issues/8392)
- fix(document): report `DocumentNotFoundError` if underlying document deleted but no changes made [#8428](https://togithub.com/Automattic/mongoose/issues/8428) [#8371](https://togithub.com/Automattic/mongoose/issues/8371) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(populate): clarify limitations of `limit` option for populate and suggest workaround [#8409](https://togithub.com/Automattic/mongoose/issues/8409)
- docs(deprecations): explain which connection options are no longer relevant with useUnifiedTopology [#8411](https://togithub.com/Automattic/mongoose/issues/8411)
- chore: allow browser build to be published [#8435](https://togithub.com/Automattic/mongoose/issues/8435) [#8427](https://togithub.com/Automattic/mongoose/issues/8427) [captaincaius](https://togithub.com/captaincaius)
### [`v5.8.1`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5813--2020-02-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.0...5.8.1)
===================
- fix(populate): use safe get to avoid crash if schematype doesn't have options [#8586](https://togithub.com/Automattic/mongoose/issues/8586)
### [`v5.8.0`](https://togithub.com/Automattic/mongoose/blob/master/History.md#580--2019-12-09)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.7.14...5.8.0)
==================
- feat: wrap server selection timeout errors in `MongooseTimeoutError` to retain original stack trace [#8259](https://togithub.com/Automattic/mongoose/issues/8259)
- feat(model): add `Model.validate()` function that validates a POJO against the model's schema [#7587](https://togithub.com/Automattic/mongoose/issues/7587)
- feat(schema): add `Schema#pick()` function to create a new schema with a picked subset of the original schema's paths [#8207](https://togithub.com/Automattic/mongoose/issues/8207)
- feat(schema): add ability to change CastError message using `cast` option to SchemaType [#8300](https://togithub.com/Automattic/mongoose/issues/8300)
- feat(schema): group indexes defined in schema path with the same name [#6499](https://togithub.com/Automattic/mongoose/issues/6499)
- fix(model): build all indexes even if one index fails [#8185](https://togithub.com/Automattic/mongoose/issues/8185) [unusualbob](https://togithub.com/unusualbob)
- feat(browser): pre-compile mongoose/browser [#8350](https://togithub.com/Automattic/mongoose/issues/8350) [captaincaius](https://togithub.com/captaincaius)
- fix(connection): throw error when setting unsupported option [#8335](https://togithub.com/Automattic/mongoose/issues/8335) [#6899](https://togithub.com/Automattic/mongoose/issues/6899) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- feat(schema): support `enum` validator for number type [#8139](https://togithub.com/Automattic/mongoose/issues/8139)
- feat(update): allow using MongoDB 4.2 update aggregation pipelines, with no Mongoose casting [#8225](https://togithub.com/Automattic/mongoose/issues/8225)
- fix(update): make update validators run on all subpaths when setting a nested path, even omitted subpaths [#3587](https://togithub.com/Automattic/mongoose/issues/3587)
- feat(schema): support setting `_id` as an option to single nested schema paths [#8137](https://togithub.com/Automattic/mongoose/issues/8137)
- feat(query): add Query#mongooseOptions() function [#8296](https://togithub.com/Automattic/mongoose/issues/8296)
- feat(array): make `MongooseArray#push()` support using `$position` [#4322](https://togithub.com/Automattic/mongoose/issues/4322)
- feat(schema): make pojo paths optionally become subdoc instead of Mixed [#8228](https://togithub.com/Automattic/mongoose/issues/8228) [captaincaius](https://togithub.com/captaincaius)
- feat(model): add Model.cleanIndexes() to drop non-schema indexes [#6676](https://togithub.com/Automattic/mongoose/issues/6676)
- feat(document): make `updateOne()` document middleware pass `this` to post hooks [#8262](https://togithub.com/Automattic/mongoose/issues/8262)
- feat(aggregate): run pre/post aggregate hooks on `explain()` [#5887](https://togithub.com/Automattic/mongoose/issues/5887)
- docs(model+query): add `session` option to docs for findOneAndX() methods [#8396](https://togithub.com/Automattic/mongoose/issues/8396)
### [`v5.7.14`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5714--2019-12-06)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.7.13...5.7.14)
===================
- fix(cursor): wait until all `eachAsync()` functions finish before resolving the promise [#8352](https://togithub.com/Automattic/mongoose/issues/8352)
- fix(update): handle embedded discriminator paths when discriminator key is defined in the update [#8378](https://togithub.com/Automattic/mongoose/issues/8378)
- fix(schematype): handle passing `message` function to `SchemaType#validate()` as positional arg [#8360](https://togithub.com/Automattic/mongoose/issues/8360)
- fix(map): handle cloning a schema that has a map of subdocuments [#8357](https://togithub.com/Automattic/mongoose/issues/8357)
- docs(schema): clarify that `uppercase`, `lowercase`, and `trim` options for SchemaString don't affect RegExp queries [#8333](https://togithub.com/Automattic/mongoose/issues/8333)
### [`v5.7.13`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5713--2019-11-29)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/5.7.12...5.7.13)
===================
- fix: upgrade mongodb driver -> 3.3.5 [#8383](https://togithub.com/Automattic/mongoose/issues/8383)
- fix(model): catch the error when insertMany fails to initialize the document [#8365](https://togithub.com/Automattic/mongoose/issues/8365) [#8363](https://togithub.com/Automattic/mongoose/issues/8363) [Fonger](https://togithub.com/Fonger)
- fix(schema): add array.$, array.$.$ subpaths for nested arrays [#6405](https://togithub.com/Automattic/mongoose/issues/6405)
- docs(error): add more detail about the ValidatorError class, including properties [#8346](https://togithub.com/Automattic/mongoose/issues/8346)
- docs(connection): document `Connection#models` property [#8314](https://togithub.com/Automattic/mongoose/issues/8314)
Renovate configuration
:date: Schedule: At any time (no schedule defined).
:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.
:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
:no_bell: Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
5.7.12
->5.9.18
Release Notes
Automattic/mongoose
### [`v5.9.18`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5918--2020-06-05) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.17...5.9.18) =================== - fix: improve atlas error in the event of incorrect password [#9095](https://togithub.com/Automattic/mongoose/issues/9095) - docs: add edit link for all docs pages [#9058](https://togithub.com/Automattic/mongoose/issues/9058) - fix(document): allow accessing `$locals` when initializing document [#9099](https://togithub.com/Automattic/mongoose/issues/9099) [#9098](https://togithub.com/Automattic/mongoose/issues/9098) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(query): make `setDefaultsOnInsert` a mongoose option so it doesn't end up in debug output [#9086](https://togithub.com/Automattic/mongoose/issues/9086) - docs(connection+index): add serverSelectionTimeoutMS and heartbeatFrequencyMS to `connect()` and `openUri()` options [#9071](https://togithub.com/Automattic/mongoose/issues/9071) - docs(geojson): add notes about geojson 2dsphere indexes [#9044](https://togithub.com/Automattic/mongoose/issues/9044) - docs: make active page bold in navbar [#9062](https://togithub.com/Automattic/mongoose/issues/9062) - docs: correct a typo in a code snippet [#9089](https://togithub.com/Automattic/mongoose/issues/9089) [Elvis-Sarfo](https://togithub.com/Elvis-Sarfo) ### [`v5.9.17`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5917--2020-06-02) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.16...5.9.17) =================== - fix(document): avoid tracking changes like `splice()` on slice()-ed arrays [#9011](https://togithub.com/Automattic/mongoose/issues/9011) - fix(populate): make populating a nested path a no-op [#9073](https://togithub.com/Automattic/mongoose/issues/9073) - fix(document): clear nested cast errors when overwriting an array path [#9080](https://togithub.com/Automattic/mongoose/issues/9080) - fix: upgrade mongodb to v3.5.8 [#9069](https://togithub.com/Automattic/mongoose/issues/9069) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(document): add validateModifiedOnly to Document#save(), Document#validateSync() and Document#validate() [#9078](https://togithub.com/Automattic/mongoose/issues/9078) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(faq): fix typo [#9075](https://togithub.com/Automattic/mongoose/issues/9075) [tigransimonyan](https://togithub.com/tigransimonyan) - docs: document all parameters to .debug [#9029](https://togithub.com/Automattic/mongoose/issues/9029) [dandv](https://togithub.com/dandv) - docs: fix property value in Getters example [#9061](https://togithub.com/Automattic/mongoose/issues/9061) [ismet](https://togithub.com/ismet) ### [`v5.9.16`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5916--2020-05-25) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.15...5.9.16) =================== - perf(error): convert errors to classes extending Error for lower CPU overhead [#9021](https://togithub.com/Automattic/mongoose/issues/9021) [zbjornson](https://togithub.com/zbjornson) - fix(query): throw CastError if filter `$and`, `$or`, `$nor` contain non-object values [#8948](https://togithub.com/Automattic/mongoose/issues/8948) - fix(bulkwrite): cast filter & update to schema after applying timestamps [#9030](https://togithub.com/Automattic/mongoose/issues/9030) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(document): don't overwrite defaults with undefined keys in nested documents [#9039](https://togithub.com/Automattic/mongoose/issues/9039) [vitorhnn](https://togithub.com/vitorhnn) - fix(discriminator): remove discriminator schema nested paths pulled from base schema underneath a mixed path in discriminator schema [#9042](https://togithub.com/Automattic/mongoose/issues/9042) - fix(model): make syncIndexes() not drop index if all user-specified collation options are the same [#8994](https://togithub.com/Automattic/mongoose/issues/8994) - fix(document): make internal `$__.scope` property a symbol instead to work around a bug with fast-safe-stringify [#8955](https://togithub.com/Automattic/mongoose/issues/8955) - docs: model.findByIdAndUpdate() 'new' param fix [#9026](https://togithub.com/Automattic/mongoose/issues/9026) [dandv](https://togithub.com/dandv) ### [`v5.9.15`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5915--2020-05-18) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.14...5.9.15) =================== - fix(schema): treat creating dotted path with no parent as creating a nested path [#9020](https://togithub.com/Automattic/mongoose/issues/9020) - fix(documentarray): make sure you can call `unshift()` after `map()` [#9012](https://togithub.com/Automattic/mongoose/issues/9012) [philippejer](https://togithub.com/philippejer) - fix(model): cast bulkwrite according to discriminator schema if discriminator key is present [#8982](https://togithub.com/Automattic/mongoose/issues/8982) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(schema): remove `db` from reserved keywords [#8940](https://togithub.com/Automattic/mongoose/issues/8940) - fix(populate): treat populating a doc array that doesn't have a `ref` as a no-op [#8946](https://togithub.com/Automattic/mongoose/issues/8946) - fix(timestamps): set createdAt and updatedAt on doubly nested subdocs when upserting [#8894](https://togithub.com/Automattic/mongoose/issues/8894) - fix(model): allow POJOs as schemas for model.discriminator(...) [#8991](https://togithub.com/Automattic/mongoose/issues/8991) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(model): report `insertedDocs` on `insertMany()` errors [#8938](https://togithub.com/Automattic/mongoose/issues/8938) - fix(model): ensure consistent `writeErrors` property on insertMany error with `ordered: false`, even if only one op failed [#8938](https://togithub.com/Automattic/mongoose/issues/8938) - docs: add anchor tag to strictQuery and strict [#9014](https://togithub.com/Automattic/mongoose/issues/9014) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(faq): remove faq ipv6 [#9004](https://togithub.com/Automattic/mongoose/issues/9004) - docs: add note about throwing error only after validation and fix broken reference to api/CastError [#8993](https://togithub.com/Automattic/mongoose/issues/8993) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: fix typos in documents.pug [#9005](https://togithub.com/Automattic/mongoose/issues/9005) [dandv](https://togithub.com/dandv) ### [`v5.9.14`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5914--2020-05-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.13...5.9.14) =================== - fix(cursor): add index as second parameter to eachAsync callback [#8972](https://togithub.com/Automattic/mongoose/issues/8972) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(query): cast filter according to discriminator schema if discriminator key in filter [#8881](https://togithub.com/Automattic/mongoose/issues/8881) - fix(model): fix throwing error when populating virtual path defined on child discriminator [#8924](https://togithub.com/Automattic/mongoose/issues/8924) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(errors): handle case when user has make `Error.prototype.toJSON` read only [#8986](https://togithub.com/Automattic/mongoose/issues/8986) [osher](https://togithub.com/osher) - fix(model): add `kind` to cast errors thrown by query execution [#8953](https://togithub.com/Automattic/mongoose/issues/8953) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(update): use child schema strict on single nested updates if useNestedStrict not set [#8922](https://togithub.com/Automattic/mongoose/issues/8922) - docs(model): improve `save()` docs [#8956](https://togithub.com/Automattic/mongoose/issues/8956) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: add immutable type to Schema Types [#8987](https://togithub.com/Automattic/mongoose/issues/8987) [Andrew5569](https://togithub.com/Andrew5569) - docs: sort schema reserved keys in documentation [#8966](https://togithub.com/Automattic/mongoose/issues/8966) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) ### [`v5.9.13`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5913--2020-05-08) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.12...5.9.13) =================== - fix(schema): mark correct path as modified when setting a path underneath a nested array of documents [#8926](https://togithub.com/Automattic/mongoose/issues/8926) - fix(query): Query#select({ field: false }) should not overwrite schema selection options [#8929](https://togithub.com/Automattic/mongoose/issues/8929) [#8923](https://togithub.com/Automattic/mongoose/issues/8923) - fix(update): handle immutable properties are ignored in bulk upserts [#8952](https://togithub.com/Automattic/mongoose/issues/8952) [philippejer](https://togithub.com/philippejer) - docs(browser): add back sample webpack config [#8890](https://togithub.com/Automattic/mongoose/issues/8890) - docs(faq): fix broken reference in limit vs perDocumentLimit [#8937](https://togithub.com/Automattic/mongoose/issues/8937) ### [`v5.9.12`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5912--2020-05-04) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.11...5.9.12) =================== - fix(document): report cast error on array elements with array index instead of just being a cast error for the whole array [#8888](https://togithub.com/Automattic/mongoose/issues/8888) - fix(connection): throw more helpful error in case of IP whitelisting issue with Atlas [#8846](https://togithub.com/Automattic/mongoose/issues/8846) - fix(schema): throw error on schema with reserved key with type of object [#8869](https://togithub.com/Automattic/mongoose/issues/8869) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(connection): inherit config for useDB from default connection [#8267](https://togithub.com/Automattic/mongoose/issues/8267) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(query): set mongodb options for `distinct()` [#8906](https://togithub.com/Automattic/mongoose/issues/8906) [clhuang](https://togithub.com/clhuang) - fix(schema): allow adding descending indexes on schema [#8895](https://togithub.com/Automattic/mongoose/issues/8895) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(document): set defaults if setting nested path to empty object with `minimize: false` [#8829](https://togithub.com/Automattic/mongoose/issues/8829) - fix(populate): check discriminator existence before accessing schema in getModelsMapForPopulate [#8837](https://togithub.com/Automattic/mongoose/issues/8837) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: fix broken references to Mongoose#Document API, and prefer mongoose.model(...) over Document#model(...) [#8914](https://togithub.com/Automattic/mongoose/issues/8914) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(model): adds options.limit to Model.insertMany(...) [#8864](https://togithub.com/Automattic/mongoose/issues/8864) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: add flattenMaps and aliases to Document#toObject() [#8901](https://togithub.com/Automattic/mongoose/issues/8901) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(model): add options.overwrite to findOneAndUpdate [#8865](https://togithub.com/Automattic/mongoose/issues/8865) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(populate+faq): separate limit-vs-perDocumentLimit into its own section, add FAQ for populate and limit [#8917](https://togithub.com/Automattic/mongoose/issues/8917) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) ### [`v5.9.11`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5911--2020-04-30) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.10...5.9.11) =================== - fix: upgrade mongodb driver -> 3.5.7 [#8842](https://togithub.com/Automattic/mongoose/issues/8842) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix: validate nested paths on Model.validate(...) [#8848](https://togithub.com/Automattic/mongoose/issues/8848) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(populate): make doc.execPopulate(options) a shorthand for doc.populate(options).execPopulate() [#8840](https://togithub.com/Automattic/mongoose/issues/8840) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(model): return validation errors when all docs are invalid & rawResult set [#8853](https://togithub.com/Automattic/mongoose/issues/8853) [tusharf5](https://togithub.com/tusharf5) - fix(schemaType): treat select: null or select: undefined as not specified [#8850](https://togithub.com/Automattic/mongoose/issues/8850) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix: fix stream close event listener being called multiple times in Node 14 [#8835](https://togithub.com/Automattic/mongoose/issues/8835) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(populate): handle `clone` with `lean` when setting a path to `null` [#8807](https://togithub.com/Automattic/mongoose/issues/8807) - docs(faq): clarify setting paths under document arrays with `markModified()` [#8854](https://togithub.com/Automattic/mongoose/issues/8854) - docs: fix race condition in creating connection for lambda [#8845](https://togithub.com/Automattic/mongoose/issues/8845) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: add options.path for Model.populate(...) [#8833](https://togithub.com/Automattic/mongoose/issues/8833) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: use ES6 classes for custom schema type example [#8802](https://togithub.com/Automattic/mongoose/issues/8802) ### [`v5.9.10`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5910--2020-04-20) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.9...5.9.10) =================== - fix: upgrade mongodb -> 3.5.6, bson -> 1.1.4 [#8719](https://togithub.com/Automattic/mongoose/issues/8719) - fix(document): avoid calling `$set()` on object keys if object path isn't in schema [#8751](https://togithub.com/Automattic/mongoose/issues/8751) - fix(timestamps): handle timestamps on doubly nested subdocuments [#8799](https://togithub.com/Automattic/mongoose/issues/8799) - fix(schematype): throw error if default is set to a schema instance [#8751](https://togithub.com/Automattic/mongoose/issues/8751) - fix: handle $elemMatch projection with `select: false` in schema [#8818](https://togithub.com/Automattic/mongoose/issues/8818) [#8806](https://togithub.com/Automattic/mongoose/issues/8806) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: make FAQ questions more linkable [#8825](https://togithub.com/Automattic/mongoose/issues/8825) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(validation): use `init()` as opposed to `once('index')` in `unique` example [#8816](https://togithub.com/Automattic/mongoose/issues/8816) - docs: clarify `insertMany()` return value [#8820](https://togithub.com/Automattic/mongoose/issues/8820) [dandv](https://togithub.com/dandv) - docs(populate+query): fix typos [#8793](https://togithub.com/Automattic/mongoose/issues/8793) [#8794](https://togithub.com/Automattic/mongoose/issues/8794) [dandv](https://togithub.com/dandv) - docs(model): document skipId parameter [#8791](https://togithub.com/Automattic/mongoose/issues/8791) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) ### [`v5.9.9`](https://togithub.com/Automattic/mongoose/blob/master/History.md#599--2020-04-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.7...5.9.9) ================== - fix(model): make Model.bulkWrite accept `strict` option [#8782](https://togithub.com/Automattic/mongoose/issues/8782) [#8788](https://togithub.com/Automattic/mongoose/issues/8788) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(virtual): make populated virtual getter return value when it is passed in [#8775](https://togithub.com/Automattic/mongoose/issues/8775) [#8774](https://togithub.com/Automattic/mongoose/issues/8774) [makinde](https://togithub.com/makinde) - fix(document): handle validating document array whose docs contain maps and nested paths [#8767](https://togithub.com/Automattic/mongoose/issues/8767) - fix(document): skip discriminator key when overwriting a document [#8765](https://togithub.com/Automattic/mongoose/issues/8765) - fix(populate): support `clone` option with `lean` [#8761](https://togithub.com/Automattic/mongoose/issues/8761) [#8760](https://togithub.com/Automattic/mongoose/issues/8760) - docs(transactions): use `endSession()` in all transactions examples [#8741](https://togithub.com/Automattic/mongoose/issues/8741) - docs(queries): expand streaming section to include async iterators, cursor timeouts, and sesssion idle timeouts [#8720](https://togithub.com/Automattic/mongoose/issues/8720) - docs(model+query+findoneandupdate): add docs for `returnOriginal` option [#8766](https://togithub.com/Automattic/mongoose/issues/8766) - docs(model): fix punctuation [#8788](https://togithub.com/Automattic/mongoose/issues/8788) [dandv](https://togithub.com/dandv) - docs: fix typos [#8780](https://togithub.com/Automattic/mongoose/issues/8780) [#8799](https://togithub.com/Automattic/mongoose/issues/8799) [dandv](https://togithub.com/dandv) ### [`v5.9.7`](https://togithub.com/Automattic/mongoose/blob/master/History.md#597--2020-03-30) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.6...5.9.7) ================== - fix(map): avoid infinite loop when setting a map of documents to a document copied using spread operator [#8722](https://togithub.com/Automattic/mongoose/issues/8722) - fix(query): clean stack trace for filter cast errors so they include the calling file [#8691](https://togithub.com/Automattic/mongoose/issues/8691) - fix(model): make bulkWrite updates error if `strict` and `upsert` are set and `filter` contains a non-schema path [#8698](https://togithub.com/Automattic/mongoose/issues/8698) - fix(cast): make internal `castToNumber()` allow undefined [#8725](https://togithub.com/Automattic/mongoose/issues/8725) [p3x-robot](https://togithub.com/p3x-robot) ### [`v5.9.6`](https://togithub.com/Automattic/mongoose/blob/master/History.md#596--2020-03-23) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.5...5.9.6) ================== - fix(document): allow saving document with nested document array after setting `nestedArr.0` [#8689](https://togithub.com/Automattic/mongoose/issues/8689) - docs(connections): expand section about multiple connections to describe patterns for exporting schemas [#8679](https://togithub.com/Automattic/mongoose/issues/8679) - docs(populate): add note about `execPopulate()` to "populate an existing document" section [#8671](https://togithub.com/Automattic/mongoose/issues/8671) [#8275](https://togithub.com/Automattic/mongoose/issues/8275) - docs: fix broken links [#8690](https://togithub.com/Automattic/mongoose/issues/8690) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(guide): fix typos [#8704](https://togithub.com/Automattic/mongoose/issues/8704) [MateRyze](https://togithub.com/MateRyze) - docs(guide): fix minor typo [#8683](https://togithub.com/Automattic/mongoose/issues/8683) [pkellz](https://togithub.com/pkellz) ### [`v5.9.5`](https://togithub.com/Automattic/mongoose/blob/master/History.md#595--2020-03-16) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.4...5.9.5) ================== - fix: upgrade mongodb driver -> 3.5.5 [#8667](https://togithub.com/Automattic/mongoose/issues/8667) [#8664](https://togithub.com/Automattic/mongoose/issues/8664) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(connection): emit "disconnected" after losing connectivity to every member of a replica set with `useUnifiedTopology: true` [#8643](https://togithub.com/Automattic/mongoose/issues/8643) - fix(array): allow calling `slice()` after `push()` [#8668](https://togithub.com/Automattic/mongoose/issues/8668) [#8655](https://togithub.com/Automattic/mongoose/issues/8655) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(map): avoid marking map as modified if setting `key` to the same value [#8652](https://togithub.com/Automattic/mongoose/issues/8652) - fix(updateValidators): don't run `Mixed` update validator on dotted path underneath mixed type [#8659](https://togithub.com/Automattic/mongoose/issues/8659) - fix(populate): ensure top-level `limit` applies if one document being populated has more than `limit` results [#8657](https://togithub.com/Automattic/mongoose/issues/8657) - fix(populate): throw error if both `limit` and `perDocumentLimit` are set [#8661](https://togithub.com/Automattic/mongoose/issues/8661) [#8658](https://togithub.com/Automattic/mongoose/issues/8658) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(findOneAndUpdate): add a section about the `rawResult` option [#8662](https://togithub.com/Automattic/mongoose/issues/8662) - docs(guide): add section about `loadClass()` [#8623](https://togithub.com/Automattic/mongoose/issues/8623) - docs(query): improve `Query#populate()` example to clarify that `sort` doesn't affect the original result's order [#8647](https://togithub.com/Automattic/mongoose/issues/8647) ### [`v5.9.4`](https://togithub.com/Automattic/mongoose/blob/master/History.md#594--2020-03-09) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.3...5.9.4) ================== - fix(document): allow `new Model(doc)` to set immutable properties when doc is a mongoose document [#8642](https://togithub.com/Automattic/mongoose/issues/8642) - fix(array): make sure you can call `unshift()` after `slice()` [#8482](https://togithub.com/Automattic/mongoose/issues/8482) - fix(schema): propagate `typePojoToMixed` to implicitly created arrays [#8627](https://togithub.com/Automattic/mongoose/issues/8627) - fix(schema): also propagate `typePojoToMixed` option to schemas implicitly created because of `typePojoToMixed` [#8627](https://togithub.com/Automattic/mongoose/issues/8627) - fix(model): support passing `background` option to `syncIndexes()` [#8645](https://togithub.com/Automattic/mongoose/issues/8645) - docs(schema): add a section about the `_id` path in schemas [#8625](https://togithub.com/Automattic/mongoose/issues/8625) - docs(virtualtype+populate): document using `match` with virtual populate [#8616](https://togithub.com/Automattic/mongoose/issues/8616) - docs(guide): fix typo [#8648](https://togithub.com/Automattic/mongoose/issues/8648) [sauzy34](https://togithub.com/sauzy34) ### [`v5.9.3`](https://togithub.com/Automattic/mongoose/blob/master/History.md#593--2020-03-02) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.2...5.9.3) ================== - fix: upgrade mongodb driver -> 3.5.4 [#8620](https://togithub.com/Automattic/mongoose/issues/8620) - fix(document): set subpath defaults when overwriting single nested subdoc [#8603](https://togithub.com/Automattic/mongoose/issues/8603) - fix(document): make calling `validate()` with single nested subpath only validate that single nested subpath [#8626](https://togithub.com/Automattic/mongoose/issues/8626) - fix(browser): make `mongoose.model()` return a class in the browser to allow hydrating populated data in the browser [#8605](https://togithub.com/Automattic/mongoose/issues/8605) - fix(model): make `syncIndexes()` and `cleanIndexes()` drop compound indexes with `_id` that aren't in the schema [#8559](https://togithub.com/Automattic/mongoose/issues/8559) - docs(connection+index): add warnings to explain that bufferMaxEntries does nothing with `useUnifiedTopology` [#8604](https://togithub.com/Automattic/mongoose/issues/8604) - docs(document+model+query): add `options.timestamps` parameter docs to `findOneAndUpdate()` and `findByIdAndUpdate()` [#8619](https://togithub.com/Automattic/mongoose/issues/8619) - docs: fix out of date links to tumblr [#8599](https://togithub.com/Automattic/mongoose/issues/8599) ### [`v5.9.2`](https://togithub.com/Automattic/mongoose/blob/master/History.md#592--2020-02-21) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.1...5.9.2) ================== - fix(model): add discriminator key to bulkWrite filters [#8590](https://togithub.com/Automattic/mongoose/issues/8590) - fix(document): when setting nested array path to non-nested array, wrap values top-down rather than bottom up when possible [#8544](https://togithub.com/Automattic/mongoose/issues/8544) - fix(document): dont leave nested key as undefined when setting nested key to empty object with minimize [#8565](https://togithub.com/Automattic/mongoose/issues/8565) - fix(document): avoid throwing error if setting path to Mongoose document with nullish `_doc` [#8565](https://togithub.com/Automattic/mongoose/issues/8565) - fix(update): handle Binary type correctly with `runValidators` [#8580](https://togithub.com/Automattic/mongoose/issues/8580) - fix(query): run `deleteOne` hooks only on `Document#deleteOne()` when setting `options.document = true` for `Schema#pre()` [#8555](https://togithub.com/Automattic/mongoose/issues/8555) - fix(document): allow calling `validate()` in post validate hook without causing parallel validation error [#8597](https://togithub.com/Automattic/mongoose/issues/8597) - fix(virtualtype): correctly copy options when cloning [#8587](https://togithub.com/Automattic/mongoose/issues/8587) - fix(collection): skip creating capped collection if `autoCreate` set to `false` [#8566](https://togithub.com/Automattic/mongoose/issues/8566) - docs(middleware): clarify that updateOne and deleteOne hooks are query middleware by default, not document middleware [#8581](https://togithub.com/Automattic/mongoose/issues/8581) - docs(aggregate): clarify that `Aggregate#unwind()` can take object parameters as well as strings [#8594](https://togithub.com/Automattic/mongoose/issues/8594) ### [`v5.9.1`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5918--2020-06-05) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.9.0...5.9.1) =================== - fix: improve atlas error in the event of incorrect password [#9095](https://togithub.com/Automattic/mongoose/issues/9095) - docs: add edit link for all docs pages [#9058](https://togithub.com/Automattic/mongoose/issues/9058) - fix(document): allow accessing `$locals` when initializing document [#9099](https://togithub.com/Automattic/mongoose/issues/9099) [#9098](https://togithub.com/Automattic/mongoose/issues/9098) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(query): make `setDefaultsOnInsert` a mongoose option so it doesn't end up in debug output [#9086](https://togithub.com/Automattic/mongoose/issues/9086) - docs(connection+index): add serverSelectionTimeoutMS and heartbeatFrequencyMS to `connect()` and `openUri()` options [#9071](https://togithub.com/Automattic/mongoose/issues/9071) - docs(geojson): add notes about geojson 2dsphere indexes [#9044](https://togithub.com/Automattic/mongoose/issues/9044) - docs: make active page bold in navbar [#9062](https://togithub.com/Automattic/mongoose/issues/9062) - docs: correct a typo in a code snippet [#9089](https://togithub.com/Automattic/mongoose/issues/9089) [Elvis-Sarfo](https://togithub.com/Elvis-Sarfo) ### [`v5.9.0`](https://togithub.com/Automattic/mongoose/blob/master/History.md#590--2020-02-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.13...5.9.0) ================== - fix: upgrade to MongoDB driver 3.5 [#8520](https://togithub.com/Automattic/mongoose/issues/8520) [#8563](https://togithub.com/Automattic/mongoose/issues/8563) - feat(schematype): support setting default options for schema type (`trim` on all strings, etc.) [#8487](https://togithub.com/Automattic/mongoose/issues/8487) - feat(populate): add `perDocumentLimit` option that limits per document in `find()` result, rather than across all documents [#7318](https://togithub.com/Automattic/mongoose/issues/7318) - feat(schematype): enable setting `transform` option on individual schematypes [#8403](https://togithub.com/Automattic/mongoose/issues/8403) - feat(timestamps): allow setting `currentTime` option for setting custom function to get the current time [#3957](https://togithub.com/Automattic/mongoose/issues/3957) - feat(connection): add `Connection#watch()` to watch for changes on an entire database [#8425](https://togithub.com/Automattic/mongoose/issues/8425) - feat(document): add `Document#$op` property to make it easier to tell what operation is running in middleware [#8439](https://togithub.com/Automattic/mongoose/issues/8439) - feat(populate): support `limit` as top-level populate option [#8445](https://togithub.com/Automattic/mongoose/issues/8445) ### [`v5.8.13`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5813--2020-02-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.12...5.8.13) =================== - fix(populate): use safe get to avoid crash if schematype doesn't have options [#8586](https://togithub.com/Automattic/mongoose/issues/8586) ### [`v5.8.12`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5812--2020-02-12) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.11...5.8.12) =================== - fix(query): correctly cast dbref `$id` with `$elemMatch` [#8577](https://togithub.com/Automattic/mongoose/issues/8577) - fix(populate): handle populating when some embedded discriminator schemas have `refPath` but none of the subdocs have `refPath` [#8553](https://togithub.com/Automattic/mongoose/issues/8553) - docs: add useUnifiedTopology to homepage example [#8558](https://togithub.com/Automattic/mongoose/issues/8558) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - refactor(utils): moving promiseOrCallback to helpers/promiseOrCallback [#8573](https://togithub.com/Automattic/mongoose/issues/8573) [hugosenari](https://togithub.com/hugosenari) ### [`v5.8.11`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5811--2020-01-31) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.10...5.8.11) =================== - fix(document): allow calling `validate()` multiple times in parallel on subdocs to avoid errors if Mongoose double-validates [taxilian](https://togithub.com/taxilian) [#8548](https://togithub.com/Automattic/mongoose/issues/8548) [#8539](https://togithub.com/Automattic/mongoose/issues/8539) - fix(connection): allow calling initial `mongoose.connect()` after connection helpers on the same tick [#8534](https://togithub.com/Automattic/mongoose/issues/8534) - fix(connection): throw helpful error when callback param to `mongoose.connect()` or `mongoose.createConnection()` is not a function [#8556](https://togithub.com/Automattic/mongoose/issues/8556) - fix(drivers): avoid unnecessary caught error when importing [#8528](https://togithub.com/Automattic/mongoose/issues/8528) - fix(discriminator): remove unnecessary `utils.merge()` [samgladstone](https://togithub.com/samgladstone) [#8542](https://togithub.com/Automattic/mongoose/issues/8542) - docs: add "built with mongoose" page [#8540](https://togithub.com/Automattic/mongoose/issues/8540) ### [`v5.8.10`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5810--2020-01-27) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.9...5.8.10) =================== - perf(document): improve performance of document creation by skipping unnecessary split() calls [#8533](https://togithub.com/Automattic/mongoose/issues/8533) [igrunert-atlassian](https://togithub.com/igrunert-atlassian) - fix(document): only call validate once for deeply nested subdocuments [#8532](https://togithub.com/Automattic/mongoose/issues/8532) [#8531](https://togithub.com/Automattic/mongoose/issues/8531) [taxilian](https://togithub.com/taxilian) - fix(document): create document array defaults in forward order, not reverse [#8514](https://togithub.com/Automattic/mongoose/issues/8514) - fix(document): allow function as message for date min/max validator [#8512](https://togithub.com/Automattic/mongoose/issues/8512) - fix(populate): don't try to populate embedded discriminator that has populated path but no `refPath` [#8527](https://togithub.com/Automattic/mongoose/issues/8527) - fix(document): plugins from base schema when creating a discriminator [#8536](https://togithub.com/Automattic/mongoose/issues/8536) [samgladstone](https://togithub.com/samgladstone) - fix(document): ensure parent and ownerDocument are set for subdocs in document array defaults [#8509](https://togithub.com/Automattic/mongoose/issues/8509) - fix(document): dont set undefined keys to null if minimize is false [#8504](https://togithub.com/Automattic/mongoose/issues/8504) - fix(update): bump timestamps when using update aggregation pipelines [#8524](https://togithub.com/Automattic/mongoose/issues/8524) - fix(model): ensure `cleanIndexes()` drops indexes with different collations [#8521](https://togithub.com/Automattic/mongoose/issues/8521) - docs(model): document `insertMany` `lean` option [#8522](https://togithub.com/Automattic/mongoose/issues/8522) - docs(connections): document `authSource` option [#8517](https://togithub.com/Automattic/mongoose/issues/8517) ### [`v5.8.9`](https://togithub.com/Automattic/mongoose/blob/master/History.md#589--2020-01-17) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.7...5.8.9) ================== - fix(populate): skip populating embedded discriminator array values that don't have a `refPath` [#8499](https://togithub.com/Automattic/mongoose/issues/8499) - docs(queries): clarify when to use queries versus aggregations [#8494](https://togithub.com/Automattic/mongoose/issues/8494) ### [`v5.8.7`](https://togithub.com/Automattic/mongoose/blob/master/History.md#587--2020-01-10) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.6...5.8.7) ================== - fix(documentarray): modify ownerDocument when setting doc array to a doc array thats part of another document [#8479](https://togithub.com/Automattic/mongoose/issues/8479) - fix(document): ensure that you can call `splice()` after `slice()` on an array [#8482](https://togithub.com/Automattic/mongoose/issues/8482) - docs(populate): improve cross-db populate docs to include model refs [#8497](https://togithub.com/Automattic/mongoose/issues/8497) ### [`v5.8.6`](https://togithub.com/Automattic/mongoose/blob/master/History.md#586--2020-01-07) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.5...5.8.6) ==================== - chore: merge changes from 4.13.20 and override mistaken publish to latest tag ### [`v5.8.5`](https://togithub.com/Automattic/mongoose/blob/master/History.md#585--2020-01-06) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.4...5.8.5) ================== - fix(document): throw error when running `validate()` multiple times on the same document [#8468](https://togithub.com/Automattic/mongoose/issues/8468) - fix(model): ensure deleteOne() and deleteMany() set discriminator filter even if no conditions passed [#8471](https://togithub.com/Automattic/mongoose/issues/8471) - fix(document): allow pre('validate') hooks to throw errors with `name = 'ValidationError'` [#8466](https://togithub.com/Automattic/mongoose/issues/8466) - fix(update): move top level $set of immutable properties to $setOnInsert so upserting with immutable properties actually sets the property [#8467](https://togithub.com/Automattic/mongoose/issues/8467) - fix(document): avoid double-running validators on single nested subdocs within single nested subdocs [#8468](https://togithub.com/Automattic/mongoose/issues/8468) - fix(populate): support top-level match option for virtual populate [#8475](https://togithub.com/Automattic/mongoose/issues/8475) - fix(model): avoid applying skip when populating virtual with count [#8476](https://togithub.com/Automattic/mongoose/issues/8476) ### [`v5.8.4`](https://togithub.com/Automattic/mongoose/blob/master/History.md#584--2020-01-02) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.3...5.8.4) ================== - fix(populate): ensure populate virtual gets set to empty array if `localField` is undefined in the database [#8455](https://togithub.com/Automattic/mongoose/issues/8455) - fix(connection): wrap `mongoose.connect()` server selection timeouts in MongooseTimeoutError for more readable stack traces [#8451](https://togithub.com/Automattic/mongoose/issues/8451) - fix(populate): allow deselecting `foreignField` from projection by prefixing with `-` [#8460](https://togithub.com/Automattic/mongoose/issues/8460) - fix(populate): support embedded discriminators with `refPath` when not all discriminator schemas have `refPath` [#8452](https://togithub.com/Automattic/mongoose/issues/8452) - fix(array): allow defining `enum` on array if an array of numbers [#8449](https://togithub.com/Automattic/mongoose/issues/8449) ### [`v5.8.3`](https://togithub.com/Automattic/mongoose/blob/master/History.md#583--2019-12-23) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.2...5.8.3) ================== - fix: upgrade mongodb -> 3.4.1 [#8430](https://togithub.com/Automattic/mongoose/issues/8430) [jaschaio](https://togithub.com/jaschaio) - fix(populate): don't add empty subdocument to array when populating path underneath a non-existent document array [#8432](https://togithub.com/Automattic/mongoose/issues/8432) - fix(schema): handle `_id` option for document array schematypes [#8450](https://togithub.com/Automattic/mongoose/issues/8450) - fix(update): call setters when updating mixed type [#8444](https://togithub.com/Automattic/mongoose/issues/8444) - docs(connections): add note about MongoTimeoutError.reason [#8402](https://togithub.com/Automattic/mongoose/issues/8402) ### [`v5.8.2`](https://togithub.com/Automattic/mongoose/blob/master/History.md#582--2019-12-20) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.1...5.8.2) ================== - fix(schema): copy `.add()`-ed paths when calling `.add()` with schema argument [#8429](https://togithub.com/Automattic/mongoose/issues/8429) - fix(cursor): pull schema-level readPreference when using `Query#cursor()` [#8421](https://togithub.com/Automattic/mongoose/issues/8421) - fix(cursor): wait for all promises to resolve if `parallel` is greater than number of documents [#8422](https://togithub.com/Automattic/mongoose/issues/8422) - fix(document): depopulate entire array when setting array path to a partially populated array [#8443](https://togithub.com/Automattic/mongoose/issues/8443) - fix: handle setDefaultsOnInsert with deeply nested subdocs [#8392](https://togithub.com/Automattic/mongoose/issues/8392) - fix(document): report `DocumentNotFoundError` if underlying document deleted but no changes made [#8428](https://togithub.com/Automattic/mongoose/issues/8428) [#8371](https://togithub.com/Automattic/mongoose/issues/8371) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(populate): clarify limitations of `limit` option for populate and suggest workaround [#8409](https://togithub.com/Automattic/mongoose/issues/8409) - docs(deprecations): explain which connection options are no longer relevant with useUnifiedTopology [#8411](https://togithub.com/Automattic/mongoose/issues/8411) - chore: allow browser build to be published [#8435](https://togithub.com/Automattic/mongoose/issues/8435) [#8427](https://togithub.com/Automattic/mongoose/issues/8427) [captaincaius](https://togithub.com/captaincaius) ### [`v5.8.1`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5813--2020-02-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.8.0...5.8.1) =================== - fix(populate): use safe get to avoid crash if schematype doesn't have options [#8586](https://togithub.com/Automattic/mongoose/issues/8586) ### [`v5.8.0`](https://togithub.com/Automattic/mongoose/blob/master/History.md#580--2019-12-09) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.7.14...5.8.0) ================== - feat: wrap server selection timeout errors in `MongooseTimeoutError` to retain original stack trace [#8259](https://togithub.com/Automattic/mongoose/issues/8259) - feat(model): add `Model.validate()` function that validates a POJO against the model's schema [#7587](https://togithub.com/Automattic/mongoose/issues/7587) - feat(schema): add `Schema#pick()` function to create a new schema with a picked subset of the original schema's paths [#8207](https://togithub.com/Automattic/mongoose/issues/8207) - feat(schema): add ability to change CastError message using `cast` option to SchemaType [#8300](https://togithub.com/Automattic/mongoose/issues/8300) - feat(schema): group indexes defined in schema path with the same name [#6499](https://togithub.com/Automattic/mongoose/issues/6499) - fix(model): build all indexes even if one index fails [#8185](https://togithub.com/Automattic/mongoose/issues/8185) [unusualbob](https://togithub.com/unusualbob) - feat(browser): pre-compile mongoose/browser [#8350](https://togithub.com/Automattic/mongoose/issues/8350) [captaincaius](https://togithub.com/captaincaius) - fix(connection): throw error when setting unsupported option [#8335](https://togithub.com/Automattic/mongoose/issues/8335) [#6899](https://togithub.com/Automattic/mongoose/issues/6899) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - feat(schema): support `enum` validator for number type [#8139](https://togithub.com/Automattic/mongoose/issues/8139) - feat(update): allow using MongoDB 4.2 update aggregation pipelines, with no Mongoose casting [#8225](https://togithub.com/Automattic/mongoose/issues/8225) - fix(update): make update validators run on all subpaths when setting a nested path, even omitted subpaths [#3587](https://togithub.com/Automattic/mongoose/issues/3587) - feat(schema): support setting `_id` as an option to single nested schema paths [#8137](https://togithub.com/Automattic/mongoose/issues/8137) - feat(query): add Query#mongooseOptions() function [#8296](https://togithub.com/Automattic/mongoose/issues/8296) - feat(array): make `MongooseArray#push()` support using `$position` [#4322](https://togithub.com/Automattic/mongoose/issues/4322) - feat(schema): make pojo paths optionally become subdoc instead of Mixed [#8228](https://togithub.com/Automattic/mongoose/issues/8228) [captaincaius](https://togithub.com/captaincaius) - feat(model): add Model.cleanIndexes() to drop non-schema indexes [#6676](https://togithub.com/Automattic/mongoose/issues/6676) - feat(document): make `updateOne()` document middleware pass `this` to post hooks [#8262](https://togithub.com/Automattic/mongoose/issues/8262) - feat(aggregate): run pre/post aggregate hooks on `explain()` [#5887](https://togithub.com/Automattic/mongoose/issues/5887) - docs(model+query): add `session` option to docs for findOneAndX() methods [#8396](https://togithub.com/Automattic/mongoose/issues/8396) ### [`v5.7.14`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5714--2019-12-06) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.7.13...5.7.14) =================== - fix(cursor): wait until all `eachAsync()` functions finish before resolving the promise [#8352](https://togithub.com/Automattic/mongoose/issues/8352) - fix(update): handle embedded discriminator paths when discriminator key is defined in the update [#8378](https://togithub.com/Automattic/mongoose/issues/8378) - fix(schematype): handle passing `message` function to `SchemaType#validate()` as positional arg [#8360](https://togithub.com/Automattic/mongoose/issues/8360) - fix(map): handle cloning a schema that has a map of subdocuments [#8357](https://togithub.com/Automattic/mongoose/issues/8357) - docs(schema): clarify that `uppercase`, `lowercase`, and `trim` options for SchemaString don't affect RegExp queries [#8333](https://togithub.com/Automattic/mongoose/issues/8333) ### [`v5.7.13`](https://togithub.com/Automattic/mongoose/blob/master/History.md#5713--2019-11-29) [Compare Source](https://togithub.com/Automattic/mongoose/compare/5.7.12...5.7.13) =================== - fix: upgrade mongodb driver -> 3.3.5 [#8383](https://togithub.com/Automattic/mongoose/issues/8383) - fix(model): catch the error when insertMany fails to initialize the document [#8365](https://togithub.com/Automattic/mongoose/issues/8365) [#8363](https://togithub.com/Automattic/mongoose/issues/8363) [Fonger](https://togithub.com/Fonger) - fix(schema): add array.$, array.$.$ subpaths for nested arrays [#6405](https://togithub.com/Automattic/mongoose/issues/6405) - docs(error): add more detail about the ValidatorError class, including properties [#8346](https://togithub.com/Automattic/mongoose/issues/8346) - docs(connection): document `Connection#models` property [#8314](https://togithub.com/Automattic/mongoose/issues/8314)Renovate configuration
:date: Schedule: At any time (no schedule defined).
:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.
:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
:no_bell: Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.