Automattic/mongoose
### [`v6.2.11`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6211--2022-04-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.10...6.2.11)
\===================
- fix(document): handle validation with triply nested document arrays [#11564](https://togithub.com/Automattic/mongoose/issues/11564)
- fix(query): skip applying string schema setters on $regex [#11426](https://togithub.com/Automattic/mongoose/issues/11426)
- fix: skip findOneAndReplace() validation if runValidators = false [#11559](https://togithub.com/Automattic/mongoose/issues/11559)
- fix(model): correctly handle schema-level collations in syncIndexes() [#7621](https://togithub.com/Automattic/mongoose/issues/7621)
- fix(types): correct populate query return type with lean [#11560](https://togithub.com/Automattic/mongoose/issues/11560) [mohammad0-0ahmad](https://togithub.com/mohammad0-0ahmad)
- fix(types): allow using { type: Mixed } as schema type definition for any path [#10900](https://togithub.com/Automattic/mongoose/issues/10900)
- docs: fix example on Schema.prototype.post() [#11648](https://togithub.com/Automattic/mongoose/issues/11648) [EmilienLeroy](https://togithub.com/EmilienLeroy)
- docs: fix typo in methods/index.js [#11651](https://togithub.com/Automattic/mongoose/issues/11651) [eltociear](https://togithub.com/eltociear)
### [`v6.2.10`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6210--2022-04-04)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.9...6.2.10)
\===================
- fix(types): improve lastErrorObject typing for rawResults [#11602](https://togithub.com/Automattic/mongoose/issues/11602) [simllll](https://togithub.com/simllll)
- docs(typescript): add note about deprecating extends Document [#11619](https://togithub.com/Automattic/mongoose/issues/11619) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: consistent syntax highlighting with upgraded highlight.js [#11579](https://togithub.com/Automattic/mongoose/issues/11579) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
### [`v6.2.9`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#629--2022-03-28)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.8...6.2.9)
\==================
- perf(document+model): make a few small optimizations [#11380](https://togithub.com/Automattic/mongoose/issues/11380)
- fix(types): improve populate return type [#11560](https://togithub.com/Automattic/mongoose/issues/11560) [mohammad0-0ahmad](https://togithub.com/mohammad0-0ahmad)
- fix(document): avoid marking paths as modified on subdocument defaults [#11528](https://togithub.com/Automattic/mongoose/issues/11528)
- docs(schema): add example to index `expires` option [#11557](https://togithub.com/Automattic/mongoose/issues/11557) [boly38](https://togithub.com/boly38)
- docs(model): add change stream docs [#11275](https://togithub.com/Automattic/mongoose/issues/11275)
- docs(lambda): update Lambda docs for Mongoose 6 [#11275](https://togithub.com/Automattic/mongoose/issues/11275)
- docs(connections): add note about connecting with X509 [#11333](https://togithub.com/Automattic/mongoose/issues/11333)
- docs(populate): fix incorrect path name in `refPath` example [#11565](https://togithub.com/Automattic/mongoose/issues/11565) [chandiwalaaadhar](https://togithub.com/chandiwalaaadhar)
### [`v6.2.8`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#628--2022-03-22)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.7...6.2.8)
\==================
- fix(document): handle casting array of spread docs [#11522](https://togithub.com/Automattic/mongoose/issues/11522)
- fix(document): avoid setting nested properties on top-level document when initing with strict: false [#11526](https://togithub.com/Automattic/mongoose/issues/11526)
- fix(document): correctly handle deeply nested subdocuments when getting paths to validate [#11501](https://togithub.com/Automattic/mongoose/issues/11501)
- fix(types): avoid making TInstanceMethods any by default leading to `this = any` in middleware [#11435](https://togithub.com/Automattic/mongoose/issues/11435)
- fix(types): allow defining array default if using Types.Array<> in document interface [#11391](https://togithub.com/Automattic/mongoose/issues/11391)
- docs(migrating_to\_6): describe breaking change in Mongoose 6 about default query populate model [#11289](https://togithub.com/Automattic/mongoose/issues/11289)
- docs(middleware): fix typo [#11537](https://togithub.com/Automattic/mongoose/issues/11537) [x1489](https://togithub.com/x1489)
### [`v6.2.7`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#627--2022-03-16)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.6...6.2.7)
\==================
- perf(document): avoid running validation on every array element if there's no validators to run [#11380](https://togithub.com/Automattic/mongoose/issues/11380)
- fix(cursor): correctly populate in batches when batchSize is set [#11509](https://togithub.com/Automattic/mongoose/issues/11509)
- fix(connection): avoid setting MongoClient on useDb() connections until after setting on base connection [#11445](https://togithub.com/Automattic/mongoose/issues/11445)
- fix(schema): throw more helpful error when using schema from a different version of Mongoose module [#10453](https://togithub.com/Automattic/mongoose/issues/10453)
- fix: add missing timeseries expiration handling [#11489](https://togithub.com/Automattic/mongoose/issues/11489) [#11229](https://togithub.com/Automattic/mongoose/issues/11229) [Uzlopak](https://togithub.com/Uzlopak)
- docs: correct Model.findOneAndReplace docs param naming [#11524](https://togithub.com/Automattic/mongoose/issues/11524) [anatolykopyl](https://togithub.com/anatolykopyl)
### [`v6.2.6`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#626--2022-03-11)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.5...6.2.6)
\==================
- fix(types): correct reference to cursor TypeScript bindings [#11513](https://togithub.com/Automattic/mongoose/issues/11513) [SimonHausdorf](https://togithub.com/SimonHausdorf)
- fix(types): allow calling Query.prototype.populate() with array of strings [#11518](https://togithub.com/Automattic/mongoose/issues/11518)
- fix(types): export and refactor types of PreMiddlewareFunction, PreSaveMiddlewareFunction, PostMiddlewareFunction, ErrorHandlingMiddlewareFunction [#11485](https://togithub.com/Automattic/mongoose/issues/11485) [Uzlopak](https://togithub.com/Uzlopak)
### [`v6.2.5`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#625--2022-03-09)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.4...6.2.5)
\==================
- fix(mongoose): add isObjectIdOrHexString() to better capture the most common use case for `isValidObjectId()` [#11419](https://togithub.com/Automattic/mongoose/issues/11419)
- fix(query): prevent modifying discriminator key in updates using operators other than `$set` [#11456](https://togithub.com/Automattic/mongoose/issues/11456)
- fix(populate+types): call foreignField functions with doc as 1st param, better typings for `localField` and `foreignField` functions [#11321](https://togithub.com/Automattic/mongoose/issues/11321)
- fix(populate): return an array when using populate count on an array localField [#11307](https://togithub.com/Automattic/mongoose/issues/11307)
- fix(query): avoid error when using $not with arrays [#11467](https://togithub.com/Automattic/mongoose/issues/11467)
- perf: only deep clone validators if necessary [#11412](https://togithub.com/Automattic/mongoose/issues/11412) [Uzlopak](https://togithub.com/Uzlopak)
- fix(types): rename definition files to lowercase to avoid typescript bug [#11469](https://togithub.com/Automattic/mongoose/issues/11469)
- fix(types): aggregate.sort() accepts a string but also `{ field: 'asc'|'ascending'|'desc'|'descending' }` [#11479](https://togithub.com/Automattic/mongoose/issues/11479) [simonbrunel](https://togithub.com/simonbrunel)
- fix(types): extract and refactor aggregationcursor and querycursor [#11488](https://togithub.com/Automattic/mongoose/issues/11488) [Uzlopak](https://togithub.com/Uzlopak)
- fix(types): extract and refactor schemaoptions [#11484](https://togithub.com/Automattic/mongoose/issues/11484) [Uzlopak](https://togithub.com/Uzlopak)
- fix(types): make first param to `Query.prototype.populate()` a string [#11475](https://togithub.com/Automattic/mongoose/issues/11475) [minhthinhls](https://togithub.com/minhthinhls)
- fix(types): improve type checking for doc arrays in schema definitions [#11241](https://togithub.com/Automattic/mongoose/issues/11241)
- docs: fix length comparaison in lean.test.js [#11493](https://togithub.com/Automattic/mongoose/issues/11493) [zazapeta](https://togithub.com/zazapeta)
- docs(timestamps): fix typo [#11481](https://togithub.com/Automattic/mongoose/issues/11481) [saibbyweb](https://togithub.com/saibbyweb)
- docs: fix broken link to rawResult [#11459](https://togithub.com/Automattic/mongoose/issues/11459) [chhiring90](https://togithub.com/chhiring90)
### [`v6.2.4`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#624--2022-02-28)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.3...6.2.4)
\==================
- fix(query): correctly return full deleteOne(), deleteMany() result [#11211](https://togithub.com/Automattic/mongoose/issues/11211)
- fix(query): handle update validators on deeply nested subdocuments [#11455](https://togithub.com/Automattic/mongoose/issues/11455) [#11394](https://togithub.com/Automattic/mongoose/issues/11394)
- fix(discriminator): handle modifying multiple nested paths underneath a discriminator [#11428](https://togithub.com/Automattic/mongoose/issues/11428)
- perf: improve isAsyncFunction [#11408](https://togithub.com/Automattic/mongoose/issues/11408) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): add typedefs for Schema `pick()` [#11448](https://togithub.com/Automattic/mongoose/issues/11448) [Moisei-Shkil](https://togithub.com/Moisei-Shkil)
- fix(index.d.ts): allow type override for distinct() [#11306](https://togithub.com/Automattic/mongoose/issues/11306)
- fix(index.d.ts): allow array of validators in schema definition [#11355](https://togithub.com/Automattic/mongoose/issues/11355)
- fix(index.d.ts): improve connection typings [#11418](https://togithub.com/Automattic/mongoose/issues/11418) [Uzlopak](https://togithub.com/Uzlopak)
- docs: add timestamps docs [#11336](https://togithub.com/Automattic/mongoose/issues/11336)
- docs(timestamps): explain how timestamps works under the hood [#11336](https://togithub.com/Automattic/mongoose/issues/11336)
- docs(migrating_to\_6): add model.exists breaking change returning doument instead of boolean [#11407](https://togithub.com/Automattic/mongoose/issues/11407) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs(index.d.ts): add docs for FilterQuery, UpdateQuery, and LeanDocument [#11457](https://togithub.com/Automattic/mongoose/issues/11457) [Moisei-Shkil](https://togithub.com/Moisei-Shkil)
### [`v6.2.3`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#623--2022-02-21)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.2...6.2.3)
\==================
- fix(model): avoid dropping base model indexes when using discriminators with `Connection.prototype.syncIndexes()` [#11424](https://togithub.com/Automattic/mongoose/issues/11424) [#11421](https://togithub.com/Automattic/mongoose/issues/11421) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(document): handle array defaults when selecting element underneath array [#11376](https://togithub.com/Automattic/mongoose/issues/11376)
- fix(populate): correctly handle depopulating populated subdocuments [#11436](https://togithub.com/Automattic/mongoose/issues/11436)
- fix(utils): improve deepEqual() handling for comparing objects with non-objects [#11417](https://togithub.com/Automattic/mongoose/issues/11417)
- fix(schema): allow declaring array of arrays using `[{ type: [String] }]` [#11252](https://togithub.com/Automattic/mongoose/issues/11252)
- perf: improve validation sync and async by replacing forEach with classic for loops [#11414](https://togithub.com/Automattic/mongoose/issues/11414) [Uzlopak](https://togithub.com/Uzlopak)
- perf: make hasDollarKeys faster [#11401](https://togithub.com/Automattic/mongoose/issues/11401) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): ValidationError `errors` only contains CastError or ValidationError [#11369](https://togithub.com/Automattic/mongoose/issues/11369) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): make InsertManyResult.insertedIds return an array of Types.ObjectId by default [#11197](https://togithub.com/Automattic/mongoose/issues/11197)
- fix(index.d.ts): allow pre('save') middleware with pre options [#11257](https://togithub.com/Automattic/mongoose/issues/11257)
- fix(index.d.ts): add `supressReservedKeysWarning` option to schema [#11439](https://togithub.com/Automattic/mongoose/issues/11439) [hiukky](https://togithub.com/hiukky)
- docs(connections): improve replica set hostname docs with correct error message and info about `err.reason.servers` [#11200](https://togithub.com/Automattic/mongoose/issues/11200)
- docs(populate): add virtual populate match option documentation [#11411](https://togithub.com/Automattic/mongoose/issues/11411) [remirobichet](https://togithub.com/remirobichet)
- docs(document): add note to API docs that flattenMaps defaults to `true` for `toJSON()` but not `toObject()` [#11213](https://togithub.com/Automattic/mongoose/issues/11213)
- docs(document+model): add populate option to populate() API docs [#11170](https://togithub.com/Automattic/mongoose/issues/11170)
- docs(migrating_to\_6): add additional info about removing omitUndefined [#11038](https://togithub.com/Automattic/mongoose/issues/11038)
- docs(migrating_to\_6): add model.exists breaking change returning doument instead of boolean [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
### [`v6.2.2`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#622--2022-02-16)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.1...6.2.2)
\==================
- fix: fix QueryCursor and AggregationCursor compatibility with Node v17.5 [#11381](https://togithub.com/Automattic/mongoose/issues/11381) [benjamingr](https://togithub.com/benjamingr)
- fix: better esm support, no necessity for setting allowSyntheticDefaultImports and esModuleInterop [#11343](https://togithub.com/Automattic/mongoose/issues/11343) [Uzlopak](https://togithub.com/Uzlopak)
- fix(model): apply projection parameter to hydrate() [#11375](https://togithub.com/Automattic/mongoose/issues/11375)
- fix: fix issue with creating arrays of length > 10000 [#11405](https://togithub.com/Automattic/mongoose/issues/11405) [Uzlopak](https://togithub.com/Uzlopak)
- fix(document): minimize single nested subdocs [#11247](https://togithub.com/Automattic/mongoose/issues/11247)
- fix(connection): handle reopening base connection with useDb() [#11240](https://togithub.com/Automattic/mongoose/issues/11240)
- perf: use property access instead of `get()` helper where possible [#11389](https://togithub.com/Automattic/mongoose/issues/11389) [Uzlopak](https://togithub.com/Uzlopak)
- fix: use `isArray()` instead of `instanceof Array` [#11393](https://togithub.com/Automattic/mongoose/issues/11393) [Uzlopak](https://togithub.com/Uzlopak)
- perf: improve performance of `cast$expr()` [#11388](https://togithub.com/Automattic/mongoose/issues/11388) [Uzlopak](https://togithub.com/Uzlopak)
- perf: remove `startsWith()` from `isOperator()` [#11400](https://togithub.com/Automattic/mongoose/issues/11400) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): extract `PipelineStage` into separate file [#11368](https://togithub.com/Automattic/mongoose/issues/11368) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): fix $search highlight path option type [#11373](https://togithub.com/Automattic/mongoose/issues/11373) [lmX2015](https://togithub.com/lmX2015)
- docs: update changelog file to CHANGELOG.md [#11365](https://togithub.com/Automattic/mongoose/issues/11365) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: fix broken links [#11388](https://togithub.com/Automattic/mongoose/issues/11388) [#11377](https://togithub.com/Automattic/mongoose/issues/11377) [saibbyweb](https://togithub.com/saibbyweb)
- docs: remove double determiners in connections docs [#11340](https://togithub.com/Automattic/mongoose/issues/11340) [Erma32](https://togithub.com/Erma32)
### [`v6.2.1`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6211--2022-04-13)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.0...6.2.1)
\===================
- fix(document): handle validation with triply nested document arrays [#11564](https://togithub.com/Automattic/mongoose/issues/11564)
- fix(query): skip applying string schema setters on $regex [#11426](https://togithub.com/Automattic/mongoose/issues/11426)
- fix: skip findOneAndReplace() validation if runValidators = false [#11559](https://togithub.com/Automattic/mongoose/issues/11559)
- fix(model): correctly handle schema-level collations in syncIndexes() [#7621](https://togithub.com/Automattic/mongoose/issues/7621)
- fix(types): correct populate query return type with lean [#11560](https://togithub.com/Automattic/mongoose/issues/11560) [mohammad0-0ahmad](https://togithub.com/mohammad0-0ahmad)
- fix(types): allow using { type: Mixed } as schema type definition for any path [#10900](https://togithub.com/Automattic/mongoose/issues/10900)
- docs: fix example on Schema.prototype.post() [#11648](https://togithub.com/Automattic/mongoose/issues/11648) [EmilienLeroy](https://togithub.com/EmilienLeroy)
- docs: fix typo in methods/index.js [#11651](https://togithub.com/Automattic/mongoose/issues/11651) [eltociear](https://togithub.com/eltociear)
### [`v6.2.0`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#620--2022-02-02)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.10...6.2.0)
\==================
- feat: upgrade MongoDB driver to 4.3.1
- feat(connection+mongoose): add support for continueOnError for syncIndexes [#11266](https://togithub.com/Automattic/mongoose/issues/11266) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- feat(query): cast literals in `$expr` where possible [#10663](https://togithub.com/Automattic/mongoose/issues/10663)
- feat(schema+mongoose): add pluginTags to allow applying global plugins to only schemas with matching tags [#9780](https://togithub.com/Automattic/mongoose/issues/9780)
- feat(discriminator): support overwriteModels:true to reuse discriminator names [#11244](https://togithub.com/Automattic/mongoose/issues/11244) [#10931](https://togithub.com/Automattic/mongoose/issues/10931) [IslandRhythms](https://togithub.com/IslandRhythms)
- feat(index.d.ts): add DocType generic param to Model functions that return queries to better support projections [#11156](https://togithub.com/Automattic/mongoose/issues/11156)
- feat(error): export MongooseServerSelectionError [#11202](https://togithub.com/Automattic/mongoose/issues/11202)
- feat(schematype): add validators, path, isRequired to public API and TypeScript types [#11139](https://togithub.com/Automattic/mongoose/issues/11139)
- fix(model): make exists(...) return lean document with \_id or null instead of boolean [#11142](https://togithub.com/Automattic/mongoose/issues/11142) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(model): support storing versionKey in nested paths [#10980](https://togithub.com/Automattic/mongoose/issues/10980)
- fix(index.d.ts): add options to `bulkSave()` type def [#11201](https://togithub.com/Automattic/mongoose/issues/11201) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): better support for query projections [#11210](https://togithub.com/Automattic/mongoose/issues/11210) [EugeneKorshenko](https://togithub.com/EugeneKorshenko)
### [`v6.1.10`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6110--2022-02-01)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.9...6.1.10)
\===================
- fix(mongoose): correctly handle destructured isValidObjectId [#11304](https://togithub.com/Automattic/mongoose/issues/11304)
- fix(mongoose): defer to MongoDB driver isValid() for `isValidObjectId()` [#11227](https://togithub.com/Automattic/mongoose/issues/11227)
### [`v6.1.9`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#619--2022-01-31)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.8...6.1.9)
\==================
- fix(query): respect nested schema strict as default when casting query filters [#11291](https://togithub.com/Automattic/mongoose/issues/11291)
- fix(mongoose): make isValidObjectId() consistent with isValid(), make `ObjectId()` casting more flexible [#11209](https://togithub.com/Automattic/mongoose/issues/11209)
- fix(setDefaultsOnInsert): ignore defaults underneath maps [#11235](https://togithub.com/Automattic/mongoose/issues/11235)
- fix(query): avoid setting nested schema properties that are stripped out by strictQuery to undefined in query filter [#11291](https://togithub.com/Automattic/mongoose/issues/11291)
- fix: check for all flags in a regex deepequal [#11242](https://togithub.com/Automattic/mongoose/issues/11242) [Uzlopak](https://togithub.com/Uzlopak)
- fix: replace substr with substring [#11278](https://togithub.com/Automattic/mongoose/issues/11278) [Uzlopak](https://togithub.com/Uzlopak)
- docs: port for documentation testing in CONTRIBUTING.md [#11273](https://togithub.com/Automattic/mongoose/issues/11273) [Uzlopak](https://togithub.com/Uzlopak)
### [`v6.1.8`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#618--2022-01-24)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.7...6.1.8)
\==================
- fix(connection): stop leaking sessions in .transaction() [#11259](https://togithub.com/Automattic/mongoose/issues/11259) [#11256](https://togithub.com/Automattic/mongoose/issues/11256) [Uzlopak](https://togithub.com/Uzlopak)
- perf: remove sliced in favor of Array.prototype.slice() [#11238](https://togithub.com/Automattic/mongoose/issues/11238) [Uzlopak](https://togithub.com/Uzlopak)
- perf: improve setDottedPath [#11264](https://togithub.com/Automattic/mongoose/issues/11264) [Uzlopak](https://togithub.com/Uzlopak)
- fix(document): handle edge case where NestJS sets String.type = String, mixing up schema definitions [#11199](https://togithub.com/Automattic/mongoose/issues/11199)
- fix: remove obsolete code after upgrading to bson4 [#11265](https://togithub.com/Automattic/mongoose/issues/11265) [Uzlopak](https://togithub.com/Uzlopak)
- fix: remove util.isArray in favor of Array.isArray [#11234](https://togithub.com/Automattic/mongoose/issues/11234) [Uzlopak](https://togithub.com/Uzlopak)
- fix(index.d.ts): avoid UnpackedIntersection making `findOne().populate()` result non-nullable [#11041](https://togithub.com/Automattic/mongoose/issues/11041)
- docs(migration): add note to change default functions to schema [#11245](https://togithub.com/Automattic/mongoose/issues/11245) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- docs: updated docs and issue templates for new FAQs [#11171](https://togithub.com/Automattic/mongoose/issues/11171) [IslandRhythms](https://togithub.com/IslandRhythms)
- chore: fix casting benchmark [#11262](https://togithub.com/Automattic/mongoose/issues/11262) [Uzlopak](https://togithub.com/Uzlopak)
- chore: add mongodb-memory-server to test easier locally [#11255](https://togithub.com/Automattic/mongoose/issues/11255) [Uzlopak](https://togithub.com/Uzlopak)
- chore: fix testing tsconfig [#11243](https://togithub.com/Automattic/mongoose/issues/11243) [Uzlopak](https://togithub.com/Uzlopak)
- refactor: move utils.random to test folder [#11239](https://togithub.com/Automattic/mongoose/issues/11239) [Uzlopak](https://togithub.com/Uzlopak)
### [`v6.1.7`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#617--2022-01-17)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.6...6.1.7)
\==================
- fix(model): correct handling for $push on a nested array [#11108](https://togithub.com/Automattic/mongoose/issues/11108)
- fix(update): correctly apply timestamps to update pipelines [#11151](https://togithub.com/Automattic/mongoose/issues/11151)
- fix(document): correctly handle modifying array subdocument after setting array subdocument to itself [#11172](https://togithub.com/Automattic/mongoose/issues/11172)
- fix(index.d.ts): allow passing options to model() in place of removed `skipInit` [#11137](https://togithub.com/Automattic/mongoose/issues/11137)
- fix(aggregate): allow passing verbosity to Aggregate.prototype.explain() [#11144](https://togithub.com/Automattic/mongoose/issues/11144)
- fix(index.d.ts): avoid TypeScript inferring \_id as any type with HydratedDocument [#11085](https://togithub.com/Automattic/mongoose/issues/11085)
- docs: fix Node.js Driver compat link [#11214](https://togithub.com/Automattic/mongoose/issues/11214) [wesbos](https://togithub.com/wesbos)
- docs: remove extraneous backquote [#11204](https://togithub.com/Automattic/mongoose/issues/11204) [joebowbeer](https://togithub.com/joebowbeer)
### [`v6.1.6`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#616--2022-01-10)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.5...6.1.6)
\==================
- perf(document): delay creating document event emitter until used to improve memory usage, several small improvements to improve initing docs with large arrays [#10400](https://togithub.com/Automattic/mongoose/issues/10400)
- fix(model): avoid `bulkSave()` error when `versionKey: false` [#11186](https://togithub.com/Automattic/mongoose/issues/11186) [#11071](https://togithub.com/Automattic/mongoose/issues/11071) [IslandRhythms](https://togithub.com/IslandRhythms)
- fix(model): revert [#11079](https://togithub.com/Automattic/mongoose/issues/11079): `findByIdAndUpdate(undefined)` breaking change [#11149](https://togithub.com/Automattic/mongoose/issues/11149)
- fix(index.d.ts): support strings in deep populate [#11181](https://togithub.com/Automattic/mongoose/issues/11181) [ivalduan](https://togithub.com/ivalduan)
- fix(index.d.ts): rename map() -> transform() to line up with change in v6.0 [#11161](https://togithub.com/Automattic/mongoose/issues/11161)
- fix(index.d.ts): allow new Model(obj) for stricter type checks [#11148](https://togithub.com/Automattic/mongoose/issues/11148)
- fix(index.d.ts): make Schema.prototype.pre() and post() generics default to HydratedDocument [#11180](https://togithub.com/Automattic/mongoose/issues/11180)
- docs: improve autoCreate docs [#11116](https://togithub.com/Automattic/mongoose/issues/11116)
- docs(schematype): add missing parameter to example [#11185](https://togithub.com/Automattic/mongoose/issues/11185) [kerolloz](https://togithub.com/kerolloz)
- docs(connections): use updated link to list of MongoDB Node driver `connect()` options [#11184](https://togithub.com/Automattic/mongoose/issues/11184) [splinter](https://togithub.com/splinter)
- docs(aggregate): fix formatting [#11191](https://togithub.com/Automattic/mongoose/issues/11191) [enieber](https://togithub.com/enieber)
- docs: fix broken link [#11179](https://togithub.com/Automattic/mongoose/issues/11179) [khairnarsaurabh23](https://togithub.com/khairnarsaurabh23)
### [`v6.1.5`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#615--2022-01-04)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.4...6.1.5)
\==================
- perf(index.d.ts): simplify Schema typedef for query helpers and methods to significantly reduce TS compiler overhead [#10349](https://togithub.com/Automattic/mongoose/issues/10349)
- fix(document): allow populating deeply nested models as strings [#11168](https://togithub.com/Automattic/mongoose/issues/11168) [#11160](https://togithub.com/Automattic/mongoose/issues/11160) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez)
- fix(query): allow calling limit() and skip() with a string [#11017](https://togithub.com/Automattic/mongoose/issues/11017)
- fix(cursor): propery apply selected fields when loading discriminator docs with query cursor [#11130](https://togithub.com/Automattic/mongoose/issues/11130)
- fix(mongoose+connection): clone schema correctly when passing instance of another Mongoose instance's Schema to Connection.prototype.model() [#11047](https://togithub.com/Automattic/mongoose/issues/11047)
- fix(index.d.ts): handle primitives with FlattenMaps [#11117](https://togithub.com/Automattic/mongoose/issues/11117)
- fix(index.d.ts): enforce id on lean query result type [#11118](https://togithub.com/Automattic/mongoose/issues/11118)
- fix(index.d.ts): export facet stage type [#11150](https://togithub.com/Automattic/mongoose/issues/11150) [mhoc](https://togithub.com/mhoc)
- fix(index.d.ts): correct return type of projection method [#11176](https://togithub.com/Automattic/mongoose/issues/11176) [EugeneKorshenko](https://togithub.com/EugeneKorshenko)
- fix(index.d.ts): additional fix for `$group` pipeline stage [#11140](https://togithub.com/Automattic/mongoose/issues/11140) [#11067](https://togithub.com/Automattic/mongoose/issues/11067) [EugeneKorshenko](https://togithub.com/EugeneKorshenko)
- docs: update CONTRIBUTING.md for TS tests [#11164](https://togithub.com/Automattic/mongoose/issues/11164) [ahmedelshenawy25](https://togithub.com/ahmedelshenawy25)
- docs: use es6 object destructuring instead of regular dot operator for accessing value in object [#11147](https://togithub.com/Automattic/mongoose/issues/11147) [Shivaansh-Agarwal](https://togithub.com/Shivaansh-Agarwal)
### [`v6.1.4`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#614--2021-12-27)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.3...6.1.4)
\==================
- fix(document): handle save with undefined nested doc under subdoc [#11110](https://togithub.com/Automattic/mongoose/issues/11110)
- fix(document): allow manually populating subdocument refs with `create()` [#10856](https://togithub.com/Automattic/mongoose/issues/10856)
- fix(populate): handles refPath underneath map of subdocuments [#9359](https://togithub.com/Automattic/mongoose/issues/9359)
- fix(update): throw error when calling findByIdAndUpdate with undefined id [#11079](https://togithub.com/Automattic/mongoose/issues/11079) [gramliu](https://togithub.com/gramliu)
- fix(mongoose): export ConnectionStates [#11133](https://togithub.com/Automattic/mongoose/issues/11133) [orgads](https://togithub.com/orgads)
- fix(index.d.ts): unpack array when using generic type override with `populate()` [#11027](https://togithub.com/Automattic/mongoose/issues/11027)
- fix(index.d.ts): fix typings in Merge stage [#11132](https://togithub.com/Automattic/mongoose/issues/11132)
- fix(index.d.ts): PipelineStage.Merge interface definition is wrong [#11109](https://togithub.com/Automattic/mongoose/issues/11109)
- docs(typescript): add note about Schema.Types.ObjectId vs Types.ObjectId in document definition [#10949](https://togithub.com/Automattic/mongoose/issues/10949)
- docs(connection): clarify that "connected" and "open" are different [#10886](https://togithub.com/Automattic/mongoose/issues/10886)
- docs(populate): correct refPath example to not use on as a schema path name [#11113](https://togithub.com/Automattic/mongoose/issues/11113)
- docs: fix `strictQuery` example [#11135](https://togithub.com/Automattic/mongoose/issues/11135) [MontgomeryWatts](https://togithub.com/MontgomeryWatts)
### [`v6.1.3`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#613--2021-12-21)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.2...6.1.3)
\==================
- perf(populate): avoid duplicate model names when using refPath to avoid O(n^2) memory growth with number of array elements [#10983](https://togithub.com/Automattic/mongoose/issues/10983)
- fix(schema+model): cast paths marked with ref when hydrating [#11052](https://togithub.com/Automattic/mongoose/issues/11052)
- fix(schema): handle default function that returns null on document arrays [#11058](https://togithub.com/Automattic/mongoose/issues/11058)
- fix(document): clean modified paths when setting deeply nested subdocument [#11060](https://togithub.com/Automattic/mongoose/issues/11060)
- fix(populate): report full path when throwing strictPopulate error with deep populate [#10923](https://togithub.com/Automattic/mongoose/issues/10923)
- fix(connection): allow calling `setClient()` when disconnected [#11114](https://togithub.com/Automattic/mongoose/issues/11114) [hustxiaoc](https://togithub.com/hustxiaoc)
- fix(index.d.ts): fix typings in Group stage [#11124](https://togithub.com/Automattic/mongoose/issues/11124) [DavideViolante](https://togithub.com/DavideViolante)
- fix(index.d.ts): add Mongoose.prototype.trusted() function to type defs [#10957](https://togithub.com/Automattic/mongoose/issues/10957)
- fix(index.d.ts): allow use type string in $unset update with aggregation pipeline [#11107](https://togithub.com/Automattic/mongoose/issues/11107) [rpenido](https://togithub.com/rpenido)
- fix(index.d.ts) treat \_id like other fields in $project [#11102](https://togithub.com/Automattic/mongoose/issues/11102)
- docs(migrating_to\_6): add omitUndefined to Mongoose 6 migration guide [#10672](https://togithub.com/Automattic/mongoose/issues/10672)
- docs: add MongooseDocumentArray to API docs [#10998](https://togithub.com/Automattic/mongoose/issues/10998)
- docs: fix typo in model.js [#11121](https://togithub.com/Automattic/mongoose/issues/11121) [eltociear](https://togithub.com/eltociear)
- docs: fix typo in validation.md [#11103](https://togithub.com/Automattic/mongoose/issues/11103) [warlock1996](https://togithub.com/warlock1996)
### [`v6.1.2`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#612--2021-12-14)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.1...6.1.2)
\==================
- fix: upgrade mongodb driver to 4.2.2 [#11092](https://togithub.com/Automattic/mongoose/issues/11092) [lorand-horvath](https://togithub.com/lorand-horvath)
- fix(model): respect discriminators when calling Model.watch() [#11007](https://togithub.com/Automattic/mongoose/issues/11007)
- fix(populate): allow referencing parent connection models by name when using `useDb()` [#11003](https://togithub.com/Automattic/mongoose/issues/11003)
- fix(query): support options param to `Query.prototype.countDocuments()` [#11037](https://togithub.com/Automattic/mongoose/issues/11037)
- fix(query): correctly use awaitData instead of awaitdata in `Query.prototype.tailable()` [#10875](https://togithub.com/Automattic/mongoose/issues/10875)
- fix(index.d.ts): fix replaceRoot type [#11098](https://togithub.com/Automattic/mongoose/issues/11098) [alibehroozi](https://togithub.com/alibehroozi)
- fix(index.d.ts): add missing syncIndexes() definition to Mongoose global and Connection class [#11065](https://togithub.com/Automattic/mongoose/issues/11065)
- fix(index.d.ts): add boolean type for transform option [#11057](https://togithub.com/Automattic/mongoose/issues/11057) [AliYusuf95](https://togithub.com/AliYusuf95)
- docs(model.estimatedDocumentCount): add await into example to get value from the Query [#11044](https://togithub.com/Automattic/mongoose/issues/11044) [olecom](https://togithub.com/olecom)
- docs: fix broken build from awaitdata comment [#11096](https://togithub.com/Automattic/mongoose/issues/11096) [medolino](https://togithub.com/medolino)
- docs: correct Query.prototype.transform() docs [#11094](https://togithub.com/Automattic/mongoose/issues/11094) [medolino](https://togithub.com/medolino)
### [`v6.1.1`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6110--2022-02-01)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.0...6.1.1)
\===================
- fix(mongoose): correctly handle destructured isValidObjectId [#11304](https://togithub.com/Automattic/mongoose/issues/11304)
- fix(mongoose): defer to MongoDB driver isValid() for `isValidObjectId()` [#11227](https://togithub.com/Automattic/mongoose/issues/11227)
### [`v6.1.0`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#610--2021-12-07)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.15...6.1.0)
\==================
- feat(populate): support ref on subdocuments [#10856](https://togithub.com/Automattic/mongoose/issues/10856)
- feat(document): add `ownerDocument()` method to top-level document for consistency with subdocs [#10884](https://togithub.com/Automattic/mongoose/issues/10884) [IslandRhythms](https://togithub.com/IslandRhythms)
- fix: upgrade to mongodb driver 4.2.1 [#11032](https://togithub.com/Automattic/mongoose/issues/11032) [#10985](https://togithub.com/Automattic/mongoose/issues/10985) [lorand-horvath](https://togithub.com/lorand-horvath) [has-n](https://togithub.com/has-n)
- feat(schema): support `timeseries` option for MongoDB 5 time series collections support [#10611](https://togithub.com/Automattic/mongoose/issues/10611)
- feat(mongoose): add global `strictPopulate` option [#10694](https://togithub.com/Automattic/mongoose/issues/10694) [IslandRhythms](https://togithub.com/IslandRhythms)
- feat(mongoose+connection): add global `mongoose.syncIndexes()` and `Connection.prototype.syncIndexes()` [#10893](https://togithub.com/Automattic/mongoose/issues/10893) [IslandRhythms](https://togithub.com/IslandRhythms)
- feat(query): support removing fields from projections [#10630](https://togithub.com/Automattic/mongoose/issues/10630) [canac](https://togithub.com/canac)
- feat(aggregate): add unionWith method to aggregate [#10961](https://togithub.com/Automattic/mongoose/issues/10961) [saeidasadi](https://togithub.com/saeidasadi)
- fix(index.d.ts): types for aggregation pipeline stages [#10971](https://togithub.com/Automattic/mongoose/issues/10971) [jeremyben](https://togithub.com/jeremyben)
### [`v6.0.15`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6015--2021-12-06)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.14...6.0.15)
\===================
- fix(document): avoid overwriting schema methods when creating a new document with `new Model()` and `strict: false` [#11001](https://togithub.com/Automattic/mongoose/issues/11001)
- fix(document): avoid overwriting top-level document \_id with nested `_id` when `strict = false` [#10934](https://togithub.com/Automattic/mongoose/issues/10934)
- fix(collection): avoid double-calling callback on sync error [#10956](https://togithub.com/Automattic/mongoose/issues/10956)
- fix(connection): handle direct connection to uninitialized replica set that then becomes initialized [#10948](https://togithub.com/Automattic/mongoose/issues/10948)
- fix(index.d.ts): allow partial updates on subdocuments for defaults [#10947](https://togithub.com/Automattic/mongoose/issues/10947)
- fix(index.d.ts): handle buffer type in schema definitions [#11026](https://togithub.com/Automattic/mongoose/issues/11026)
### [`v6.0.14`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6014--2021-11-29)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.13...6.0.14)
\===================
- fix(document): catch errors in required functions [#10968](https://togithub.com/Automattic/mongoose/issues/10968)
- fix(connection): clone schema when passing a schema from a different copy of Mongoose to `Connection#model()` [#10904](https://togithub.com/Automattic/mongoose/issues/10904)
- fix(populate): set empty array \[] on virtual populate with no result [#10992](https://togithub.com/Automattic/mongoose/issues/10992)
- fix(query): handle orFail() with replaceOne() [#10963](https://togithub.com/Automattic/mongoose/issues/10963)
- fix(populate): use Model by default when using Model.populate() on a POJO [#10978](https://togithub.com/Automattic/mongoose/issues/10978)
- fix(document): throw VersionError if saving a document with version bump and document isn't found [#10974](https://togithub.com/Automattic/mongoose/issues/10974)
- fix(index.d.ts): make populate type param optional [#10989](https://togithub.com/Automattic/mongoose/issues/10989) [mohd-akram](https://togithub.com/mohd-akram)
- docs(migrating_to\_6): add a note about minimize and toObject() behavior change in v5.10.5 [#10827](https://togithub.com/Automattic/mongoose/issues/10827)
- docs: remove duplicate `path` in docs [#11020](https://togithub.com/Automattic/mongoose/issues/11020) [ItWorksOnMyMachine](https://togithub.com/ItWorksOnMyMachine)
- docs: fix typo in populate docs [#11015](https://togithub.com/Automattic/mongoose/issues/11015) [gavi-shandler](https://togithub.com/gavi-shandler)
- docs: fix typo in model.js [#10982](https://togithub.com/Automattic/mongoose/issues/10982) [eltociear](https://togithub.com/eltociear)
### [`v6.0.13`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6013--2021-11-15)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.12...6.0.13)
\===================
- fix(document): allows validating doc again if pre validate errors out [#10830](https://togithub.com/Automattic/mongoose/issues/10830)
- fix: upgrade to mongodb driver 4.1.4 [#10955](https://togithub.com/Automattic/mongoose/issues/10955) [mohd-akram](https://togithub.com/mohd-akram)
- fix(schema): handle functions with accidental type properties in schema definitions [#10807](https://togithub.com/Automattic/mongoose/issues/10807)
- fix(path): add check to avoid flattening dotted paths on Mongoose docs, improve error when flattening dotted paths causes conflicts [#10825](https://togithub.com/Automattic/mongoose/issues/10825)
- fix(index.d.ts): rename EnforceDocument -> HydratedDocument, export HydratedDocument for easier typing for users [#10843](https://togithub.com/Automattic/mongoose/issues/10843)
- fix(index.d.ts): handle maps in TypeScript schema definitions [#10838](https://togithub.com/Automattic/mongoose/issues/10838)
- fix(index.d.ts): add clone to query [#10943](https://togithub.com/Automattic/mongoose/issues/10943) [asportnoy](https://togithub.com/asportnoy)
- fix(index.d.ts): add strictQuery global option [#10933](https://togithub.com/Automattic/mongoose/issues/10933)
- fix(index.d.ts): add generic to allow overriding `Schema#clone()` return type [#10951](https://togithub.com/Automattic/mongoose/issues/10951) [StefanoA1](https://togithub.com/StefanoA1)
- docs(typescript): add quick guide to virtuals in TypeScript [#10754](https://togithub.com/Automattic/mongoose/issues/10754)
- docs(aggregate): remove exec() from AggregationCursor example, no longer correct for Mongoose 6 [#10862](https://togithub.com/Automattic/mongoose/issues/10862)
- docs(document.js): fix link leading to old github pages site [#10958](https://togithub.com/Automattic/mongoose/issues/10958) [PuneetGopinath](https://togithub.com/PuneetGopinath)
- docs: fixed typo in document.js [#10950](https://togithub.com/Automattic/mongoose/issues/10950) [Haosik](https://togithub.com/Haosik)
### [`v6.0.12`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6012--2021-10-21)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.11...6.0.12)
\===================
- fix(cursor): remove the logic for emitting close, rely on autoDestroy option for Node 12 support [#10906](https://togithub.com/Automattic/mongoose/issues/10906) [iovanom](https://togithub.com/iovanom)
- fix(map): support passing flattenMaps: false to Map toJSON(), make `toJSON()` flatten maps by default in TypeScript [#10872](https://togithub.com/Automattic/mongoose/issues/10872)
- fix: upgrade to mongodb driver 4.1.3 [#10911](https://togithub.com/Automattic/mongoose/issues/10911) [orgads](https://togithub.com/orgads)
- fix(index.d.ts): correct TS function signature for `SchemaType.prototype.set()` [#10799](https://togithub.com/Automattic/mongoose/issues/10799)
- fix(index.d.ts): support implicit $in in FilterQuery [#10826](https://togithub.com/Automattic/mongoose/issues/10826)
- fix(index.d.ts): More precise type for Schema.clone() [#10899](https://togithub.com/Automattic/mongoose/issues/10899) [coyotte508](https://togithub.com/coyotte508)
- fix(index.d.ts): add caster property to schema arrays and document arrays [#10865](https://togithub.com/Automattic/mongoose/issues/10865)
- docs: update `updateMany()` and `deleteMany()` docs to reflect new `matchedCount`, `modifiedCount`, `deletedCount` properties [#10908](https://togithub.com/Automattic/mongoose/issues/10908) [IslandRhythms](https://togithub.com/IslandRhythms)
- docs: fix broken links to populate virtuals [#10870](https://togithub.com/Automattic/mongoose/issues/10870) [IslandRhythms](https://togithub.com/IslandRhythms)
- docs: updated docs to have returnOriginal, removed new and returnDocument [#10887](https://togithub.com/Automattic/mongoose/issues/10887) [IslandRhythms](https://togithub.com/IslandRhythms)
### [`v6.0.11`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6011--2021-10-14)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.10...6.0.11)
\===================
- perf(index.d.ts): remove some unnecessary definitions, streamline some union types to reduce number of instantiations [#10349](https://togithub.com/Automattic/mongoose/issues/10349)
- fix(cursor): use stream destroy method on close to prevent emitting duplicate 'close' [#10878](https://togithub.com/Automattic/mongoose/issues/10878) [#10876](https://togithub.com/Automattic/mongoose/issues/10876) [iovanom](https://togithub.com/iovanom)
- fix: create indexes when readPreference=primary is set [#10861](https://togithub.com/Automattic/mongoose/issues/10861) [#10855](https://togithub.com/Automattic/mongoose/issues/10855) [gemyero](https://togithub.com/gemyero)
- fix(document): avoid depopulating when setting array of subdocs from different doc [#10819](https://togithub.com/Automattic/mongoose/issues/10819)
- fix(index.d.ts): allow modifying properties of UpdateQuery instances [#10786](https://togithub.com/Automattic/mongoose/issues/10786)
- fix(index.d.ts): add generic Paths to populate() to allow overriding path types [#10758](https://togithub.com/Automattic/mongoose/issues/10758)
### [`v6.0.10`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6010--2021-10-08)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.9...6.0.10)
\===================
- fix(query): add back strictQuery option to avoid empty filter issues, tie it to `strict` by default for compatibility [#10781](https://togithub.com/Automattic/mongoose/issues/10781) [#10763](https://togithub.com/Automattic/mongoose/issues/10763)
- fix(model): avoid unnecessarily dropping text indexes in `syncIndexes()` [#10851](https://togithub.com/Automattic/mongoose/issues/10851) [#10850](https://togithub.com/Automattic/mongoose/issues/10850) [IslandRhythms](https://togithub.com/IslandRhythms)
- fix(query): avoid trying to call toArray() on cursor if find() error occurred [#10845](https://togithub.com/Automattic/mongoose/issues/10845)
- fix: accepts uppercase values in mongoose.isValidObjectId [#10846](https://togithub.com/Automattic/mongoose/issues/10846) [foxadb](https://togithub.com/foxadb)
- perf(document): further reduce unnecessary objects and keys to minimize document memory overhead [#10400](https://togithub.com/Automattic/mongoose/issues/10400)
- fix(index.d.ts): restore unpacked type and avoid distributive conditional types [#10859](https://togithub.com/Automattic/mongoose/issues/10859) [dbellavista](https://togithub.com/dbellavista)
- fix(index.d.ts): add correct null typings for `findOneAndUpdate()` and `findByIdAndUpdate()` [#10820](https://togithub.com/Automattic/mongoose/issues/10820)
- fix(index.d.ts): make insertMany() correctly return Promise if passing single document to `insertMany()` [#10802](https://togithub.com/Automattic/mongoose/issues/10802)
- fix(index.d.ts): avoid weird issue where TypeScript 4.3.x and 4.4.x makes string extend Function [#10746](https://togithub.com/Automattic/mongoose/issues/10746)
- fix(index.d.ts): allow type: `SchemaTypeOptions[]` when defining schema [#10789](https://togithub.com/Automattic/mongoose/issues/10789)
- fix(index.d.ts): allow using `$in` with enum fields [#10757](https://togithub.com/Automattic/mongoose/issues/10757) [#10734](https://togithub.com/Automattic/mongoose/issues/10734)
- fix(index.d.ts): add missing fields and options params to Model constructor [#10817](https://togithub.com/Automattic/mongoose/issues/10817)
- fix(index.d.ts): support extending type for mongoose.models [#10806](https://togithub.com/Automattic/mongoose/issues/10806) [MunifTanjim](https://togithub.com/MunifTanjim)
- docs: enhance docs section linking [#10779](https://togithub.com/Automattic/mongoose/issues/10779) [saveman71](https://togithub.com/saveman71)
- docs(middleware): add missing query middleware [#10721](https://togithub.com/Automattic/mongoose/issues/10721)
- docs: fix typo [#10853](https://togithub.com/Automattic/mongoose/issues/10853) [mdatif796](https://togithub.com/mdatif796)
- docs: add missing to [#10848](https://togithub.com/Automattic/mongoose/issues/10848) [digidub](https://togithub.com/digidub)
### [`v6.0.9`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#609--2021-10-04)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.8...6.0.9)
\==================
- fix(document): init non-schema values if strict is set to false [#10828](https://togithub.com/Automattic/mongoose/issues/10828)
- fix(document): correctly track saved state for deeply nested objects [#10773](https://togithub.com/Automattic/mongoose/issues/10773)
- fix(array): avoid mutating arrays passed into Model() constructor [#10766](https://togithub.com/Automattic/mongoose/issues/10766)
- fix(cursor): allow using find().cursor() before connecting, report errors in pre('find') hooks when using `.cursor()` [#10785](https://togithub.com/Automattic/mongoose/issues/10785)
- fix(populate): support ref: Model with virtual populate [#10695](https://togithub.com/Automattic/mongoose/issues/10695)
- fix(schema): support type: { subpath: String } in document array definitions and improve schema `interpretAsType` error messages if type name is undefined [#10750](https://togithub.com/Automattic/mongoose/issues/10750)
- fix: upgrade to mongodb driver 4.1.2 [#10810](https://togithub.com/Automattic/mongoose/issues/10810) [orgads](https://togithub.com/orgads)
- fix(subdocument): add extra precaution to throw an error if a subdocument is a parent of itself in `ownerDocument()` [#9259](https://togithub.com/Automattic/mongoose/issues/9259)
- perf(index.d.ts): make `model()` call more strict to improve VS Code autocomplete perf [#10801](https://togithub.com/Automattic/mongoose/issues/10801) [traverse1984](https://togithub.com/traverse1984)
- fix(index.d.ts): allow calling depopulate with 0 args [#10793](https://togithub.com/Automattic/mongoose/issues/10793)
- fix(index.d.ts): Add type definitions for allowDiskUse [#10791](https://togithub.com/Automattic/mongoose/issues/10791) [coyotte508](https://togithub.com/coyotte508)
- docs(populate): expand virtual populate docs with info on principle of least cardinality and other info [#10558](https://togithub.com/Automattic/mongoose/issues/10558)
- docs: add migration guide to side bar [#10769](https://togithub.com/Automattic/mongoose/issues/10769)
- docs(connections+api): clarify that maxPoolSize is now 100 by default [#10809](https://togithub.com/Automattic/mongoose/issues/10809)
- docs(schema): add Schema#virtuals to docs as a public property [#10829](https://togithub.com/Automattic/mongoose/issues/10829)
- docs: remove array indexes section from FAQ [#10784](https://togithub.com/Automattic/mongoose/issues/10784) [Duchynko](https://togithub.com/Duchynko)
- docs(model): fix broken example [#10831](https://togithub.com/Automattic/mongoose/issues/10831) [Okekeprince1](https://togithub.com/Okekeprince1)
- docs: fix markdown issue with schemas.md [#10839](https://togithub.com/Automattic/mongoose/issues/10839) [aseerkt](https://togithub.com/aseerkt)
### [`v6.0.8`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#608--2021-09-27)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.7...6.0.8)
\==================
- fix: support $set on elements of map of subdocuments [#10720](https://togithub.com/Automattic/mongoose/issues/10720)
- fix(schematype): handle schema type definition where unique: false and `index` not set [#10738](https://togithub.com/Automattic/mongoose/issues/10738)
- fix(timestamps): handle `createdAt` with custom `typeKey` [#10768](https://togithub.com/Automattic/mongoose/issues/10768) [#10761](https://togithub.com/Automattic/mongoose/issues/10761) [jclaudan](https://togithub.com/jclaudan)
- fix(model): amend Model.translateAliases to observe non-aliased sub schemas [#10772](https://togithub.com/Automattic/mongoose/issues/10772) [frisbee09](https://togithub.com/frisbee09)
- fix: allow ObjectId#valueOf() to override built-in `Object#valueOf()`, clarify using `==` with ObjectIds in migration guide [#10741](https://togithub.com/Automattic/mongoose/issues/10741)
- fix: use process.emitWarning() instead of console.warn() for warnings [#10687](https://togithub.com/Automattic/mongoose/issues/10687)
- fix(index.d.ts): allow array of schema type options for string\[], `number[]` property Schema definitions [#10731](https://togithub.com/Automattic/mongoose/issues/10731)
- fix(index.d.ts): make built-in subdocument properties not required in UpdateQuery [#10597](https://togithub.com/Automattic/mongoose/issues/10597)
- docs(ssl): correct sslCA option and clarify that sslCA should be the path to the CA file [#10705](https://togithub.com/Automattic/mongoose/issues/10705)
### [`v6.0.7`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#607--2021-09-20)
[Compare Source](https://togithub.com/Automattic/mongoose/compare/6.0.6...6.0.7)
\==================
- fix(populate): wrap populate filters in trusted() so they work with `sanitizeFilter` [#10740](https://togithub.com/Automattic/mongoose/issues/10740)
- fix(aggregate): handle calling aggregate() before initial connection succeeds [#10722](https://togithub.com/Automattic/mongoose/issues/10722)
- fix(query): avoid throwing error when using `$not` with `$size` [#10716](https://togithub.com/Automattic/mongoose/issues/10716) [IslandRhythms](https://togithub.com/IslandRhythms)
- fix(discriminator): handle setting nested discriminator paths [#10702](https://togithub.com/Autom
This PR contains the following updates:
4.4.10
->6.2.11
By merging this PR, the issue #16 will be automatically resolved and closed:
Release Notes
Automattic/mongoose
### [`v6.2.11`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6211--2022-04-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.10...6.2.11) \=================== - fix(document): handle validation with triply nested document arrays [#11564](https://togithub.com/Automattic/mongoose/issues/11564) - fix(query): skip applying string schema setters on $regex [#11426](https://togithub.com/Automattic/mongoose/issues/11426) - fix: skip findOneAndReplace() validation if runValidators = false [#11559](https://togithub.com/Automattic/mongoose/issues/11559) - fix(model): correctly handle schema-level collations in syncIndexes() [#7621](https://togithub.com/Automattic/mongoose/issues/7621) - fix(types): correct populate query return type with lean [#11560](https://togithub.com/Automattic/mongoose/issues/11560) [mohammad0-0ahmad](https://togithub.com/mohammad0-0ahmad) - fix(types): allow using { type: Mixed } as schema type definition for any path [#10900](https://togithub.com/Automattic/mongoose/issues/10900) - docs: fix example on Schema.prototype.post() [#11648](https://togithub.com/Automattic/mongoose/issues/11648) [EmilienLeroy](https://togithub.com/EmilienLeroy) - docs: fix typo in methods/index.js [#11651](https://togithub.com/Automattic/mongoose/issues/11651) [eltociear](https://togithub.com/eltociear) ### [`v6.2.10`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6210--2022-04-04) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.9...6.2.10) \=================== - fix(types): improve lastErrorObject typing for rawResults [#11602](https://togithub.com/Automattic/mongoose/issues/11602) [simllll](https://togithub.com/simllll) - docs(typescript): add note about deprecating extends Document [#11619](https://togithub.com/Automattic/mongoose/issues/11619) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: consistent syntax highlighting with upgraded highlight.js [#11579](https://togithub.com/Automattic/mongoose/issues/11579) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) ### [`v6.2.9`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#629--2022-03-28) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.8...6.2.9) \================== - perf(document+model): make a few small optimizations [#11380](https://togithub.com/Automattic/mongoose/issues/11380) - fix(types): improve populate return type [#11560](https://togithub.com/Automattic/mongoose/issues/11560) [mohammad0-0ahmad](https://togithub.com/mohammad0-0ahmad) - fix(document): avoid marking paths as modified on subdocument defaults [#11528](https://togithub.com/Automattic/mongoose/issues/11528) - docs(schema): add example to index `expires` option [#11557](https://togithub.com/Automattic/mongoose/issues/11557) [boly38](https://togithub.com/boly38) - docs(model): add change stream docs [#11275](https://togithub.com/Automattic/mongoose/issues/11275) - docs(lambda): update Lambda docs for Mongoose 6 [#11275](https://togithub.com/Automattic/mongoose/issues/11275) - docs(connections): add note about connecting with X509 [#11333](https://togithub.com/Automattic/mongoose/issues/11333) - docs(populate): fix incorrect path name in `refPath` example [#11565](https://togithub.com/Automattic/mongoose/issues/11565) [chandiwalaaadhar](https://togithub.com/chandiwalaaadhar) ### [`v6.2.8`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#628--2022-03-22) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.7...6.2.8) \================== - fix(document): handle casting array of spread docs [#11522](https://togithub.com/Automattic/mongoose/issues/11522) - fix(document): avoid setting nested properties on top-level document when initing with strict: false [#11526](https://togithub.com/Automattic/mongoose/issues/11526) - fix(document): correctly handle deeply nested subdocuments when getting paths to validate [#11501](https://togithub.com/Automattic/mongoose/issues/11501) - fix(types): avoid making TInstanceMethods any by default leading to `this = any` in middleware [#11435](https://togithub.com/Automattic/mongoose/issues/11435) - fix(types): allow defining array default if using Types.Array<> in document interface [#11391](https://togithub.com/Automattic/mongoose/issues/11391) - docs(migrating_to\_6): describe breaking change in Mongoose 6 about default query populate model [#11289](https://togithub.com/Automattic/mongoose/issues/11289) - docs(middleware): fix typo [#11537](https://togithub.com/Automattic/mongoose/issues/11537) [x1489](https://togithub.com/x1489) ### [`v6.2.7`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#627--2022-03-16) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.6...6.2.7) \================== - perf(document): avoid running validation on every array element if there's no validators to run [#11380](https://togithub.com/Automattic/mongoose/issues/11380) - fix(cursor): correctly populate in batches when batchSize is set [#11509](https://togithub.com/Automattic/mongoose/issues/11509) - fix(connection): avoid setting MongoClient on useDb() connections until after setting on base connection [#11445](https://togithub.com/Automattic/mongoose/issues/11445) - fix(schema): throw more helpful error when using schema from a different version of Mongoose module [#10453](https://togithub.com/Automattic/mongoose/issues/10453) - fix: add missing timeseries expiration handling [#11489](https://togithub.com/Automattic/mongoose/issues/11489) [#11229](https://togithub.com/Automattic/mongoose/issues/11229) [Uzlopak](https://togithub.com/Uzlopak) - docs: correct Model.findOneAndReplace docs param naming [#11524](https://togithub.com/Automattic/mongoose/issues/11524) [anatolykopyl](https://togithub.com/anatolykopyl) ### [`v6.2.6`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#626--2022-03-11) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.5...6.2.6) \================== - fix(types): correct reference to cursor TypeScript bindings [#11513](https://togithub.com/Automattic/mongoose/issues/11513) [SimonHausdorf](https://togithub.com/SimonHausdorf) - fix(types): allow calling Query.prototype.populate() with array of strings [#11518](https://togithub.com/Automattic/mongoose/issues/11518) - fix(types): export and refactor types of PreMiddlewareFunction, PreSaveMiddlewareFunction, PostMiddlewareFunction, ErrorHandlingMiddlewareFunction [#11485](https://togithub.com/Automattic/mongoose/issues/11485) [Uzlopak](https://togithub.com/Uzlopak) ### [`v6.2.5`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#625--2022-03-09) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.4...6.2.5) \================== - fix(mongoose): add isObjectIdOrHexString() to better capture the most common use case for `isValidObjectId()` [#11419](https://togithub.com/Automattic/mongoose/issues/11419) - fix(query): prevent modifying discriminator key in updates using operators other than `$set` [#11456](https://togithub.com/Automattic/mongoose/issues/11456) - fix(populate+types): call foreignField functions with doc as 1st param, better typings for `localField` and `foreignField` functions [#11321](https://togithub.com/Automattic/mongoose/issues/11321) - fix(populate): return an array when using populate count on an array localField [#11307](https://togithub.com/Automattic/mongoose/issues/11307) - fix(query): avoid error when using $not with arrays [#11467](https://togithub.com/Automattic/mongoose/issues/11467) - perf: only deep clone validators if necessary [#11412](https://togithub.com/Automattic/mongoose/issues/11412) [Uzlopak](https://togithub.com/Uzlopak) - fix(types): rename definition files to lowercase to avoid typescript bug [#11469](https://togithub.com/Automattic/mongoose/issues/11469) - fix(types): aggregate.sort() accepts a string but also `{ field: 'asc'|'ascending'|'desc'|'descending' }` [#11479](https://togithub.com/Automattic/mongoose/issues/11479) [simonbrunel](https://togithub.com/simonbrunel) - fix(types): extract and refactor aggregationcursor and querycursor [#11488](https://togithub.com/Automattic/mongoose/issues/11488) [Uzlopak](https://togithub.com/Uzlopak) - fix(types): extract and refactor schemaoptions [#11484](https://togithub.com/Automattic/mongoose/issues/11484) [Uzlopak](https://togithub.com/Uzlopak) - fix(types): make first param to `Query.prototype.populate()` a string [#11475](https://togithub.com/Automattic/mongoose/issues/11475) [minhthinhls](https://togithub.com/minhthinhls) - fix(types): improve type checking for doc arrays in schema definitions [#11241](https://togithub.com/Automattic/mongoose/issues/11241) - docs: fix length comparaison in lean.test.js [#11493](https://togithub.com/Automattic/mongoose/issues/11493) [zazapeta](https://togithub.com/zazapeta) - docs(timestamps): fix typo [#11481](https://togithub.com/Automattic/mongoose/issues/11481) [saibbyweb](https://togithub.com/saibbyweb) - docs: fix broken link to rawResult [#11459](https://togithub.com/Automattic/mongoose/issues/11459) [chhiring90](https://togithub.com/chhiring90) ### [`v6.2.4`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#624--2022-02-28) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.3...6.2.4) \================== - fix(query): correctly return full deleteOne(), deleteMany() result [#11211](https://togithub.com/Automattic/mongoose/issues/11211) - fix(query): handle update validators on deeply nested subdocuments [#11455](https://togithub.com/Automattic/mongoose/issues/11455) [#11394](https://togithub.com/Automattic/mongoose/issues/11394) - fix(discriminator): handle modifying multiple nested paths underneath a discriminator [#11428](https://togithub.com/Automattic/mongoose/issues/11428) - perf: improve isAsyncFunction [#11408](https://togithub.com/Automattic/mongoose/issues/11408) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): add typedefs for Schema `pick()` [#11448](https://togithub.com/Automattic/mongoose/issues/11448) [Moisei-Shkil](https://togithub.com/Moisei-Shkil) - fix(index.d.ts): allow type override for distinct() [#11306](https://togithub.com/Automattic/mongoose/issues/11306) - fix(index.d.ts): allow array of validators in schema definition [#11355](https://togithub.com/Automattic/mongoose/issues/11355) - fix(index.d.ts): improve connection typings [#11418](https://togithub.com/Automattic/mongoose/issues/11418) [Uzlopak](https://togithub.com/Uzlopak) - docs: add timestamps docs [#11336](https://togithub.com/Automattic/mongoose/issues/11336) - docs(timestamps): explain how timestamps works under the hood [#11336](https://togithub.com/Automattic/mongoose/issues/11336) - docs(migrating_to\_6): add model.exists breaking change returning doument instead of boolean [#11407](https://togithub.com/Automattic/mongoose/issues/11407) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs(index.d.ts): add docs for FilterQuery, UpdateQuery, and LeanDocument [#11457](https://togithub.com/Automattic/mongoose/issues/11457) [Moisei-Shkil](https://togithub.com/Moisei-Shkil) ### [`v6.2.3`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#623--2022-02-21) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.2...6.2.3) \================== - fix(model): avoid dropping base model indexes when using discriminators with `Connection.prototype.syncIndexes()` [#11424](https://togithub.com/Automattic/mongoose/issues/11424) [#11421](https://togithub.com/Automattic/mongoose/issues/11421) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(document): handle array defaults when selecting element underneath array [#11376](https://togithub.com/Automattic/mongoose/issues/11376) - fix(populate): correctly handle depopulating populated subdocuments [#11436](https://togithub.com/Automattic/mongoose/issues/11436) - fix(utils): improve deepEqual() handling for comparing objects with non-objects [#11417](https://togithub.com/Automattic/mongoose/issues/11417) - fix(schema): allow declaring array of arrays using `[{ type: [String] }]` [#11252](https://togithub.com/Automattic/mongoose/issues/11252) - perf: improve validation sync and async by replacing forEach with classic for loops [#11414](https://togithub.com/Automattic/mongoose/issues/11414) [Uzlopak](https://togithub.com/Uzlopak) - perf: make hasDollarKeys faster [#11401](https://togithub.com/Automattic/mongoose/issues/11401) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): ValidationError `errors` only contains CastError or ValidationError [#11369](https://togithub.com/Automattic/mongoose/issues/11369) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): make InsertManyResult.insertedIds return an array of Types.ObjectId by default [#11197](https://togithub.com/Automattic/mongoose/issues/11197) - fix(index.d.ts): allow pre('save') middleware with pre options [#11257](https://togithub.com/Automattic/mongoose/issues/11257) - fix(index.d.ts): add `supressReservedKeysWarning` option to schema [#11439](https://togithub.com/Automattic/mongoose/issues/11439) [hiukky](https://togithub.com/hiukky) - docs(connections): improve replica set hostname docs with correct error message and info about `err.reason.servers` [#11200](https://togithub.com/Automattic/mongoose/issues/11200) - docs(populate): add virtual populate match option documentation [#11411](https://togithub.com/Automattic/mongoose/issues/11411) [remirobichet](https://togithub.com/remirobichet) - docs(document): add note to API docs that flattenMaps defaults to `true` for `toJSON()` but not `toObject()` [#11213](https://togithub.com/Automattic/mongoose/issues/11213) - docs(document+model): add populate option to populate() API docs [#11170](https://togithub.com/Automattic/mongoose/issues/11170) - docs(migrating_to\_6): add additional info about removing omitUndefined [#11038](https://togithub.com/Automattic/mongoose/issues/11038) - docs(migrating_to\_6): add model.exists breaking change returning doument instead of boolean [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) ### [`v6.2.2`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#622--2022-02-16) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.1...6.2.2) \================== - fix: fix QueryCursor and AggregationCursor compatibility with Node v17.5 [#11381](https://togithub.com/Automattic/mongoose/issues/11381) [benjamingr](https://togithub.com/benjamingr) - fix: better esm support, no necessity for setting allowSyntheticDefaultImports and esModuleInterop [#11343](https://togithub.com/Automattic/mongoose/issues/11343) [Uzlopak](https://togithub.com/Uzlopak) - fix(model): apply projection parameter to hydrate() [#11375](https://togithub.com/Automattic/mongoose/issues/11375) - fix: fix issue with creating arrays of length > 10000 [#11405](https://togithub.com/Automattic/mongoose/issues/11405) [Uzlopak](https://togithub.com/Uzlopak) - fix(document): minimize single nested subdocs [#11247](https://togithub.com/Automattic/mongoose/issues/11247) - fix(connection): handle reopening base connection with useDb() [#11240](https://togithub.com/Automattic/mongoose/issues/11240) - perf: use property access instead of `get()` helper where possible [#11389](https://togithub.com/Automattic/mongoose/issues/11389) [Uzlopak](https://togithub.com/Uzlopak) - fix: use `isArray()` instead of `instanceof Array` [#11393](https://togithub.com/Automattic/mongoose/issues/11393) [Uzlopak](https://togithub.com/Uzlopak) - perf: improve performance of `cast$expr()` [#11388](https://togithub.com/Automattic/mongoose/issues/11388) [Uzlopak](https://togithub.com/Uzlopak) - perf: remove `startsWith()` from `isOperator()` [#11400](https://togithub.com/Automattic/mongoose/issues/11400) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): extract `PipelineStage` into separate file [#11368](https://togithub.com/Automattic/mongoose/issues/11368) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): fix $search highlight path option type [#11373](https://togithub.com/Automattic/mongoose/issues/11373) [lmX2015](https://togithub.com/lmX2015) - docs: update changelog file to CHANGELOG.md [#11365](https://togithub.com/Automattic/mongoose/issues/11365) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: fix broken links [#11388](https://togithub.com/Automattic/mongoose/issues/11388) [#11377](https://togithub.com/Automattic/mongoose/issues/11377) [saibbyweb](https://togithub.com/saibbyweb) - docs: remove double determiners in connections docs [#11340](https://togithub.com/Automattic/mongoose/issues/11340) [Erma32](https://togithub.com/Erma32) ### [`v6.2.1`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6211--2022-04-13) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.2.0...6.2.1) \=================== - fix(document): handle validation with triply nested document arrays [#11564](https://togithub.com/Automattic/mongoose/issues/11564) - fix(query): skip applying string schema setters on $regex [#11426](https://togithub.com/Automattic/mongoose/issues/11426) - fix: skip findOneAndReplace() validation if runValidators = false [#11559](https://togithub.com/Automattic/mongoose/issues/11559) - fix(model): correctly handle schema-level collations in syncIndexes() [#7621](https://togithub.com/Automattic/mongoose/issues/7621) - fix(types): correct populate query return type with lean [#11560](https://togithub.com/Automattic/mongoose/issues/11560) [mohammad0-0ahmad](https://togithub.com/mohammad0-0ahmad) - fix(types): allow using { type: Mixed } as schema type definition for any path [#10900](https://togithub.com/Automattic/mongoose/issues/10900) - docs: fix example on Schema.prototype.post() [#11648](https://togithub.com/Automattic/mongoose/issues/11648) [EmilienLeroy](https://togithub.com/EmilienLeroy) - docs: fix typo in methods/index.js [#11651](https://togithub.com/Automattic/mongoose/issues/11651) [eltociear](https://togithub.com/eltociear) ### [`v6.2.0`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#620--2022-02-02) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.10...6.2.0) \================== - feat: upgrade MongoDB driver to 4.3.1 - feat(connection+mongoose): add support for continueOnError for syncIndexes [#11266](https://togithub.com/Automattic/mongoose/issues/11266) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - feat(query): cast literals in `$expr` where possible [#10663](https://togithub.com/Automattic/mongoose/issues/10663) - feat(schema+mongoose): add pluginTags to allow applying global plugins to only schemas with matching tags [#9780](https://togithub.com/Automattic/mongoose/issues/9780) - feat(discriminator): support overwriteModels:true to reuse discriminator names [#11244](https://togithub.com/Automattic/mongoose/issues/11244) [#10931](https://togithub.com/Automattic/mongoose/issues/10931) [IslandRhythms](https://togithub.com/IslandRhythms) - feat(index.d.ts): add DocType generic param to Model functions that return queries to better support projections [#11156](https://togithub.com/Automattic/mongoose/issues/11156) - feat(error): export MongooseServerSelectionError [#11202](https://togithub.com/Automattic/mongoose/issues/11202) - feat(schematype): add validators, path, isRequired to public API and TypeScript types [#11139](https://togithub.com/Automattic/mongoose/issues/11139) - fix(model): make exists(...) return lean document with \_id or null instead of boolean [#11142](https://togithub.com/Automattic/mongoose/issues/11142) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - fix(model): support storing versionKey in nested paths [#10980](https://togithub.com/Automattic/mongoose/issues/10980) - fix(index.d.ts): add options to `bulkSave()` type def [#11201](https://togithub.com/Automattic/mongoose/issues/11201) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): better support for query projections [#11210](https://togithub.com/Automattic/mongoose/issues/11210) [EugeneKorshenko](https://togithub.com/EugeneKorshenko) ### [`v6.1.10`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#6110--2022-02-01) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.9...6.1.10) \=================== - fix(mongoose): correctly handle destructured isValidObjectId [#11304](https://togithub.com/Automattic/mongoose/issues/11304) - fix(mongoose): defer to MongoDB driver isValid() for `isValidObjectId()` [#11227](https://togithub.com/Automattic/mongoose/issues/11227) ### [`v6.1.9`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#619--2022-01-31) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.8...6.1.9) \================== - fix(query): respect nested schema strict as default when casting query filters [#11291](https://togithub.com/Automattic/mongoose/issues/11291) - fix(mongoose): make isValidObjectId() consistent with isValid(), make `ObjectId()` casting more flexible [#11209](https://togithub.com/Automattic/mongoose/issues/11209) - fix(setDefaultsOnInsert): ignore defaults underneath maps [#11235](https://togithub.com/Automattic/mongoose/issues/11235) - fix(query): avoid setting nested schema properties that are stripped out by strictQuery to undefined in query filter [#11291](https://togithub.com/Automattic/mongoose/issues/11291) - fix: check for all flags in a regex deepequal [#11242](https://togithub.com/Automattic/mongoose/issues/11242) [Uzlopak](https://togithub.com/Uzlopak) - fix: replace substr with substring [#11278](https://togithub.com/Automattic/mongoose/issues/11278) [Uzlopak](https://togithub.com/Uzlopak) - docs: port for documentation testing in CONTRIBUTING.md [#11273](https://togithub.com/Automattic/mongoose/issues/11273) [Uzlopak](https://togithub.com/Uzlopak) ### [`v6.1.8`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#618--2022-01-24) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.7...6.1.8) \================== - fix(connection): stop leaking sessions in .transaction() [#11259](https://togithub.com/Automattic/mongoose/issues/11259) [#11256](https://togithub.com/Automattic/mongoose/issues/11256) [Uzlopak](https://togithub.com/Uzlopak) - perf: remove sliced in favor of Array.prototype.slice() [#11238](https://togithub.com/Automattic/mongoose/issues/11238) [Uzlopak](https://togithub.com/Uzlopak) - perf: improve setDottedPath [#11264](https://togithub.com/Automattic/mongoose/issues/11264) [Uzlopak](https://togithub.com/Uzlopak) - fix(document): handle edge case where NestJS sets String.type = String, mixing up schema definitions [#11199](https://togithub.com/Automattic/mongoose/issues/11199) - fix: remove obsolete code after upgrading to bson4 [#11265](https://togithub.com/Automattic/mongoose/issues/11265) [Uzlopak](https://togithub.com/Uzlopak) - fix: remove util.isArray in favor of Array.isArray [#11234](https://togithub.com/Automattic/mongoose/issues/11234) [Uzlopak](https://togithub.com/Uzlopak) - fix(index.d.ts): avoid UnpackedIntersection making `findOne().populate()` result non-nullable [#11041](https://togithub.com/Automattic/mongoose/issues/11041) - docs(migration): add note to change default functions to schema [#11245](https://togithub.com/Automattic/mongoose/issues/11245) [AbdelrahmanHafez](https://togithub.com/AbdelrahmanHafez) - docs: updated docs and issue templates for new FAQs [#11171](https://togithub.com/Automattic/mongoose/issues/11171) [IslandRhythms](https://togithub.com/IslandRhythms) - chore: fix casting benchmark [#11262](https://togithub.com/Automattic/mongoose/issues/11262) [Uzlopak](https://togithub.com/Uzlopak) - chore: add mongodb-memory-server to test easier locally [#11255](https://togithub.com/Automattic/mongoose/issues/11255) [Uzlopak](https://togithub.com/Uzlopak) - chore: fix testing tsconfig [#11243](https://togithub.com/Automattic/mongoose/issues/11243) [Uzlopak](https://togithub.com/Uzlopak) - refactor: move utils.random to test folder [#11239](https://togithub.com/Automattic/mongoose/issues/11239) [Uzlopak](https://togithub.com/Uzlopak) ### [`v6.1.7`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#617--2022-01-17) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.6...6.1.7) \================== - fix(model): correct handling for $push on a nested array [#11108](https://togithub.com/Automattic/mongoose/issues/11108) - fix(update): correctly apply timestamps to update pipelines [#11151](https://togithub.com/Automattic/mongoose/issues/11151) - fix(document): correctly handle modifying array subdocument after setting array subdocument to itself [#11172](https://togithub.com/Automattic/mongoose/issues/11172) - fix(index.d.ts): allow passing options to model() in place of removed `skipInit` [#11137](https://togithub.com/Automattic/mongoose/issues/11137) - fix(aggregate): allow passing verbosity to Aggregate.prototype.explain() [#11144](https://togithub.com/Automattic/mongoose/issues/11144) - fix(index.d.ts): avoid TypeScript inferring \_id as any type with HydratedDocument [#11085](https://togithub.com/Automattic/mongoose/issues/11085) - docs: fix Node.js Driver compat link [#11214](https://togithub.com/Automattic/mongoose/issues/11214) [wesbos](https://togithub.com/wesbos) - docs: remove extraneous backquote [#11204](https://togithub.com/Automattic/mongoose/issues/11204) [joebowbeer](https://togithub.com/joebowbeer) ### [`v6.1.6`](https://togithub.com/Automattic/mongoose/blob/HEAD/CHANGELOG.md#616--2022-01-10) [Compare Source](https://togithub.com/Automattic/mongoose/compare/6.1.5...6.1.6) \================== - perf(document): delay creating document event emitter until used to improve memory usage, several small improvements to improve initing docs with large arrays [#10400](https://togithub.com/Automattic/mongoose/issues/10400) - fix(model): avoid `bulkSave()` error when `versionKey: false` [#11186](https://togithub.com/Automattic/mongoose/issues/11186) [#11071](https://togithub.com/Automattic/mongoose/issues/11071) [IslandRhythms](https://togithub.com/IslandRhythms) - fix(model): revert [#11079](https://togithub.com/Automattic/mongoose/issues/11079): `findByIdAndUpdate(undefined)` breaking change [#11149](https://togithub.com/Automattic/mongoose/issues/11149) - fix(index.d.ts): support strings in deep populate [#11181](https://togithub.com/Automattic/mongoose/issues/11181) [ivalduan](https://togithub.com/ivalduan) - fix(index.d.ts): rename map() -> transform() to line up with change in v6.0 [#11161](https://togithub.com/Automattic/mongoose/issues/11161) - fix(index.d.ts): allow new Model