Skip to content
Permalink
0eda12a77d
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
7659 lines (6713 sloc) 439 KB

6.7.5 / 2022-11-30

  • fix(schema): copy indexes when calling add() with schema instance #12737 #12654
  • fix(query): handle deselecting _id when another field has schema-level select: false #12736 #12670
  • fix(types): support using UpdateQuery in bulkWrite() #12742 #12595
  • docs(middleware): added note about execution policy on subdocuments #12735 #12694 lpizzinidev
  • docs(validation): clarify context for update validators in validation docs #12738 #12655 IslandRhythms

6.7.4 / 2022-11-28

  • fix: allow setting global strictQuery after Schema creation #12717 #12703 lpizzinidev
  • fix(cursor): make eachAsync() avoid modifying batch when mixing parallel and batchSize #12716
  • fix(types): infer virtuals in query results #12727 #12702 #12684
  • fix(types): correctly infer ReadonlyArray types in schema definitions #12720
  • fix(types): avoid typeof Query with generics for TypeScript 4.6 support #12712 #12688
  • chore: avoid bundling .tgz files when publishing #12725 hasezoey

6.7.3 / 2022-11-22

  • fix(document): handle setting array to itself after saving and pushing a new value #12672 #12656
  • fix(types): update replaceWith pipeline stage #12715 coyotte508
  • fix(types): remove incorrect modelName type definition #12682 #12669 lpizzinidev
  • fix(schema): fix setupTimestamps for browser.umd #12683 raphael-papazikas
  • docs: correct justOne description #12686 #12599 tianguangcn
  • docs: make links more consistent #12690 #12645 hasezoey
  • docs(document): explain that $isNew is false in post('save') hooks #12685 #11990
  • docs: fixed line causing a "used before defined" linting error #12707 sgpinkus

6.7.2 / 2022-11-07

  • fix(discriminator): skip copying base schema plugins if applyPlugins == false #12613 #12604 lpizzinidev
  • fix(types): add UUID to types #12650 #12593
  • fix(types): allow setting SchemaTypeOptions' index property to IndexOptions #12562
  • fix(types): set this to doc type in SchemaType.prototype.validate() #12663 #12590
  • fix(types): correct handling for model #12659 #12573
  • fix(types): pre hook with deleteOne should resolve this as Query #12642 #12622 lpizzinidev

6.7.1 / 2022-11-02

  • fix(query): select Map field with select: false when explicitly requested #12616 #12603 lpizzinidev
  • fix: correctly find paths underneath single nested document with an array of mixed #12605 #12530
  • fix(populate): better support for populating maps of arrays of refs #12601 #12494
  • fix(types): add missing create constructor signature override type #12585 naorpeled
  • fix(types): make array paths optional in inferred type of array default returns undefined #12649 #12420
  • fix(types): improve ValidateOpts type #12606 Freezystem
  • docs: add Lodash guide highlighting issues with cloneDeep() #12609
  • docs: removed v5 link from v6 docs #12641 #12624 lpizzinidev
  • docs: removed outdated connection example #12618 lpizzinidev

6.7.0 / 2022-10-24

  • feat: upgrade to mongodb driver 4.11.0 #12446
  • feat: add UUID Schema Type (BSON Buffer SubType 4) #12268 #3208 hasezoey
  • feat(aggregation): add $fill pipeline stage #12545 raphael-papazikas
  • feat(types+schema): allow defining schema paths using mongoose.Types.* to work around TS type inference issues #12352
  • feat(schema): add alias() method that makes it easier to define multiple aliases for a given path #12368
  • feat(model): add mergeHooks option to Model.discriminator() to avoid duplicate hooks #12542
  • feat(document): add $timestamps() method to set timestamps for save(), bulkSave(), and insertMany() #12540

6.6.7 / 2022-10-21

  • fix: correct browser build and improve isAsyncFunction check for browser #12577 #12576 #12392
  • fix(query): allow overwriting discriminator key with overwriteDiscriminatorKey if strict: 'throw' #12578 #12513

6.6.6 / 2022-10-20

  • fix(update): handle runValidators when using $set on a doc array in discriminator schema #12571 #12518
  • fix(document): allow creating document with document array and top-level key named schema #12569 #12480
  • fix(cast): make schema-level strictQuery override schema-level strict for query filters #12570 #12508
  • fix(aggregate): avoid adding extra $match stage if user manually set discriminator key to correct value in first pipeline stage #12568 #12478
  • fix: Throws error when updating a key name that match the discriminator key name on nested object #12534 #12517 lpizzinidev
  • fix(types): add limit to $filter expression #12553 raphael-papazikas
  • fix(types): correct replaceWith type pipeline stage #12535 FabioCingottini
  • fix(types): add missing densify type pipeline type #12533 FabioCingottini
  • docs(populate): added transform option description #12560 #12551 lpizzinidev
  • docs(connection): add sample to useDb() documentation #12541 lpizzinidev
  • docs(guide): update broken read-preference links #12538 #12525 hasezoey
  • chore: add TypeScript version field to issue template #12532 hasezoey

6.6.5 / 2022-10-05

  • fix(document): set defaults on subdocuments underneath init-ed single nested subdocument #12523 #12515
  • fix: make Jest fake timers check more robust to other libs that overwrite time functions #12527 #12514
  • fix(types): indicate that Schema.prototype.discriminator() returns this #12522 #12457
  • fix(types): add "estimatedDocumentCount" and "countDocuments" as possible hooks #12519 #12516
  • docs(models): add section on MongoDB Views #12526 #5694
  • docs(subdocs): clarify that populated docs are not subdocs #12521 #12398
  • docs(change-streams): remove unnecessary obsolete comment about needing to use mongodb driver change streams #12444

6.6.4 / 2022-10-03

  • fix(model): avoid saving applied defaults if path is deselected #12506 #12414
  • fix(types): correct DocType for auto typed query helpers #12342
  • fix(types): avoid "excessively deep" type instantiation error when using bulkWrite() with type that extends from document #12277
  • fix(types): avoid relying on typeof this, which isn't supported in TypeScript < 4.4 #12375
  • docs(schema): correct example for Schema.prototype.discriminator() #12493
  • docs(typescript): clean up query helpers examples #12342
  • chore: use mongodb-memory-server for testing #12262 hasezoey

6.6.3 / 2022-09-30

  • fix(query): treat findOne(_id) as equivalent to findOne({ _id }) #12485 #12325
  • fix(timestamps): findOneAndUpdate creates subdocs with timestamps in reverse order #12484 #12475 lpizzinidev
  • fix(types): make schema.plugin() more flexible for schemas that don't define any generics #12486 #12454
  • fix(types): add "array of array key-value pairs" as a argument option for "query.sort()" #12483 #12434 hasezoey
  • fix(types): remove unused defaults in "PluginFunction" #12459 hasezoey
  • fix(types): update DiscriminatorSchema to have better names and combine statics #12460 hasezoey

6.6.2 / 2022-09-26

  • fix(model): avoid deleting shared schema methods in fix for #12254 #12423
  • fix(document): set $inc default value in case field has not been specified on the document #12435 lpizzinidev
  • fix(query): handle select: false on map paths in query results #12467 lpizzinidev
  • fix(types): add HydratedDocumentFromSchema to make it easier to pull inferred hydrated doc type #12464 #12319
  • fix(types): add sanitizeFilter to types #12465 zrosenbauer
  • fix(types): infer number enum types from schema if using enum: [0, 1] as const #12463 #12242
  • docs(validation): add section on global schematype validation, clean up other issues #12430
  • docs: add clarification about overwrite flag in model.js #12447 Tzvika-m
  • docs: change to consistent "Example:" for jsdoc comments #12432 hasezoey

6.6.1 / 2022-09-14

  • fix: correctly apply defaults after subdoc init #12328
  • fix(array): avoid using default _id when using pull() #12294
  • fix: allow null values inside $expr objects #12429 MartinDrost
  • fix(query): use correct Query constructor when cloning query #12418
  • docs(website): remove setting "latest38x" which is not used anywhere #12396 hasezoey

6.6.0 / 2022-09-08

  • feat: upgrade mongodb driver -> 4.9.1 #12370 AbdelrahmanHafez
  • feat: re-export default Mongoose instance properties for ESM named imports support #12256
  • feat(model): add option to skip invalid fields with castObject() #12156 IslandRhythms
  • feat: use setPrototypeOf() instead of proto to allow running on Deno #12315
  • feat(QueryCursor): add support for AbortSignal on eachAsync() #12323
  • feat(types): add types for new $densify operator #12118 IslandRhythms

6.5.5 / 2022-09-07

  • fix(setDefaultsOnInsert): avoid applying defaults on insert if nested property set #12279
  • fix(model): make applyHooks() and applyMethods() handle case where custom method is set to Mongoose implementation #12254
  • fix(types): add string "ascending" and "descending" index-directions #10269
  • docs: upgrade dox to 1.0.0 #12403 hasezoey
  • docs: update old mongodb nodejs driver documentation urls #12387 hasezoey
  • docs: update JSDOC ... (spread) definition #12388 hasezoey
  • refactor(model): allow optionally passing indexes to createIndexes and cleanIndexes #12280 AbdelrahmanHafez

6.5.4 / 2022-08-30

  • fix(document): allow calling $assertPopulated() with values to better support manual population #12233
  • fix(connection+mongoose): better handling for calling model() with 1 argument #12359
  • fix(model): allow defining discriminator virtuals and methods using schema options #12326
  • fix(types): fix MongooseQueryMiddleware missing "findOneAndReplace" and "replaceOne" #12330 #12329 Jule- lpizzinidev
  • fix(types): fix replaceOne return type #12351 lpizzinidev
  • fix(types): use this for return type from $assertPopulated() #12234
  • docs: highlight how to connect using auth in README #12354 AntonyOnScript
  • docs: improve jsdoc comments for private methods #12337 hasezoey
  • docs: fix minor typo in compatibility table header #12355 skyme5

6.5.3 / 2022-08-24

  • fix(document): handle maps when applying defaults to nested paths #12322
  • fix(schema): make ArraySubdocuments apply _id defaults on init #12264
  • fix(populate): handle specifying recursive populate as a string with discriminators #12266
  • perf(types): remove extends Query in Schema.pre() and Schema.post(), loosen discriminator() generic #10349
  • perf(types): some more micro-optimizations re: #10349, remove extra type checking on $ne, etc.
  • fix(types): infer schema on connection.model() #12298 #12125 hasezoey
  • fix(types): add missing findById() type definitions #12309 lpizzinidev
  • fix(types): allow $search in $lookup pipeline stages for MongoDB v6.x support #12278 AbdelrahmanHafez
  • fix(types): add parameter "options" to "Model.remove" #12258 hasezoey
  • fix(types): sync single-generic-no-constraint "model" between "index.d.ts" and "connection.d.ts" #12299 hasezoey
  • fix(types): update isDirectModified typing #12290 gabrielDonnantuoni
  • docs: update links on api docs #12293 eatmoarrice
  • docs: add note about language_override option #12310 IslandRhythms
  • docs(document): add "String[]" to Document.depopulate as jsdoc parameter type #12300 hasezoey
  • docs: update Node.js EventEmitter url #12303 rainrisa

5.13.15 / 2022-08-22

  • fix: backport fix for CVE-2022-2564 #12281 shubanker
  • docs: fix broken link from findandmodify method deprecation #11366 laissonsilveira

6.5.2 / 2022-08-09

  • fix(aggregate): avoid throwing error when disconnecting with change stream open #12201 ramos-ph
  • fix(query): overwrite top-level key if using Query.prototype.set() to set to undefined #12155
  • fix(query): shallow clone options before modifying #12176
  • fix(types): auto schema type inference on Connection.prototype.model() #12240 hasezoey
  • fix(types): better typescript support for schema plugins #12139 emiljanitzek
  • fix(types): make bulkWrite() type param optional #12221 #12212
  • docs: misc cleanup #12199 hasezoey
  • docs: highlight current top-most visible header in navbar #12222 hasezoey
  • docs(populate): improve examples for Document.prototype.populate() #12111
  • docs(middleware): clarify document vs model in middleware docs #12113

6.5.1 / 2022-08-03

  • fix(timestamps): set timestamps on child schema when child schema has timestamps: true but parent schema does not #12119
  • fix(schema+timestamps): handle insertMany() with timestamps and discriminators #12150
  • fix(model+query): handle populate with lean transform that deletes _id #12143
  • fix(types): allow $pull with _id #12142
  • fix(types): add schema plugin option inference #12196 hasezoey
  • fix(types): pass type to mongodb bulk write operation #12167 emiljanitzek
  • fix(types): map correct generics from model to schema #12125 emiljanitzek
  • fix(types): avoid baffling circular reference when using PopulatedDoc with a bidirectional reference #12136
  • fix(types): allow using path with $count #12149
  • docs(compatibility): change to use a table #12200 hasezoey
  • docs(api_split.pug): add "code" to sidebar entries #12153 hasezoey
  • docs: add "code" to Headers (and index list) #12152 hasezoey

6.5.0 / 2022-07-26

  • perf(document): avoid creating unnecessary empty objects when creating a state machine #11988
  • feat: upgrade mongodb driver -> 4.8.1 #12103 AbdelrahmanHafez
  • feat(model): allow passing timestamps option to Model.bulkSave(...) #12082 AbdelrahmanHafez
  • feat(model): add castObject() function that casts a POJO to the model's schema #11945
  • feat(document): add $inc() helper that increments numeric paths #12115
  • feat(schema): add schema level lean option IslandRhythms
  • feat(schema): add global id option to disable id on schemas #12067 IslandRhythms
  • fix(connection): re-run Model.init() if re-connecting after explicitly closing a connection #12130
  • feat(model): add applyDefaults() helper that allows applying defaults to document or POJO #11945
  • feat(model): allow calling hydrate() with { setters: true } #11653
  • feat(model): add hydrate option to Model.watch() to automatically hydrate fullDocument #12121
  • feat(types): add support for automatically typed virtuals in schemas #11908 mohammad0-0ahmad

6.4.7 / 2022-07-25

  • fix(virtualtype): use $locals for default virtual getter/setter rather than top-level doc #12124
  • fix(document): call subdocument getters if child schema has getters: true #12105
  • fix(schematype): actually always return "this" where specified #12141 hasezoey
  • fix(types): correct return value for Model.exists() #12094
  • docs(guides): add link to advanced schemas doc #12073
  • docs: handle @see in jsdoc #12144 hasezoey
  • docs: make use of the deprecated tag available in jsdoc for documentation #12080 hasezoey
  • docs(api_split): add basic DEPRECATED output #12146 hasezoey
  • docs: various jsdoc cleanup #12140 hasezoey
  • docs(api_split.pug): add "code" to parameter name #12145 hasezoey

6.4.6 / 2022-07-20

  • fix(schema): disallow setting proto when creating schema with dotted properties #12085
  • fix(document): avoid mutating original object passed to $set() when applying defaults to nested properties #12102
  • fix(query): apply lean transform option to top-level document #12093
  • docs(migrating_to_6): correct example for isObjectIdOrHexString() #12123 LokeshKanumoori

6.4.5 / 2022-07-18

  • fix(model+timestamps): set timestamps on subdocuments in insertMany() #12060
  • fix: correct isAtlas check #12110 skrtheboss
  • fix(types): fix various issues with auto typed schemas #12042 mohammad0-0ahmad
  • fix(types): allow any value for AddFields #12096
  • fix(types): allow arbitrary expressions for ConcatArrays #12058
  • fix(types): make $addToSet fields mutable to allow programatically constructing $addToSet #12091
  • fix(types): add $let as a possible expression to $addFields #12087 AbdelrahmanHafez
  • fix(types): fix $switch expression type #12088 AbdelrahmanHafez
  • fix(types): correct options type for syncIndexes() #12101 lpizzinidev
  • fix(types): avoid treating | undefined types as any in Require_id to better support _id: String with auto-typed schemas #12070
  • docs: fix up various jsdoc issues #12086 hasezoey
  • docs: add sanitizeFilter to mongoose.set() options #12112 pathei-kosmos

6.4.4 / 2022-07-08

  • fix(types): allow using an object to configure timestamps #12061 lantw44
  • fix(types): support findOneAndReplace with rawResult #12062 lantw44
  • docs: upgrade API documentation parser #12078 #12072 #12071 #12024 hasezoey
  • docs(document): add more info on $isNew #11990
  • docs: add SchemaType doValidate() to docs #12068

6.4.3 / 2022-07-05

  • fix(document): handle validating deeply nested subdocuments underneath nested paths with required: false #12021
  • fix(types): infer schematype type from schema paths when calling SchemaType.path() #11987
  • fix(types): add $top and $topN aggregation operators #12053
  • fix(types): clean up a couple of issues with $add and $ifNull #12017
  • fix(types): allow $cond with $in #12028
  • docs: add path level descending index example in docs #12023 MitchellCash
  • docs: add Buffer, Decimal128, Map to docs #11971

6.4.2 / 2022-07-01

  • fix: keep autoIndex & autoCreate as true by default if read preference is primaryPreferred #11976
  • fix(types): improve inferred Schema Type to handle nested paths and ObjectIds #12007 iammola
  • fix(types): avoid inferring doc type from param to create() #12001
  • fix(types): make populate Paths generic consistently overwrite doc interface #11955
  • fix(types): allow null at ne expression second parameter #11996 jyeros
  • fix(types): change index "weights" to be more explicit #11997 hasezoey

6.4.1 / 2022-06-27

  • fix(schema): allow 0 for numbers if required and ref both set #11912
  • fix(query): skip applying default projections over slice projections #11940
  • fix(types): handle arrays in ApplyBasicQueryCasting correctly #11964
  • fix(types): fix $match typings #11969 andreialecu
  • fix(types): avoid adding non-existent properties from model constructor for typegoose #11960
  • fix(types): make Mongoose UpdateQuery compatible with MongoDB UpdateFilter #11911
  • fix(types): simplify MergeType constraints #11978
  • fix(types): correct references to Buffer for @types/node >= 16.0.0 < 16.6.0 #11963
  • fix(types): re-add the possibility to pass undefined for projection in Model.find #11965 ghost91-
  • fix(types): fix typo for indexes #11953 AbdelrahmanHafez
  • fix(document+types): document merge option #11913
  • docs: update schematypes.md #11981 korzio
  • docs: update validation.md #11982 korzio

6.4.0 / 2022-06-17

  • feat: upgrade mongodb driver -> 4.7.0 #11909 AbdelrahmanHafez
  • feat(types+document): add $assertPopulated() for working with manually populated paths in TypeScript #11843
  • feat(mongoose): add setDriver() function to allow overwriting driver in a more consistent way #11900
  • feat(types): add helpers to infer schema type automatically #11563 mohammad0-0ahmad
  • feat: add transform option to lean() #10423 IslandRhythms
  • feat(base): add support to set default immutable for createdAt globally #11888 AbdelrahmanHafez
  • fix: make doValidate() on document array elements run validation on the whole subdoc #11902
  • feat(types): add expression typings to Aggregate stages #11370 Uzlopak
  • fix: remove on from schema reserved keys #11580 IslandRhythms

6.3.9 / 2022-06-17

  • fix(document): handle nested paths underneath subdocuments when getting all subdocuments for pre save hooks #11917
  • fix(types): correct typing in post aggregate hooks #11924 GCastilho
  • docs: remove connect-option reconnectTries and reconnectInterval #11930 Uzlopak

6.3.8 / 2022-06-13

  • fix: revert 670b445b0fc perf optimizations that caused some test failures #11541

6.3.7 / 2022-06-13

  • fix(schema+document): allow disabling _id on subdocuments by default #11541
  • fix(update): respect global strictQuery option when casting array filters #11836
  • perf(document): avoid unnecessarily creating new options object on every $set #11541
  • fix: toJSON with undefined path #11922 kerryChen95
  • fix: add refPath to SchemaTypeOptions class #11862
  • fix(types): handle boolean default functions #11828
  • docs(populate): make path names in refPath section consistent #11724

6.3.6 / 2022-06-07

  • fix(update): apply timestamps to nested subdocs within $push and $addToSet #11775
  • fix(document): use shallow clone instead of deep clone for toObject() options #11776
  • fix: avoid checking for ObjectId with instanceof #11891 noseworthy
  • fix(types): Allow sorting by text score #11893
  • fix(types): allow schematype get() functions to return undefined #11561
  • fix(types): add Schema.discriminator #11855 Uzlopak
  • fix(types): discriminator generic type not being passed to schema #11898 GCastilho

6.3.5 / 2022-05-30

  • fix(document): avoid infinite recursion when calling toObject() on self-referencing document #11756
  • fix(document): avoid manually populating documents that are manually populated in another doc with different unpopulatedValue #11442
  • fix(document): fix ObjectId conversion for external schemas #11841 coyotte508
  • fix: fix codeql warnings #11817 Uzlopak
  • fix(types): allow passing TVirtuals to Schema class #11543
  • fix(types): Type of Connection.transaction() #11825 dwrss
  • docs(typescript): add coverage for TypeScript query helpers #11709
  • docs: fix documention of error handling #11844 Uzlopak
  • docs: typings mongoose.Error should reference to MongooseError #11850 Uzlopak
  • chore: improve issue templates #11794 Uzlopak
  • chore: use ts-benchmark instead of internal TS benchmarking #11798 mohammad0-0ahmad

6.3.4 / 2022-05-19

  • fix(schema): disallow using schemas with schema-level projection with map subdocuments #11698
  • fix(document): avoid setting nested paths to null when they're undefined #11723
  • fix: allow using comment with findOneAndUpdate(), count(), distinct() and hint with findOneAndUpdate() #11793
  • fix(document): clean modified subpaths when setting nested path to null after modifying subpaths #11764
  • fix(types): allow calling deleteModel() with RegExp in TypeScript #11812
  • docs(typescript): add section on PopulatedDoc to TypeScript populate docs #11685

6.3.3 / 2022-05-09

  • perf: avoid leaking memory when using populate() with QueryCursor because of reusing populate options with _docs #11641
  • fix(types): add _id back for LeanDocument #11769 #11761 taxilian
  • fix(model): add skipValidation option for bulkWrite() to allow skipping validation for insertOne and replaceOne #11663
  • fix(document): correctly $__reset() subdocuments that are under nested paths #11672
  • fix(query): handle casting BSONRegExp instances as RegExps in queries #11597
  • fix: correctly cast $not in $expr #11689
  • perf: optimize size of browser bundle, use buffer v.5.7.1 package to match buffer package of mongodb in browser bundle #11765 Uzlopak
  • docs: Query.populate docs do not include using an array of strings for the path param #11768 #11641 AbdelrahmanHafez
  • chore: add GitHub workflow to close stale "can't reproduce", "help", "needs clarification" issues #11753 Uzlopak
  • chore: remove Makefile dependency for compiling docs #11751 Uzlopak

6.3.2 / 2022-05-02

  • perf: avoid registering event listeners on subdocuments to reduce memory usage #11541
  • fix(setDefaultsOnInsert): set default if sibling of nested path is $set #11668
  • perf(document): remove unnecessary workaround for ignoring subpaths of arrays #11541
  • fix(types): various fixes and improvements for types #11650 taxilian
  • fix(types): make mongoose typings work without esmModuleInterop true #11695 Uzlopak
  • fix(types): support populate(path, fields, model) syntax #11649 #11598 mohammad0-0ahmad
  • fix(types): correct SchemaTypeOptions.get function signature #11561
  • fix: fix browser build for Webpack 5 #11717
  • docs: improve readme #11705 mahendrap1512

6.3.1 / 2022-04-21

  • perf: improve perf of key order #11639 Uzlopak
  • fix(timestamps): set createdAt when creating new single nested subdocuments #11603
  • fix: improve CastError message when throwing StrictModeError #11506
  • fix: upgrade bson to match mongodb@4.5 #11676
  • fix(populate): avoid populating single nested subdocs underneath arrays if there's no ref #11538
  • fix: handle { capped: number } in schema definition with createCollection() #11539
  • fix: call markModified before setting changes in Array and in DocumentArray methods #11660 josegl
  • fix: only allow using minus path to remove auto-selected discriminatorKey from projection #11546
  • fix(types): set context on virtual getters/setters by default #11543
  • fix(types): correct return type for Connection.prototype.transaction #9919
  • fix(types): allow model as document interface key when using extends Document #11629
  • docs: improve populate typing #11690 onichandame
  • docs: add information regarding typings-tests #11691 Uzlopak
  • docs: fix jsdoc for mongoose.createConnection #11693 Uzlopak

6.3.0 / 2022-04-14

  • fix: upgrade mongodb driver -> 4.5.0 #11623 AbdelrahmanHafez
  • feat(schema): allow defining discriminators on schema and in schema definition #7971 IslandRhythms
  • feat(base): add option to set allowDiskUse globally #11554 AbdelrahmanHafez
  • feat(schema): add removeIndex() and clearIndex() #11547 IslandRhythms
  • feat(cursor): add continueOnError option to allow executing eachAsync() on all docs even if error occurs #6355
  • feat(query): add versionKey option to lean() for removing version key from lean docs #8934 IslandRhythms
  • feat(types): create new ProjectionType type for select(), find(), etc. #11437
  • chore: use webpack 5 for browser build #11584 AbdelrahmanHafez

6.2.11 / 2022-04-13

  • fix(document): handle validation with triply nested document arrays #11564
  • fix(query): skip applying string schema setters on $regex #11426
  • fix: skip findOneAndReplace() validation if runValidators = false #11559
  • fix(model): correctly handle schema-level collations in syncIndexes() #7621
  • fix(types): correct populate query return type with lean #11560 mohammad0-0ahmad
  • fix(types): allow using { type: Mixed } as schema type definition for any path #10900
  • docs: fix example on Schema.prototype.post() #11648 EmilienLeroy
  • docs: fix typo in methods/index.js #11651 eltociear

6.2.10 / 2022-04-04

  • fix(types): improve lastErrorObject typing for rawResults #11602 simllll
  • docs(typescript): add note about deprecating extends Document #11619 AbdelrahmanHafez
  • docs: consistent syntax highlighting with upgraded highlight.js #11579 AbdelrahmanHafez

6.2.9 / 2022-03-28

  • perf(document+model): make a few small optimizations #11380
  • fix(types): improve populate return type #11560 mohammad0-0ahmad
  • fix(document): avoid marking paths as modified on subdocument defaults #11528
  • docs(schema): add example to index expires option #11557 boly38
  • docs(model): add change stream docs #11275
  • docs(lambda): update Lambda docs for Mongoose 6 #11275
  • docs(connections): add note about connecting with X509 #11333
  • docs(populate): fix incorrect path name in refPath example #11565 chandiwalaaadhar

6.2.8 / 2022-03-22

  • fix(document): handle casting array of spread docs #11522
  • fix(document): avoid setting nested properties on top-level document when initing with strict: false #11526
  • fix(document): correctly handle deeply nested subdocuments when getting paths to validate #11501
  • fix(types): avoid making TInstanceMethods any by default leading to this = any in middleware #11435
  • fix(types): allow defining array default if using Types.Array<> in document interface #11391
  • docs(migrating_to_6): describe breaking change in Mongoose 6 about default query populate model #11289
  • docs(middleware): fix typo #11537 x1489

6.2.7 / 2022-03-16

  • perf(document): avoid running validation on every array element if there's no validators to run #11380
  • fix(cursor): correctly populate in batches when batchSize is set #11509
  • fix(connection): avoid setting MongoClient on useDb() connections until after setting on base connection #11445
  • fix(schema): throw more helpful error when using schema from a different version of Mongoose module #10453
  • fix: add missing timeseries expiration handling #11489 #11229 Uzlopak
  • docs: correct Model.findOneAndReplace docs param naming #11524 anatolykopyl

6.2.6 / 2022-03-11

  • fix(types): correct reference to cursor TypeScript bindings #11513 SimonHausdorf
  • fix(types): allow calling Query.prototype.populate() with array of strings #11518
  • fix(types): export and refactor types of PreMiddlewareFunction, PreSaveMiddlewareFunction, PostMiddlewareFunction, ErrorHandlingMiddlewareFunction #11485 Uzlopak

6.2.5 / 2022-03-09

  • fix(mongoose): add isObjectIdOrHexString() to better capture the most common use case for isValidObjectId() #11419
  • fix(query): prevent modifying discriminator key in updates using operators other than $set #11456
  • fix(populate+types): call foreignField functions with doc as 1st param, better typings for localField and foreignField functions #11321
  • fix(populate): return an array when using populate count on an array localField #11307
  • fix(query): avoid error when using $not with arrays #11467
  • perf: only deep clone validators if necessary #11412 Uzlopak
  • fix(types): rename definition files to lowercase to avoid typescript bug #11469
  • fix(types): aggregate.sort() accepts a string but also { field: 'asc'|'ascending'|'desc'|'descending' } #11479 simonbrunel
  • fix(types): extract and refactor aggregationcursor and querycursor #11488 Uzlopak
  • fix(types): extract and refactor schemaoptions #11484 Uzlopak
  • fix(types): make first param to Query.prototype.populate() a string #11475 minhthinhls
  • fix(types): improve type checking for doc arrays in schema definitions #11241
  • docs: fix length comparaison in lean.test.js #11493 zazapeta
  • docs(timestamps): fix typo #11481 saibbyweb
  • docs: fix broken link to rawResult #11459 chhiring90

6.2.4 / 2022-02-28

  • fix(query): correctly return full deleteOne(), deleteMany() result #11211
  • fix(query): handle update validators on deeply nested subdocuments #11455 #11394
  • fix(discriminator): handle modifying multiple nested paths underneath a discriminator #11428
  • perf: improve isAsyncFunction #11408 Uzlopak
  • fix(index.d.ts): add typedefs for Schema pick() #11448 Moisei-Shkil
  • fix(index.d.ts): allow type override for distinct() #11306
  • fix(index.d.ts): allow array of validators in schema definition #11355
  • fix(index.d.ts): improve connection typings #11418 Uzlopak
  • docs: add timestamps docs #11336
  • docs(timestamps): explain how timestamps works under the hood #11336
  • docs(migrating_to_6): add model.exists breaking change returning doument instead of boolean #11407 AbdelrahmanHafez
  • docs(index.d.ts): add docs for FilterQuery, UpdateQuery, and LeanDocument #11457 Moisei-Shkil

6.2.3 / 2022-02-21

  • fix(model): avoid dropping base model indexes when using discriminators with Connection.prototype.syncIndexes() #11424 #11421 AbdelrahmanHafez
  • fix(document): handle array defaults when selecting element underneath array #11376
  • fix(populate): correctly handle depopulating populated subdocuments #11436
  • fix(utils): improve deepEqual() handling for comparing objects with non-objects #11417
  • fix(schema): allow declaring array of arrays using [{ type: [String] }] #11252
  • perf: improve validation sync and async by replacing forEach with classic for loops #11414 Uzlopak
  • perf: make hasDollarKeys faster #11401 Uzlopak
  • fix(index.d.ts): ValidationError errors only contains CastError or ValidationError #11369 Uzlopak
  • fix(index.d.ts): make InsertManyResult.insertedIds return an array of Types.ObjectId by default #11197
  • fix(index.d.ts): allow pre('save') middleware with pre options #11257
  • fix(index.d.ts): add supressReservedKeysWarning option to schema #11439 hiukky
  • docs(connections): improve replica set hostname docs with correct error message and info about err.reason.servers #11200
  • docs(populate): add virtual populate match option documentation #11411 remirobichet
  • docs(document): add note to API docs that flattenMaps defaults to true for toJSON() but not toObject() #11213
  • docs(document+model): add populate option to populate() API docs #11170
  • docs(migrating_to_6): add additional info about removing omitUndefined #11038
  • docs(migrating_to_6): add model.exists breaking change returning doument instead of boolean AbdelrahmanHafez

6.2.2 / 2022-02-16

  • fix: fix QueryCursor and AggregationCursor compatibility with Node v17.5 #11381 benjamingr
  • fix: better esm support, no necessity for setting allowSyntheticDefaultImports and esModuleInterop #11343 Uzlopak
  • fix(model): apply projection parameter to hydrate() #11375
  • fix: fix issue with creating arrays of length > 10000 #11405 Uzlopak
  • fix(document): minimize single nested subdocs #11247
  • fix(connection): handle reopening base connection with useDb() #11240
  • perf: use property access instead of get() helper where possible #11389 Uzlopak
  • fix: use isArray() instead of instanceof Array #11393 Uzlopak
  • perf: improve performance of cast$expr() #11388 Uzlopak
  • perf: remove startsWith() from isOperator() #11400 Uzlopak
  • fix(index.d.ts): extract PipelineStage into separate file #11368 Uzlopak
  • fix(index.d.ts): fix $search highlight path option type #11373 lmX2015
  • docs: update changelog file to CHANGELOG.md #11365 AbdelrahmanHafez
  • docs: fix broken links #11388 #11377 saibbyweb
  • docs: remove double determiners in connections docs #11340 Erma32

6.2.1 / 2022-02-07

  • perf: improve performance especially of validate and clone #11298 Uzlopak
  • perf: remove regexp-clone #11327 Uzlopak
  • fix(document): handle initing nested properties in non-strict documents #11309
  • fix(query): cast $elemMatch underneath $all #11314
  • fix(populate): respect schema-level strictPopulate option #11290
  • fix: set default for dotted path projection #11293 noseworthy
  • fix(model): correctly handle writeConcern.w = 0 when saving #11300
  • fix(model): throw VersionError when saving with no changes and optimisticConcurrency = true #11295
  • fix(query): avoid adding $each to $addToSet on mixed arrays #11284
  • fix(index.d.ts): allow using type: [Schema.Types.ObjectId] for ObjectId arrays #11194
  • fix(index.d.ts): make Types.DocumentArray<> convert type to subdoc, rename TMethods -> TMethodsAndOverrides #11061
  • fix(index.d.ts): support passing generic to createCollection() and collection() for integration with MongoDB Node driver's collection class #11131
  • fix(index.d.ts): add strictPopulate to MongooseOptions #11276
  • docs: mark Mongoose 6 as compatible with MongoDB 4 #11320 JavaScriptBach
  • docs: remove documentation for useNestedStrict #11313 mark-langer
  • docs: add "new" to ObjectId class in aggregate.js docs #11322 JavanPoirier
  • chore: handle eslint configuration in .eslintrc.json #11326 Uzlopak
  • refactor: add parenthesis for constructors in tests #11330 apeltop

6.2.0 / 2022-02-02

  • feat: upgrade MongoDB driver to 4.3.1
  • feat(connection+mongoose): add support for continueOnError for syncIndexes #11266 AbdelrahmanHafez
  • feat(query): cast literals in $expr where possible #10663
  • feat(schema+mongoose): add pluginTags to allow applying global plugins to only schemas with matching tags #9780
  • feat(discriminator): support overwriteModels:true to reuse discriminator names #11244 #10931 IslandRhythms
  • feat(index.d.ts): add DocType generic param to Model functions that return queries to better support projections #11156
  • feat(error): export MongooseServerSelectionError #11202
  • feat(schematype): add validators, path, isRequired to public API and TypeScript types #11139
  • fix(model): make exists(...) return lean document with _id or null instead of boolean #11142 AbdelrahmanHafez
  • fix(model): support storing versionKey in nested paths #10980
  • fix(index.d.ts): add options to bulkSave() type def #11201 Uzlopak
  • fix(index.d.ts): better support for query projections #11210 EugeneKorshenko

6.1.10 / 2022-02-01

  • fix(mongoose): correctly handle destructured isValidObjectId #11304
  • fix(mongoose): defer to MongoDB driver isValid() for isValidObjectId() #11227

6.1.9 / 2022-01-31

  • fix(query): respect nested schema strict as default when casting query filters #11291
  • fix(mongoose): make isValidObjectId() consistent with isValid(), make ObjectId() casting more flexible #11209
  • fix(setDefaultsOnInsert): ignore defaults underneath maps #11235
  • fix(query): avoid setting nested schema properties that are stripped out by strictQuery to undefined in query filter #11291
  • fix: check for all flags in a regex deepequal #11242 Uzlopak
  • fix: replace substr with substring #11278 Uzlopak
  • docs: port for documentation testing in CONTRIBUTING.md #11273 Uzlopak

6.1.8 / 2022-01-24

  • fix(connection): stop leaking sessions in .transaction() #11259 #11256 Uzlopak
  • perf: remove sliced in favor of Array.prototype.slice() #11238 Uzlopak
  • perf: improve setDottedPath #11264 Uzlopak
  • fix(document): handle edge case where NestJS sets String.type = String, mixing up schema definitions #11199
  • fix: remove obsolete code after upgrading to bson4 #11265 Uzlopak
  • fix: remove util.isArray in favor of Array.isArray #11234 Uzlopak
  • fix(index.d.ts): avoid UnpackedIntersection making findOne().populate() result non-nullable #11041
  • docs(migration): add note to change default functions to schema #11245 AbdelrahmanHafez
  • docs: updated docs and issue templates for new FAQs #11171 IslandRhythms
  • chore: fix casting benchmark #11262 Uzlopak
  • chore: add mongodb-memory-server to test easier locally #11255 Uzlopak
  • chore: fix testing tsconfig #11243 Uzlopak
  • refactor: move utils.random to test folder #11239 Uzlopak

6.1.7 / 2022-01-17

  • fix(model): correct handling for $push on a nested array #11108
  • fix(update): correctly apply timestamps to update pipelines #11151
  • fix(document): correctly handle modifying array subdocument after setting array subdocument to itself #11172
  • fix(index.d.ts): allow passing options to model() in place of removed skipInit #11137
  • fix(aggregate): allow passing verbosity to Aggregate.prototype.explain() #11144
  • fix(index.d.ts): avoid TypeScript inferring _id as any type with HydratedDocument #11085
  • docs: fix Node.js Driver compat link #11214 wesbos
  • docs: remove extraneous backquote #11204 joebowbeer

6.1.6 / 2022-01-10

  • perf(document): delay creating document event emitter until used to improve memory usage, several small improvements to improve initing docs with large arrays #10400
  • fix(model): avoid bulkSave() error when versionKey: false #11186 #11071 IslandRhythms
  • fix(model): revert #11079: findByIdAndUpdate(undefined) breaking change #11149
  • fix(index.d.ts): support strings in deep populate #11181 ivalduan
  • fix(index.d.ts): rename map() -> transform() to line up with change in v6.0 #11161
  • fix(index.d.ts): allow new Model(obj) for stricter type checks #11148
  • fix(index.d.ts): make Schema.prototype.pre() and post() generics default to HydratedDocument #11180
  • docs: improve autoCreate docs #11116
  • docs(schematype): add missing parameter to example #11185 kerolloz
  • docs(connections): use updated link to list of MongoDB Node driver connect() options #11184 splinter
  • docs(aggregate): fix formatting #11191 enieber
  • docs: fix broken link #11179 khairnarsaurabh23

6.1.5 / 2022-01-04

  • perf(index.d.ts): simplify Schema typedef for query helpers and methods to significantly reduce TS compiler overhead #10349
  • fix(document): allow populating deeply nested models as strings #11168 #11160 AbdelrahmanHafez
  • fix(query): allow calling limit() and skip() with a string #11017
  • fix(cursor): propery apply selected fields when loading discriminator docs with query cursor #11130
  • fix(mongoose+connection): clone schema correctly when passing instance of another Mongoose instance's Schema to Connection.prototype.model() #11047
  • fix(index.d.ts): handle primitives with FlattenMaps #11117
  • fix(index.d.ts): enforce id on lean query result type #11118
  • fix(index.d.ts): export facet stage type #11150 mhoc
  • fix(index.d.ts): correct return type of projection method #11176 EugeneKorshenko
  • fix(index.d.ts): additional fix for $group pipeline stage #11140 #11067 EugeneKorshenko
  • docs: update CONTRIBUTING.md for TS tests #11164 ahmedelshenawy25
  • docs: use es6 object destructuring instead of regular dot operator for accessing value in object #11147 Shivaansh-Agarwal

6.1.4 / 2021-12-27

  • fix(document): handle save with undefined nested doc under subdoc #11110
  • fix(document): allow manually populating subdocument refs with create() #10856
  • fix(populate): handles refPath underneath map of subdocuments #9359
  • fix(update): throw error when calling findByIdAndUpdate with undefined id #11079 gramliu
  • fix(mongoose): export ConnectionStates #11133 orgads
  • fix(index.d.ts): unpack array when using generic type override with populate() #11027
  • fix(index.d.ts): fix typings in Merge stage #11132
  • fix(index.d.ts): PipelineStage.Merge interface definition is wrong #11109
  • docs(typescript): add note about Schema.Types.ObjectId vs Types.ObjectId in document definition #10949
  • docs(connection): clarify that "connected" and "open" are different #10886
  • docs(populate): correct refPath example to not use on as a schema path name #11113
  • docs: fix strictQuery example #11135 MontgomeryWatts

5.13.14 / 2021-12-27

  • fix(timestamps): avoid setting createdAt on documents that already exist but dont have createdAt #11024
  • docs(models): fix up nModified example for 5.x #11055

6.1.3 / 2021-12-21

  • perf(populate): avoid duplicate model names when using refPath to avoid O(n^2) memory growth with number of array elements #10983
  • fix(schema+model): cast paths marked with ref when hydrating #11052
  • fix(schema): handle default function that returns null on document arrays #11058
  • fix(document): clean modified paths when setting deeply nested subdocument #11060
  • fix(populate): report full path when throwing strictPopulate error with deep populate #10923
  • fix(connection): allow calling setClient() when disconnected #11114 hustxiaoc
  • fix(index.d.ts): fix typings in Group stage #11124 DavideViolante
  • fix(index.d.ts): add Mongoose.prototype.trusted() function to type defs #10957
  • fix(index.d.ts): allow use type string in $unset update with aggregation pipeline #11107 rpenido
  • fix(index.d.ts) treat _id like other fields in $project #11102
  • docs(migrating_to_6): add omitUndefined to Mongoose 6 migration guide #10672
  • docs: add MongooseDocumentArray to API docs #10998
  • docs: fix typo in model.js #11121 eltociear
  • docs: fix typo in validation.md #11103 warlock1996

6.1.2 / 2021-12-14

  • fix: upgrade mongodb driver to 4.2.2 #11092 lorand-horvath
  • fix(model): respect discriminators when calling Model.watch() #11007
  • fix(populate): allow referencing parent connection models by name when using useDb() #11003
  • fix(query): support options param to Query.prototype.countDocuments() #11037
  • fix(query): correctly use awaitData instead of awaitdata in Query.prototype.tailable() #10875
  • fix(index.d.ts): fix replaceRoot type #11098 alibehroozi
  • fix(index.d.ts): add missing syncIndexes() definition to Mongoose global and Connection class #11065
  • fix(index.d.ts): add boolean type for transform option #11057 AliYusuf95
  • docs(model.estimatedDocumentCount): add await into example to get value from the Query #11044 olecom
  • docs: fix broken build from awaitdata comment #11096 medolino
  • docs: correct Query.prototype.transform() docs #11094 medolino

6.1.1 / 2021-12-09

  • fix(document): allow setting nested path to instance of document #11011
  • fix(update): respect strict option when casting array filters #11062
  • fix(index.d.ts): allow SchemaTypes.Mixed for all schema definition properties to allow using union types #10900
  • fix(index.d.ts): correct types for Schema.prototype.obj and Model.schema #10895
  • docs(migrating_to_6): add note about Types.ObjectId() being a class and requiring new #10960

6.1.0 / 2021-12-07

  • feat(populate): support ref on subdocuments #10856
  • feat(document): add ownerDocument() method to top-level document for consistency with subdocs #10884 IslandRhythms
  • fix: upgrade to mongodb driver 4.2.1 #11032 #10985 lorand-horvath has-n
  • feat(schema): support timeseries option for MongoDB 5 time series collections support #10611
  • feat(mongoose): add global strictPopulate option #10694 IslandRhythms
  • feat(mongoose+connection): add global mongoose.syncIndexes() and Connection.prototype.syncIndexes() #10893 IslandRhythms
  • feat(query): support removing fields from projections #10630 canac
  • feat(aggregate): add unionWith method to aggregate #10961 saeidasadi
  • fix(index.d.ts): types for aggregation pipeline stages #10971 jeremyben

6.0.15 / 2021-12-06

  • fix(document): avoid overwriting schema methods when creating a new document with new Model() and strict: false #11001
  • fix(document): avoid overwriting top-level document _id with nested _id when strict = false #10934
  • fix(collection): avoid double-calling callback on sync error #10956
  • fix(connection): handle direct connection to uninitialized replica set that then becomes initialized #10948
  • fix(index.d.ts): allow partial updates on subdocuments for defaults #10947
  • fix(index.d.ts): handle buffer type in schema definitions #11026

6.0.14 / 2021-11-29

  • fix(document): catch errors in required functions #10968
  • fix(connection): clone schema when passing a schema from a different copy of Mongoose to Connection#model() #10904
  • fix(populate): set empty array [] on virtual populate with no result #10992
  • fix(query): handle orFail() with replaceOne() #10963
  • fix(populate): use Model by default when using Model.populate() on a POJO #10978
  • fix(document): throw VersionError if saving a document with version bump and document isn't found #10974
  • fix(index.d.ts): make populate type param optional #10989 mohd-akram
  • docs(migrating_to_6): add a note about minimize and toObject() behavior change in v5.10.5 #10827
  • docs: remove duplicate path in docs #11020 ItWorksOnMyMachine
  • docs: fix typo in populate docs #11015 gavi-shandler
  • docs: fix typo in model.js #10982 eltociear

6.0.13 / 2021-11-15

  • fix(document): allows validating doc again if pre validate errors out #10830
  • fix: upgrade to mongodb driver 4.1.4 #10955 mohd-akram
  • fix(schema): handle functions with accidental type properties in schema definitions #10807
  • fix(path): add check to avoid flattening dotted paths on Mongoose docs, improve error when flattening dotted paths causes conflicts #10825
  • fix(index.d.ts): rename EnforceDocument -> HydratedDocument, export HydratedDocument for easier typing for users #10843
  • fix(index.d.ts): handle maps in TypeScript schema definitions #10838
  • fix(index.d.ts): add clone to query #10943 asportnoy
  • fix(index.d.ts): add strictQuery global option #10933
  • fix(index.d.ts): add generic to allow overriding Schema#clone() return type #10951 StefanoA1
  • docs(typescript): add quick guide to virtuals in TypeScript #10754
  • docs(aggregate): remove exec() from AggregationCursor example, no longer correct for Mongoose 6 #10862
  • docs(document.js): fix link leading to old github pages site #10958 PuneetGopinath
  • docs: fixed typo in document.js #10950 Haosik

5.13.13 / 2021-11-02

  • fix: upgrade to mongodb@3.7.3 #10909 gaurav-sharma-gs
  • fix: correctly emit end event in before close #10916 iovanom
  • fix(index.d.ts): improve ts types for query set #10942 jneal-afs

6.0.12 / 2021-10-21

  • fix(cursor): remove the logic for emitting close, rely on autoDestroy option for Node 12 support #10906 iovanom
  • fix(map): support passing flattenMaps: false to Map toJSON(), make toJSON() flatten maps by default in TypeScript #10872
  • fix: upgrade to mongodb driver 4.1.3 #10911 orgads
  • fix(index.d.ts): correct TS function signature for SchemaType.prototype.set() #10799
  • fix(index.d.ts): support implicit $in in FilterQuery #10826
  • fix(index.d.ts): More precise type for Schema.clone() #10899 coyotte508
  • fix(index.d.ts): add caster property to schema arrays and document arrays #10865
  • docs: update updateMany() and deleteMany() docs to reflect new matchedCount, modifiedCount, deletedCount properties #10908 IslandRhythms
  • docs: fix broken links to populate virtuals #10870 IslandRhythms
  • docs: updated docs to have returnOriginal, removed new and returnDocument #10887 IslandRhythms

5.13.12 / 2021-10-19

  • fix(cursor): use stream destroy method on close to prevent emitting duplicate 'close' #10897 iovanom
  • fix(index.d.ts): backport streamlining of FilterQuery and DocumentDefinition to avoid "excessively deep and possibly infinite" TS errors #10617

6.0.11 / 2021-10-14

  • perf(index.d.ts): remove some unnecessary definitions, streamline some union types to reduce number of instantiations #10349
  • fix(cursor): use stream destroy method on close to prevent emitting duplicate 'close' #10878 #10876 iovanom
  • fix: create indexes when readPreference=primary is set #10861 #10855 gemyero
  • fix(document): avoid depopulating when setting array of subdocs from different doc #10819
  • fix(index.d.ts): allow modifying properties of UpdateQuery instances #10786
  • fix(index.d.ts): add generic Paths to populate() to allow overriding path types #10758

5.13.11 / 2021-10-12

  • fix: upgrade mongodb -> 3.7.2 #10871 winstonralph
  • fix(connection): call setMaxListeners(0) on MongoClient to avoid event emitter memory leak warnings with useDb() #10732

6.0.10 / 2021-10-08

  • fix(query): add back strictQuery option to avoid empty filter issues, tie it to strict by default for compatibility #10781 #10763
  • fix(model): avoid unnecessarily dropping text indexes in syncIndexes() #10851 #10850 IslandRhythms
  • fix(query): avoid trying to call toArray() on cursor if find() error occurred #10845
  • fix: accepts uppercase values in mongoose.isValidObjectId #10846 foxadb
  • perf(document): further reduce unnecessary objects and keys to minimize document memory overhead #10400
  • fix(index.d.ts): restore unpacked type and avoid distributive conditional types #10859 dbellavista
  • fix(index.d.ts): add correct null typings for findOneAndUpdate() and findByIdAndUpdate() #10820
  • fix(index.d.ts): make insertMany() correctly return Promise if passing single document to insertMany() #10802
  • fix(index.d.ts): avoid weird issue where TypeScript 4.3.x and 4.4.x makes string extend Function #10746
  • fix(index.d.ts): allow type: SchemaTypeOptions[] when defining schema #10789
  • fix(index.d.ts): allow using $in with enum fields #10757 #10734
  • fix(index.d.ts): add missing fields and options params to Model constructor #10817
  • fix(index.d.ts): support extending type for mongoose.models #10806 MunifTanjim
  • docs: enhance docs section linking #10779 saveman71
  • docs(middleware): add missing query middleware #10721
  • docs: fix typo #10853 mdatif796
  • docs: add missing to #10848 digidub

5.13.10 / 2021-10-05

  • fix(index.d.ts): allow using type: SchemaDefinitionProperty in schema definitions #10674
  • fix(index.d.ts): allow AnyObject as param to findOneAndReplace() #10714

6.0.9 / 2021-10-04

  • fix(document): init non-schema values if strict is set to false #10828
  • fix(document): correctly track saved state for deeply nested objects #10773
  • fix(array): avoid mutating arrays passed into Model() constructor #10766
  • fix(cursor): allow using find().cursor() before connecting, report errors in pre('find') hooks when using .cursor() #10785
  • fix(populate): support ref: Model with virtual populate #10695
  • fix(schema): support type: { subpath: String } in document array definitions and improve schema interpretAsType error messages if type name is undefined #10750
  • fix: upgrade to mongodb driver 4.1.2 #10810 orgads
  • fix(subdocument): add extra precaution to throw an error if a subdocument is a parent of itself in ownerDocument() #9259
  • perf(index.d.ts): make model() call more strict to improve VS Code autocomplete perf #10801 traverse1984
  • fix(index.d.ts): allow calling depopulate with 0 args #10793
  • fix(index.d.ts): Add type definitions for allowDiskUse #10791 coyotte508
  • docs(populate): expand virtual populate docs with info on principle of least cardinality and other info #10558
  • docs: add migration guide to side bar #10769
  • docs(connections+api): clarify that maxPoolSize is now 100 by default #10809
  • docs(schema): add Schema#virtuals to docs as a public property #10829
  • docs: remove array indexes section from FAQ #10784 Duchynko
  • docs(model): fix broken example #10831 Okekeprince1
  • docs: fix markdown issue with schemas.md #10839 aseerkt

6.0.8 / 2021-09-27

  • fix: support $set on elements of map of subdocuments #10720
  • fix(schematype): handle schema type definition where unique: false and index not set #10738
  • fix(timestamps): handle createdAt with custom typeKey #10768 #10761 jclaudan
  • fix(model): amend Model.translateAliases to observe non-aliased sub schemas #10772 frisbee09
  • fix: allow ObjectId#valueOf() to override built-in Object#valueOf(), clarify using == with ObjectIds in migration guide #10741
  • fix: use process.emitWarning() instead of console.warn() for warnings #10687
  • fix(index.d.ts): allow array of schema type options for string[], number[] property Schema definitions #10731
  • fix(index.d.ts): make built-in subdocument properties not required in UpdateQuery #10597
  • docs(ssl): correct sslCA option and clarify that sslCA should be the path to the CA file #10705

6.0.7 / 2021-09-20

  • fix(populate): wrap populate filters in trusted() so they work with sanitizeFilter #10740
  • fix(aggregate): handle calling aggregate() before initial connection succeeds #10722
  • fix(query): avoid throwing error when using $not with $size #10716 IslandRhythms
  • fix(discriminator): handle setting nested discriminator paths #10702
  • fix(documentarray): don't throw TypeError on DocumentArray#create() when top-level doc has populated paths #10749
  • fix(update): avoid setting single nested subdoc defaults if subdoc isn't set #10660
  • fix: delay creating id virtual until right before model compilation to allow plugins to disable the id option #10701
  • fix(connection): correct auth object when using user option to connect() #10727 #10726 saveman71
  • fix(timestamps): avoid calling getters when checking whether createdAt is set #10742 kaishu16
  • fix(index.d.ts): allow using strings for ObjectIds with $in #10735
  • fix(index.d.ts): add TVirtuals generic to Model to make it easier to separate virtuals from DocType #10689
  • fix(index.d.ts): add Model.bulkSave() definition #10745
  • fix(index.d.ts): allow RegExp for match in schema definition #10744 easen-amp
  • fix(index.d.ts): allow arbitrary additional keys in QueryOptions #10688
  • docs: correct TypeScript schema generic params in docs #10739 minifjurt123
  • docs: fix h2 header links #10682 IslandRhythms

6.0.6 / 2021-09-15

  • perf(index.d.ts): streamline SchemaDefinitionType and SchemaTypeOptions to reduce number of instantiations and speed up lib checking #10349
  • perf(document): make $locals a getter/setter, avoid creating unnecessary undefined properties in Document constructor, remove unnecessary event listeners #10400
  • fix(connection): use username parameter for MongoDB driver instead of user #10727 saveman71
  • fix(update): handle casting $or and $and in array filters #10696
  • fix(connection): allow calling connection helpers before calling mongoose.connect() #10706
  • fix(document): correctly handle subpaths of arrays that contain non-alphanumeric chars like - #10709
  • fix(index.d.ts): correct return value for findOneAndUpdate(), findByIdAndUpdate() to support query helpers #10658
  • fix(index.d.ts): add missing methods to ValidationError & ValidatorError classes #10725 medfreeman
  • perf(subdocument): make internal $isSingleNested and $isDocumentArrayElement properties constants on the prototype rather than setting them on every instance #10400
  • docs: improve Document#populate documentation, tests #10728 saveman71

6.0.5 / 2021-09-06

  • fix(model): allow calling Model.validate() static with POJO array #10669
  • fix(cast): let $expr through in query filters if strict mode enabled #10662
  • fix(map): propagate flattenMaps option down to nested maps #10653
  • fix(setDefaultsOnInsert): avoid adding unnecessary auto _id to $setOnInsert #10646
  • fix(schema): support object with values and message syntax for Number enums #10648
  • fix(index.d.ts): fix Document#populate() type #10651 thiagokisaki
  • fix(index.d.ts): allow using $in and $nin on array paths #10605
  • fix(index.d.ts): make _id required in query results and return value from create() #10657
  • docs: update deprecations.md to reflect version 6 #10673 multiwebinc
  • docs: fix typo in queries.md #10681 yogabonito
  • docs: fix typo in models.md #10680 yogabonito
  • ci: add test for ubuntu-20.04 #10679 YC

5.13.9 / 2021-09-06

  • fix(populate): avoid setting empty array on lean document when populate result is undefined #10599
  • fix(document): make depopulate() handle populated paths underneath document arrays #10592
  • fix: peg @types/bson version to 1.x || 4.0.x to avoid stubbed 4.2.x release #10678
  • fix(index.d.ts): simplify UpdateQuery to avoid "excessively deep and possibly infinite" errors with extends Document and any #10647
  • fix(index.d.ts): allow specifying weights as an IndexOption #10586
  • fix: upgrade to mpath v0.8.4 re: security issue #10683

6.0.4 / 2021-09-01

  • fix(schema): handle maps of maps #10644
  • fix: avoid setting defaults on insert on a path whose subpath is referenced in the update #10624
  • fix(index.d.ts): simplify UpdateQuery to avoid "excessively deep and possibly infinite" errors with extends Document and any #10617
  • fix(index.d.ts): allow using type: [documentDefinition] when defining a doc array in a schema #10605
  • docs: remove useNewUrlParser, useUnifiedTopology, some other legacy options from docs #10631 #10632
  • docs(defaults): clarify that setDefaultsOnInsert is true by default in 6.x #10643
  • test: use async/await instead of co #10633 AbdelrahmanHafez

6.0.3 / 2021-08-30

  • fix: handle buffering with find() now that find() no longer accepts a callback #10639 #10634 #10610

6.0.2 / 2021-08-26

  • fix(query): handle find() when buffering on initial connection #10610
  • fix(populate): get doc schema using $__schema to avoid paths named schema #10619
  • docs: use async/await in the quickstart #10610
  • docs: fix links to guide, schematypes, connections in v5.x docs #10607
  • docs: add link to 6.x migration guide to schemas guide #10616
  • docs: add migration to 6.x in Migration Guides section #10618 HunterKohler
  • docs: fix missing URL part on layout.pug #10622 ItsLhun

6.0.1 / 2021-08-25

  • fix(aggregate): allow calling Model.aggregate() with options #10604 amitbeck
  • fix(index.d.ts): add instance, options, schema properties to SchemaType class #10609
  • fix(index.d.ts): allow querying array of strings by string #10605
  • fix(index.d.ts): allow using type: SchemaDefinitionProperty in schema definitions #10605
  • fix(index.d.ts): remove strictQuery option #10598 thiagokisaki
  • docs: add link to migration guide in changelog #10600 AbdelrahmanHafez
  • docs: fix docs build for v5.x docs #10607
  • docs(query): add note about strict option to setOptions() #10602

6.0.0 / 2021-08-24

  • Follow the migration guide to get a list of all breaking changes in v6.0.
  • BREAKING CHANGE: remove the deprecated safe option in favor of write concerns
  • fix: upgrade to mongodb driver 4.1.1
  • fix: consistently use $__parent to store subdoc parent as a property, and $parent() as a getter function #10584 #10414
  • fix: allow calling countDocuments() with options

6.0.0-rc2 / 2021-08-23

  • BREAKING CHANGE: make document set() set keys in the order they're defined in the schema, not in the user specified object #4665
  • BREAKING CHANGE: remove most schema reserved words - can now opt in to using save, isNew, etc. as schema paths #9010 AbdelrahmanHafez
  • BREAKING CHANGE: upgrade mquery -> 4.x #10579
  • BREAKING CHANGE: remove some legacy type aliases for TypeScript
  • fix(document): pass depopulated value to array element validators for consistency #10585 #8042

5.13.8 / 2021-08-23

  • fix(populate): handle populating subdoc array virtual with sort #10552
  • fix(model): check for code instead of codeName when checking for existing collections for backwards compat with MongoDB 3.2 #10420
  • fix(index.d.ts): correct value of this for custom query helper methods #10545
  • fix(index.d.ts): allow strings for ObjectIds in nested properties #10573
  • fix(index.d.ts): add match to VirtualTypeOptions.options #8749
  • fix(index.d.ts): allow QueryOptions populate parameter type PopulateOptions #10587 osmanakol
  • docs(api): add Document#$where to API docs #10583

6.0.0-rc1 / 2021-08-12

  • feat: upgrade to MongoDB driver 4.1.0 #10567 #10560
  • feat: add valueOf() to ObjectId prototype #7299
  • BREAKING CHANGE: rename History.md -> CHANGELOG.md #10542

5.13.7 / 2021-08-11

  • perf(index.d.ts): loosen up restrictions on ModelType generic for Schema for a ~50% perf improvement when compiling TypeScript and using intellisense #10536 #10515 #10349
  • fix(index.d.ts): fix broken Schema#index() types #10562 JaredReisinger
  • fix(index.d.ts): allow using SchemaTypeOptions with array of raw document interfaces #10537
  • fix(index.d.ts): define IndexOptions in terms of mongodb.IndexOptions #10563 JaredReisinger
  • fix(index.d.ts): improve intellisense for DocumentArray push() #10546
  • fix(index.d.ts): correct type for expires #10529
  • fix(index.d.ts): add Query#model property to ts bindings #10531
  • refactor(index.d.ts): make callbacks use the new Callback and CallbackWithoutResult types #10550 thiagokisaki

5.13.6 / 2021-08-09

  • fix: upgrade mongodb driver -> 3.6.11 #10543 maon-fp
  • fix(schema): throw more helpful error when defining a document array using a schema from a different copy of the Mongoose module #10453
  • fix: add explicit check on constructor property to avoid throwing an error when checking objects with null prototypes #10512
  • fix(cursor): make sure to clear stack every 1000 docs when calling next() to avoid stack overflow with large batch size #10449
  • fix(index.d.ts): allow calling new Model(...) with generic Model param #10526
  • fix(index.d.ts): update type declarations of Schema.index method #10538 #10530 Raader
  • fix(index.d.ts): add useNewUrlParser and useUnifiedTopology to ConnectOptions #10500
  • fix(index.d.ts): add missing type for diffIndexes #10547 bvgusak
  • fix(index.d.ts): fixed incorrect type definition for Query's .map function #10544 GCastilho
  • docs(schema): add more info and examples to Schema#indexes() docs #10446
  • chore: add types property to package.json #10557 thiagokisaki

6.0.0-rc0 / 2021-08-03

  • BREAKING CHANGE: upgrade to MongoDB Node.js driver 4.x. This adds support for MongoDB 5.0, drops support for Node.js < 12.0.0 #10338 #9840 #8759
  • BREAKING CHANGE(connection): make connections not thenable, add Connection#asPromise() to use a connection as a promise #8810
  • BREAKING CHANGE: throw an error if the same query object is executed multiple times #7398
  • BREAKING CHANGE: Mongoose arrays are now proxies, which means directly setting an array index doc.arr[0] = 'test' triggers change tracking #8884
  • BREAKING CHANGE: make Document#populate() return a promise if a callback isn't passed, remove execPopulate() #3834
  • BREAKING CHANGE: virtual getters and setters are now executed in forward order, rather than reverse order. This means you can add getters/setters to populated virtuals #8897 ggurkal
  • BREAKING CHANGE: make setDefaultsOnInsert true by default. Set to false to disable it. #8410
  • BREAKING CHANGE: throw error by default if populating a path that isn't in the schema #5124
  • BREAKING CHANGE: make schema paths declared with type: { name: String } create a single nested subdoc, remove typePojoToMixed because it is now always false #7181
  • BREAKING CHANGE: remove context option for queries, always use context: 'query' #8395
  • BREAKING CHANGE: array subdocument class now inherits from single subdocument class #8554
  • BREAKING CHANGE: if model is registered on a non-default connection, don't register it on mongoose global #5758
  • BREAKING CHANGE: Aggregate#cursor() now returns aggregation cursor, rather than aggregate instance #10410 IslandRhythms
  • BREAKING CHANGE: useStrictQuery is removed, strict applies for both #9015
  • BREAKING CHANGE: overwrite instead of merging when setting nested paths #9121
  • BREAKING CHANGE: call ref and refPath functions with subdoc being populated, not top-level doc #8469
  • BREAKING CHANGE: remove useFindAndModify option, always use MongoDB's native findOneAndReplace() rather than legacy findAndModify() #8737
  • BREAKING CHANGE: always pass unpopulated value to validators #8042 IslandRhythms
  • BREAKING CHANGE: rename Embedded/SingleNestedPath -> Subdocument/SubdocumentPath #10419
  • BREAKING CHANGE: call setters with priorVal as 2nd parameter, and with new subdocument as context if creating new document #8629
  • BREAKING CHANGE: pass document as first parameter to default functions #9633 AbdelrahmanHafez
  • BREAKING CHANGE: make filter, flat, flatMap, map, and slice return vanilla JS arrays #8356
  • BREAKING CHANGE: make autoCreate true by default #8814
  • BREAKING CHANGE: clone schema passed to discriminator() #8552
  • BREAKING CHANGE: make autoIndex and autoCreate default to false if connection's read preference is 'secondary' or 'secondaryPreferred' #9374 chumager
  • BREAKING CHANGE: make deepEqual treat objects with different order of keys as different #9571 AbdelrahmanHafez
  • BREAKING CHANGE: Make Model.exists() return a query rather than a promise, and resolve to doc or null, rather than true/false #8097
  • BREAKING CHANGE: Model.create([]) now returns an empty array rather than undefined #8792 AbdelrahmanHafez
  • BREAKING CHANGE: createdAt schema path is now immutable by default #10139 IslandRhythms
  • BREAKING CHANGE: dont start buffering when database is disconnected #8702
  • BREAKING CHANGE: emit 'disconnected' when losing connectivity to replica set primary #9262
  • BREAKING CHANGE: Make Aggregate#model() always return a model rather than an aggregate instance #7702
  • BREAKING CHANGE: remove omitUndefined option for updates - Mongoose now always removes undefined keys in updates #7680
  • BREAKING CHANGE: remove Aggregate#addCursorFlag(), use Aggregate#options() instead #8701
  • BREAKING CHANGE: rename Query#map() -> Query#transform() to avoid conflating with Array#map() and chaining #7951
  • BREAKING CHANGE: remove storeSubdocumentValidationError schema option, never store subdocument ValidationErrors #5226
  • BREAKING CHANGE(query): make find() with explain() return object instead of an array #8551
  • BREAKING CHANGE: allow undefined in number arrays unlles required #8738
  • BREAKING CHANGE: remove isAsync option for validators in favor of checking if a function is an async function #10502
  • BREAKING CHANGE: drop support for Model#model #8958 AbdelrahmanHafez
  • BREAKING CHANGE: remove useNestedStrict, use nested schema strict mode when casting updates unless strict is explicitly specified in query options #8961
  • BREAKING CHANGE: remove safe-buffer, make MongooseBuffer extend from native Buffer #9199 AbdelrahmanHafez
  • BREAKING CHANGE(schema): skip adding id virtual if schema doesn't have an _id path #3936
  • BREAKING CHANGE: remove skipInit parameter to mongoose.model() #4625
  • BREAKING CHANGE: make pluralize convert "goose" to "geese" #9278
  • BREAKING CHANGE: the Schema#noId option is now removed, please use _id instead #9398
  • BREAKING CHANGE: remove MONGOOSE_DRIVER_PATH, use a setDriver() function on Mongoose instance instead #9604
  • feat(mongoose+query): add sanitizeFilter option and mongoose.trusted() to defend against query selector injection attacks #3944
  • feat(query): add Query#clone() so you can more easily re-execute a query #8708
  • feat(virtual+populate): allow foreignField to be a function #8568 BJvdA

5.13.5 / 2021-07-30

  • perf(index.d.ts): improve typescript type checking performance #10515 andreialecu
  • fix(index.d.ts): fix debug type in MongooseOptions #10510 thiagokisaki
  • docs(api): clarify that depopulate() with no args depopulates all #10501 gfrancz

5.13.4 / 2021-07-28

  • fix: avoid pulling non-schema paths from documents into nested paths #10449
  • fix(update): support overwriting nested map paths #10485
  • fix(update): apply timestamps to subdocs that would be newly created by $setOnInsert #10460
  • fix(map): correctly clone subdocs when calling toObject() on a map #10486
  • fix(cursor): cap parallel batchSize for populate at 5000 #10449
  • fix(index.d.ts): improve autocomplete for new Model() by making doc an object with correct keys #10475
  • fix(index.d.ts): add MongooseOptions interface #10471 thiagokisaki
  • fix(index.d.ts): make LeanDocument work with PopulatedDoc #10494
  • docs(mongoose+connection): correct default value for bufferTimeoutMS #10476
  • chore: remove unnecessary 'eslint-disable' comments #10466 thiagokisaki

5.13.3 / 2021-07-16

  • fix(model): avoid throwing error when bulkSave() called on a document with no changes #10437
  • fix(timestamps): apply timestamps when creating new subdocs with $addToSet and with positional operator #10447
  • fix(schema): allow calling Schema#loadClass() with class that has a static getter with no setter #10436
  • fix(model): handle re-applying object defaults after explicitly unsetting #10442 semirturgay
  • fix: bump mongodb driver -> 3.6.10 #10440 AbdelrahmanHafez
  • fix(index.d.ts): consistently use NativeDate instead of Date for Date validators and timestamps functions #10426
  • fix(index.d.ts): allow calling discriminator() with non-document #10452 #10421 DouglasGabr
  • fix(index.d.ts): allow passing ResultType generic to Schema#path() #10435

5.13.2 / 2021-07-03

  • fix: hardcode @types/node version for now to avoid breaking changes from DefinitelyTyped/DefinitelyTyped#53669 #10415
  • fix(index.d.ts): allow using type: Date with Date paths in SchemaDefinitionType #10409
  • fix(index.d.ts): allow extra VirtualTypeOptions for better plugin support #10412
  • docs(api): add SchemaArray to docs #10397
  • docs(schema+validation): fix broken links #10396
  • docs(transactions): add note about creating a connection to transactions docs #10406

5.13.1 / 2021-07-02

  • fix(discriminator): allow using array as discriminator key in schema and as tied value #10303
  • fix(index.d.ts): allow using & Document in schema definition for required subdocument arrays #10370
  • fix(index.d.ts): if using DocType that doesn't extends Document, default to returning that DocType from toObject() and toJSON() #10345
  • fix(index.d.ts): use raw DocType instead of LeanDocument when using lean() with queries if raw DocType doesn't extends Document #10345
  • fix(index.d.ts): remove err: any in callbacks, use err: CallbackError instead #10340
  • fix(index.d.ts): allow defining map of schemas in TypeScript #10389
  • fix(index.d.ts): correct return type for Model.createCollection() #10359
  • docs(promises+discriminators): correctly escape () in regexp to pull in examples correctly #10364
  • docs(update): fix outdated URL about unindexed upsert #10406 grimmer0125
  • docs(index.d.ts): proper placement of mongoose.Date JSDoc thiagokisaki

5.13.0 / 2021-06-28

  • feat(query): add sanitizeProjection option to opt in to automatically sanitizing untrusted query projections #10243
  • feat(model): add bulkSave() function that saves multiple docs in 1 bulkWrite() #9727 #9673 AbdelrahmanHafez
  • feat(document): allow passing a list of virtuals or pathsToSkip to apply in toObject() and toJSON() #10120
  • fix(model): make Model.validate use object under validation as context by default #10360 AbdelrahmanHafez
  • feat(document): add support for pathsToSkip in validate and validateSync #10375 AbdelrahmanHafez
  • feat(model): add diffIndexes() function that calculates what indexes syncIndexes() will create/drop without actually executing any changes #10362 IslandRhythms
  • feat(document): avoid using sessions that have ended, so you can use documents that were loaded in the session after calling endSession() #10306

5.12.15 / 2021-06-25

  • fix(index.d.ts): add extra TInstanceMethods generic param to Schema for cases when we can't infer from Model #10358
  • fix(index.d.ts): added typings for near() in model aggregation #10373 tbhaxor
  • fix(index.d.ts): correct function signature for Query#cast() #10388 lkho
  • docs(transactions): add import statement #10365 JimLynchCodes
  • docs(schema): add missing discriminatorKey schema option #10386 #10376 IslandRhythms
  • docs(index.d.ts): fix typo #10363 houssemchebeb

5.12.14 / 2021-06-15

  • fix(schema): check that schema type is an object when setting isUnderneathDocArray #10361 vmo-khanus
  • fix(document): avoid infinite recursion when setting single nested subdoc to array #10351
  • fix(populate): allow populating nested path in schema using Model.populate() #10335
  • fix(drivers): emit operation-start/operation-end events to allow inspecting when operations start and end
  • fix(index.d.ts): improve typings for virtuals #10350 thiagokisaki
  • fix(index.d.ts): correct constructor type for Document #10328
  • fix(index.d.ts): add ValidationError as a possible type for ValidationError#errors #10320 IslandRhythms
  • fix: remove unnecessary async devDependency that's causing npm audit warnings #10281
  • docs(typescript): add schemas guide #10308
  • docs(model): add options parameter description to Model.exists() #10336 Aminoiz

5.12.13 / 2021-06-04

  • perf(document): avoid creating nested paths when running $getAllSubdocs() #10275
  • fix: make returnDocument option work with findOneAndUpdate() #10232 #10231 cnwangjie
  • fix(document): correctly reset subdocument when resetting a map subdocument underneath a single nested subdoc after save #10295
  • perf(query): avoid setting non-null sessions to avoid overhead from $getAllSubdocs() #10275
  • perf(document): pre split schematype paths when compiling schema to avoid extra overhead of splitting when hydrating documents #10275
  • perf(schema): pre-calculate mapPaths to avoid looping over every path for each path when initing doc #10275
  • fix(index.d.ts): drill down into nested arrays when creating LeanDocument type #10293

5.12.12 / 2021-05-28

  • fix(documentarray): retain atomics when setting to a new array #10272
  • fix(query+model): fix deprecation warning for returnOriginal with findOneAndUpdate() #10298 #10297 #10292 #10285 IslandRhythms
  • fix(index.d.ts): make map() result an array if used over an array #10288 quantumsheep

5.12.11 / 2021-05-24

  • fix(populate): skip applying setters when casting arrays for populate() to avoid issues with arrays of immutable elements #10264
  • perf(schematype): avoid cloning setters every time we run setters #9588
  • perf(get): add benchmarks and extra cases to speed up get() #9588
  • perf(array): improve array constructor performance on small arrays to improve nested array perf #9588
  • fix(index.d.ts): allow using type: [String] with string[] when using SchemaDefinition with generic #10261
  • fix(index.d.ts): support ReadonlyArray as well as regular array where possible in schema definitions #10260
  • docs(connection): document noListener option to useDb #10278 stuartpb
  • docs: migrate raw tutorial content from pug / JS to markdown #10271
  • docs: fix typo #10269 sanjib

5.12.10 / 2021-05-18

  • fix(query): allow setting defaults option on result documents from query options #7287 IslandRhythms
  • fix(populate): handle populating embedded discriminator with custom tiedValue #10231
  • fix(document): allow passing space-delimited string of pathsToValidate to validate() and validateSync() #10258
  • fix(model+schema): support loadClass() on classes that have collection as a static property #10257 #10254 IslandRhythms
  • fix(SchemaArrayOptions): correct property name #10236
  • fix(index.d.ts): add any to all query operators to minimize likelihood of "type instantiation is excessively deep" when querying docs with 4-level deep subdocs #10189
  • fix(index.d.ts): add $parent() in addition to parent() in TS definitions
  • fix(index.d.ts): correct async iterator return type for QueryCursor #10253 #10252 #10251 borfig
  • fix(index.d.ts): add virtualsOnly parameter to loadClass() function signature IslandRhythms
  • docs(typescript): add typescript populate docs #10212
  • docs: switch from AWS to Azure Functions for search #10244

5.12.9 / 2021-05-13

  • fix(schema): ensure add() overwrites existing schema paths by default #10208 #10203
  • fix(schema): support creating nested paths underneath document arrays #10193
  • fix(update): convert nested dotted paths in update to nested paths to avoid ending up with dotted properties in update #10200
  • fix(document): allow calling validate() and validateSync() with options as first parameter #10216
  • fix(schema): apply static properties to model when using loadClass() #10206
  • fix(index.d.ts): allow returning Promise from middleware functions #10229
  • fix(index.d.ts): add pre('distinct') hooks to TypeScript #10192

5.12.8 / 2021-05-10

  • fix(populate): handle populating immutable array paths #10159
  • fix(CastError): add toJSON() function to ensure name property always ends up in JSON.stringify() output #10166 IslandRhythms
  • fix(query): add allowDiskUse() method to improve setting MongoDB 4.4's new allowDiskUse option #10177
  • fix(populate): allow populating paths under mixed schematypes where some documents have non-object properties #10191
  • chore: remove unnecessary driver dynamic imports so Mongoose can work with Parcel #9603
  • fix(index.d.ts): allow any object as parameter to create() and insertMany() #10144
  • fix(index.d.ts): allow creating Model class with raw interface, no extends Document #10144
  • fix(index.d.ts): separate UpdateQuery from UpdateWithAggregationPipeline for cases when UpdateQuery is used as a function param #10186
  • fix(index.d.ts): don't require error value in pre/post hooks #10213 michaln-q
  • docs(typescript): add a typescript intro tutorial and statics tutorial #10021
  • docs(typescript): add query helpers tutorial #10021
  • docs(deprecations): add note that you can safely ignore useFindAndModify and useCreateIndex deprecation warnings #10155
  • chore(workflows): add node 16 to github actions #10201 AbdelrahmanHafez

5.12.7 / 2021-04-29

  • fix(document): make $getPopulatedDocs() return populated virtuals #10148
  • fix(discriminator): take discriminator schema's single nested paths over base schema's #10157
  • fix(discriminator): allow numbers and ObjectIds as tied values for discriminators #10130
  • fix(document): avoid double validating paths underneath mixed objects in save() #10141
  • fix(schema): allow path() to return single nested paths within document arrays #10164
  • fix(model+query): consistently wrap query callbacks in process.nextTick() to avoid clean stack traces causing memory leak when using synchronous recursion like async.whilst() #9864
  • fix(cursor): correctly report CastError when using noCursorTimeout flag #10150
  • fix(index.d.ts): add CastError constructor #10176
  • fix(index.d.ts): allow setting mongoose.pluralize(null) in TypeScript #10185
  • docs: add link to transactions guide from nav bar #10143
  • docs(validation): add section about custom error messages #10140
  • docs: make headers linkable via clicking #10156
  • docs: broken link in document.js #10190 joostdecock
  • docs: make navbar responsive on legacy 2.x docs #10171 ad99526

5.12.6 / 2021-04-27

  • fix(query): allow setting writeConcern schema option to work around MongoDB driver's writeConcern deprecation warning #10083 #10009 IslandRhythms
  • fix(populate): dedupe when virtual populate foreignField is an array to avoid duplicate docs in result #10117
  • fix(populate): add localField filter to $elemMatch on virtual populate when custom match has a $elemMatch and foreignField is an array #10117
  • fix(query): convert projection string values to numbers as a workaround for #10142
  • fix(document): set version key filter on save() when using optimisticConcurrency if no changes in document #10128 IslandRhythms
  • fix(model): use obj as context in Model.validate() if obj is a document #10132
  • fix(connection): avoid db events deprecation warning when using useDb() with useUnifiedTopology #8267
  • fix: upgrade to sift@13.5.2 to work around transitive dev dependency security warning #10121
  • fix(index.d.ts): allow any object as parameter to create() and insertMany() #10144
  • fix(index.d.ts): clarify that eachAsync() callback receives a single doc rather than array of docs unless batchSize is set #10135
  • fix(index.d.ts): clarify that return value from validateSync() is a ValidationError #10147 michaln-q
  • fix(index.d.ts): add generic type for Model constructor #10074 Duchynko
  • fix(index.d.ts): add parameter type in merge #10168 yoonhoGo

5.12.5 / 2021-04-19

  • fix(populate): handle populating underneath document array when document array property doesn't exist in db #10003
  • fix(populate): clear out dangling pointers to populated docs so query cursor with populate() can garbage collect populated subdocs #9864
  • fix(connection): pull correct autoCreate value from Mongoose global when creating new model before calling connect() #10091
  • fix(populate): handle populating paths on documents with discriminator keys that point to non-existent discriminators #10082
  • fix(index.d.ts): allow numbers as discriminator names #10115
  • fix(index.d.ts): allow type: Boolean in Schema definitions #10085
  • fix(index.d.ts): allow passing array of aggregation pipeline stages to updateOne() and updateMany() #10095
  • fix(index.d.ts): support legacy 2nd param callback syntax for deleteOne(), deleteMany() #10122
  • docs(mongoose): make useCreateIndex always false in docs #10033
  • docs(schema): fix incorrect links from schema API docs #10111

5.12.4 / 2021-04-15

  • fix: upgrade mongodb driver -> 3.6.6 #10079
  • fix: store fields set with select:false at schema-level when saving a new document #10101 ptantiku
  • fix(populate): avoid turning already populated field to null when populating an existing lean document #10068 IslandRhythms
  • fix(populate): correctly populate lean subdocs with _id property #10069
  • fix(model): insertedDocs may contain docs that weren't inserted #10098 olnazx
  • fix(schemaType): make type Mixed cast error objects to pojos #10131 AbdelrahmanHafez
  • fix(populate): support populating embedded discriminators in nested arrays #9984
  • fix(populate): handle populating map paths using trailing .$* #10123
  • fix(populate): allow returning primitive from transform() function for single conventional populate #10064
  • fix(index.d.ts): allow generic classes of T to use T & Document internally #10046
  • fix(index.d.ts): allow $pull with $ paths #10075
  • fix(index.d.ts): use correct Date type for $currentDate #10058
  • fix(index.d.ts): add missing asyncInterator to Query type def #10094 borfig
  • fix(index.d.ts): allow RHS of $unset properties to be any value #10066
  • fix(index.d.ts): allow setting SchemaType index property to a string #10077
  • refactor(index.d.ts): move discriminator() to common interface #10109 LoneRifle

5.12.3 / 2021-03-31

  • fix: avoid setting schema-level collation on text indexes #10044 IslandRhythms
  • fix(query): add writeConcern() method to avoid writeConcern deprecation warning #10009
  • fix(connection): use queueing instead of event emitter for createCollection() and other helpers to avoid event emitter warning #9778
  • fix(connection): scope Connection#id to Mongoose instance so id always lines up with mongoose.connections index #10025 IslandRhythms
  • fix: avoid throwing in promiseOrCallback() if 3rd param isn't an EventEmitter #10055 emrebass
  • fix(index.d.ts): add Model as 2nd generic param to Model.discriminator() #10054 coro101
  • fix(index.d.ts): add docs to next() callback for pre('insertMany') hooks #10078 #10072 pezzu
  • fix(index.d.ts): add transform to PopulateOptions interface #10061
  • fix(index.d.ts): add DocumentQuery type for backwards compatibility #10036

5.12.2 / 2021-03-22

  • fix(QueryCursor): consistently execute post('find') hooks with an array of docs #10015 #9982 IslandRhythms
  • fix(schema): support setting ref as an option on an array SchemaType #10029
  • fix(query): apply schema-level select option from array schematypes #10029
  • fix(schema): avoid possible prototype pollution with Schema() constructor #10035 zpbrent
  • fix(model): make bulkWrite skip timestamps with timestamps: false #10050 SoftwareSing
  • fix(index.d.ts): make query methods return QueryWithHelpers so query helpers pass through chaining #10040
  • fix(index.d.ts): add upserted array to updateOne(), updateMany(), update() result #10042
  • fix(index.d.ts): add back Aggregate#project() types that were mistakenly removed in 5.12.0 #10043
  • fix(index.d.ts): always allow setting type in Schema to a SchemaType class or a Schema instance #10030
  • docs(transactions): introduce session.withTransaction() before session.startTransaction() because withTransaction() is the recommended approach #10008
  • docs(mongoose+browser): fix broken links to info about mongoose.Types #10016

5.12.1 / 2021-03-18

  • fix: update mongodb -> 3.6.5 to fix circular dependency warning #9900
  • fix(document): make toObject() use child schema flattenMaps option by default #9995
  • fix(ObjectId): make isValidObjectId() check that length 24 strings are hex chars only #10010 #9996 IslandRhythms
  • fix(query): correctly cast embedded discriminator paths when discriminator key is specified in array filter #9977
  • fix(schema): skip populated() check when calling applyGetters() with a POJO for mongoose-lean-getters support #9986
  • fix(populate): support populating dotted subpath of a populated doc that has the same id as a populated doc #10005
  • fix(index.d.ts): correct this for query helpers #10028 francescov1
  • fix(index.d.ts): avoid omitting function property keys in LeanDocuments, because TS can't accurately infer what's a function if using generic functions #9989
  • fix(index.d.ts): correct type definition for SchemaType#cast() #10039 #9980
  • fix(index.d.ts): make SchemaTypeOptions a class, add missing SchemaType#OptionsConstructor #10001
  • fix(index.d.ts): support calling findByIdAndUpdate() with filter, update, callback params #9981

5.12.0 / 2021-03-11

  • feat(populate): add transform option that Mongoose will call on every populated doc #3775
  • feat(query): make Query#pre() and Query#post() public #9784
  • feat(document): add Document#getPopulatedDocs() to return an array of all populated documents in a document #9702 IslandRhythms
  • feat(document): add Document#getAllSubdocs() to return an array of all single nested and array subdocuments #9764 IslandRhythms
  • feat(schema): allow schema as a schema path name #8798 IslandRhythms
  • feat(QueryCursor): Add batch processing for eachAsync #9902 khaledosama999
  • feat(connection): add noListener option to help with use cases where you're using useDb() on every request #9961
  • feat(index): emit 'createConnection' event when user calls mongoose.createConnection() #9985
  • feat(connection+index): emit 'model' and 'deleteModel' events on connections when creating and deleting models #9983
  • feat(query): allow passing explain option to Model.exists() #8098 IslandRhythms

5.11.20 / 2021-03-11

  • fix(query+populate): avoid unnecessarily projecting in subpath when populating a path that uses an elemMatch projection #9973
  • fix(connection): avoid db events deprecation warning with 'close' events #10004 #9930
  • fix(index.d.ts): make $pull more permissive to allow dotted paths #9993

5.11.19 / 2021-03-05

  • fix(document): skip validating array elements that aren't modified when validateModifiedOnly is set #9963
  • fix(timestamps): apply timestamps on findOneAndReplace() #9951
  • fix(schema): correctly handle trailing array filters when looking up schema paths #9977
  • fix(schema): load child class getter for virtuals instead of base class when using loadClass() #9975
  • fix(index.d.ts): allow creating statics without passing generics to Schema constructor #9969
  • fix(index.d.ts): add QueryHelpers generic to schema and model, make all query methods instead return QueryWithHelpers #9850
  • fix(index.d.ts): support setting type to an array of schemas when using SchemaDefinitionType #9962
  • fix(index.d.ts): add generic to plugin schema definition #9968 emiljanitzek
  • docs: small typo fix #9964 KrishnaMoorthy12

5.11.18 / 2021-02-23

  • fix(connection): set connection state to disconnected if connecting string failed to parse #9921
  • fix(connection): remove db events deprecation warning if useUnifiedTopology = true #9930
  • fix(connection): fix promise chaining for openUri #9960 lantw44
  • fix(index.d.ts): add PopulatedDoc type to make it easier to define populated docs in interfaces #9818
  • fix(index.d.ts): allow explicitly overwriting toObject() return type for backwards compatibility #9944
  • fix(index.d.ts): correctly throw error when interface path type doesn't line up with schema path type #9958 ShadiestGoat
  • fix(index.d.ts): remove any from deleteX() and updateX() query params and return values #9959 btd
  • fix(index.d.ts): add non-generic versions of Model.create() for better autocomplete #9928
  • docs: correctly handle multiple &gt in API descriptions #9940

5.11.17 / 2021-02-17

  • fix(populate): handle perDocumentLimit when multiple documents reference the same populated doc #9906
  • fix(document): handle directly setting embedded document array element with projection #9909
  • fix(map): cast ObjectId to string inside of MongooseMap #9938 HunterKohler
  • fix(model): use schema-level default collation for indexes if index doesn't have collation #9912
  • fix(index.d.ts): make SchemaTypeOptions#type optional again to allow alternative typeKeys #9927
  • fix(index.d.ts): support { type: String } in schema definition when using SchemaDefinitionType generic #9911
  • docs(populate+schematypes): document the $* syntax for populating every entry in a map #9907
  • docs(connection): clarify that Connection#transaction() promise resolves to a command result #9919

5.11.16 / 2021-02-12

  • fix(document): skip applying array element setters when init-ing an array #9889
  • fix: upgrade to mongodb driver 3.6.4 #9893 jooeycheng
  • fix: avoid copying Object.prototype properties when cloning #9876
  • fix(aggregate): automatically convert functions to strings when using $function operator #9897
  • fix: call pre-remove hooks for subdocuments #9895 #9885 IslandRhythms
  • docs: fix confusing sentence in Schema docs #9914 namenyi

5.11.15 / 2021-02-03

  • fix(document): fix issues with isSelected as an path in a nested schema #9884 #9873 IslandRhythms
  • fix(index.d.ts): better support for SchemaDefinition generics when creating schema #9863 #9862 #9789
  • fix(index.d.ts): allow required function in array definition #9888 Ugzuzg
  • fix(index.d.ts): reorder create typings to allow array desctructuring #9890 Ugzuzg
  • fix(index.d.ts): add missing overload to Model.validate #9878 #9877 jonamat
  • fix(index.d.ts): throw compiler error if schema says path is a String, but interface says path is a number #9857
  • fix(index.d.ts): make Query a class, allow calling Query#where() with object argument and with no arguments #9856
  • fix(index.d.ts): support calling Schema#pre() and Schema#post() with options and array of hooked function names #9844
  • docs(faq): mention other debug options than console #9887 dandv
  • docs(connections): clarify that Mongoose can emit 'error' both during initial connection and after initial connection #9853

5.11.14 / 2021-01-28

  • fix(populate): avoid inferring justOne from parent when populating a POJO with a manually populated path #9833 IslandRhythms
  • fix(document): apply setters on each element of the array when setting a populated array #9838
  • fix(map): handle change tracking on maps of subdocs #9811 IslandRhythms
  • fix(document): remove dependency on documentIsSelected symbol #9841 IslandRhythms
  • fix(error): make ValidationError.toJSON to include the error name correctly #9849 hanzki
  • fix(index.d.ts): indicate that Document#remove() returns a promise, not a query #9826
  • fix(index.d.ts): allow setting SchemaType#enum to TypeScript enum with required: true #9546

5.11.13 / 2021-01-20

  • fix(map): handle change tracking on map of arrays #9813
  • fix(connection): allow passing options to Connection#transaction() #9834 pnutmath
  • fix(index.d.ts): make Query#options#rawResult take precedence over new+upsert #9816
  • fix(index.d.ts): changed setOptions's 'overwrite' argument to optional #9824 pierissimo
  • fix(index.d.ts): allow setting mongoose.Promise #9820
  • fix(index.d.ts): add Aggregate#replaceRoot() #9814
  • fix(index.d.ts): make Model.create() with a spread return a promise of array rather than single doc #9817
  • fix(index.d.ts): use SchemaDefinitionProperty generic for SchemaTypeOptions if specified #9815
  • docs(populate): add note about setting toObject for populate virtuals #9822

5.11.12 / 2021-01-14

  • fix(document): handle using db as a document path #9798
  • fix(collection): make sure to call onOpen() if autoCreate === false #9807
  • fix(index.d.ts): correct query type for findOneAndUpdate() and findByIdAndUpdate() with rawResult = true #9803
  • fix(index.d.ts): require setting new: true or returnOriginal: false to skip null check with findOneAndUpdate() #9654
  • fix(index.d.ts): make methods and statics optional on schema #9801
  • fix(index.d.ts): remove non backwards compatible methods restriction #9801
  • docs: removed the extra word on comment doc #9794 HenriqueLBorges

5.11.11 / 2021-01-08

  • fix(model): support calling create() with undefined as first argument and no callback #9765
  • fix(index.d.ts): ensure TypeScript knows that this refers to DocType in schema methods with strict mode #9755
  • fix(index.d.ts): make SchemaDefinition accept a model generic #9761 mroohian
  • fix(index.d.ts): add Aggregate#addFields() #9774
  • fix(index.d.ts): allow setting min and max to [number, string] and [Date, string] #9762
  • fix(index.d.ts): improve context and type bindings for Schema#methods and Schema#statics #9717
  • docs: add recommended connection option #9768 Fernando-Lozano
  • chore: correct improper date in History.md #9783 botv

5.11.10 / 2021-01-04

  • fix(model): support populate option for insertMany() as a workaround for mongoose-autopopulate #9720
  • perf(schema): avoid creating extra array when initializing array of arrays #9588
  • perf(schema): avoid setting arrayPath when casting to a non-array, avoid unnecessarily setting atomics #9588
  • perf(schema): avoid expensive String#slice() call when creating a new array #9588
  • fix(queryhelpers): avoid modifying lean.virtuals in place #9754
  • fix: fall back to legacy treatment for square brackets if square brackets contents aren't a number #9640
  • fix(document): make fix for #9396 handle null values more gracefully #9709
  • fix(index.d.ts): add missing overloaded function for Document#populate() #9744 sahasayan
  • fix(index.d.ts): allow Model.create param1 overwrite #9753 hasezoey
  • fix(index.d.ts): improve autocomplete for query middleware #9752 3Aahmednaser94
  • fix(index.d.ts): add missing function for Aggregate#group() #9750 coro101
  • fix(index.d.ts): add missing Aggregate#project() #9763 vorticalbox
  • fix(index.d.ts): allow null as an enum value for schematypes #9746
  • docs(guide+schema): make schema API docs and guide docs' list of Schema options line up #9749
  • docs(documents): add some more details about what the save() promise resolves to #9689
  • docs(subdocs): add section about subdocument defaults #7291
  • chore: run GitHub CI on PRs and update badge #9760 YC

5.11.9 / 2020-12-28

  • fix(document): keeps atomics when assigning array to filtered array #9651
  • fix(document): apply defaults option to subdocument arrays #9736
  • fix(index.d.ts): allow passing generic parameter to overwrite lean() result type #9728
  • fix(index.d.ts): add missing pre hook for findOneAndUpdate #9743 sahasayan
  • fix(index.d.ts): schema methods & statics types #9725
  • fix(index.d.ts): allow id paths with non-string values in TypeScript #9723
  • fix(index.d.ts): support calling createIndexes() and ensureIndexes() with just callback #9706
  • fix(index.d.ts): include __v in LeanDocuments #9687
  • fix(index.d.ts): add missing Aggregate#append() #9714
  • chore: add eslint typescript support and lint index.d.ts file #9729 simllll
  • chore: add Github Actions #9688 YC

5.11.8 / 2020-12-14

  • fix(index.d.ts): add missing single document populate #9696 YC
  • fix(index.d.ts): make options optional for toObject #9700
  • fix(index.d.ts): added missing match and model methods in Aggregate class #9710 manekshms
  • fix(index.d.ts): make options optional for createIndexes() and ensureIndexes() #9706
  • fix(index.d.ts): support passing a function to ValidateOpts.message #9697
  • docs: add media query for ::before on headings #9705 #9704 YC

5.11.7 / 2020-12-10

  • fix(document): ensure calling get() with empty string returns undefined for mongoose-plugin-autoinc #9681
  • fix(model): set isNew to false for documents that were successfully inserted by insertMany with ordered = false when an error occurred #9677
  • fix(index.d.ts): add missing Aggregate#skip() & Aggregate#limit() #9692 sahasayan
  • fix(index.d.ts): make Document#id optional so types that use id can use Model<IMyType & Document> #9684

5.11.6 / 2020-12-09

  • fix(middleware): ensure sync errors in pre hooks always bubble up to the calling code #9659
  • fix(index.d.ts): allow passing ObjectId properties as strings to create() and findOneAndReplace() #9676
  • fix(index.d.ts): allow calling mongoose.model() and Connection#model() with model as generic param #9685 #9678 sahasayan
  • fix(index.d.ts): Fix return type of Model#aggregate() #9680 orgads
  • fix(index.d.ts): optional next() parameter for post middleware #9683 isengartz
  • fix(index.d.ts): allow array of validators in SchemaTypeOptions #9686 cjroebuck

5.11.5 / 2020-12-07

  • fix(map): support null in maps of subdocs #9628
  • fix(index.d.ts): support object syntax for validate #9667
  • fix(index.d.ts): Allow number for Schema expires #9670 alecgibson
  • fix(index.d.ts): allow definining arbitrary properties on SchemaTypeOpts for plugins like mongoose-autopopulate #9669
  • fix(index.d.ts): add mongoose.models #9661 #9660 AbdelrahmanHafez
  • fix(index.d.ts): allow the next() argument to be optional #9665 #9664 sahasayan
  • fix(index.d.ts): add missing VirtualType#applyGetters() and applySetters(), Schema#virtuals, Schema#childSchemas, Query#_mongooseOptions #9658
  • fix(index.d.ts): add id to LeanDocuments in case it is defined in the user's schema #9657
  • fix(index.d.ts): add missing types for hook functions #9653
  • fix(index.d.ts): improve support for strict null checks with upsert and orFail() #9654
  • fix(index.d.ts): make return values for insertMany() more consistent #9662
  • fix(index.d.ts): Change options in Connection#collection() to be optional #9663 orgads
  • fix(index.d.ts): add the missing generic declaration for Schema #9655 sahasayan
  • fix(index.d.ts): add missing SchemaTypeOpts and ConnectionOptions aliases for backwards compat
  • docs(populate): remove sort() from limit example to avoid potential confusion #9584
  • docs(compatibility): add MongoDB server 4.4 version compatibility #9641

5.11.4 / 2020-12-04

  • fix(index.d.ts): add Document#__v so documents have a Version by default #9652 sahasayan
  • fix(index.d.ts): add missing session option to SaveOptions #9642
  • fix(index.d.ts): add Schema#paths, Schema#static(obj), Embedded#schema, DocumentArray#schema, make Schema inherit from EventEmitter #9650
  • fix(index.d.ts): order when cb is optional in method #9647 CatsMiaow
  • fix(index.d.ts): use DocumentDefinition for FilterQuery #9649
  • fix(index.d.ts): correct callback result types for find(), findOne(), findById() #9648
  • fix(index.d.ts): remove Document#parent() method because it conflicts with existing user code #9645
  • fix(index.d.ts): add missing Connection#db property #9643
  • test(typescript): add tsconfig.json file for intellisense #9611 alecgibson

5.11.3 / 2020-12-03

  • fix(index.d.ts): make Mongoose collection inherit MongoDB collection #9637 #9630 AbdelrahmanHafez
  • fix(index.d.ts): add Document#_id so documents have an id by default #9632
  • fix(index.d.ts): allow inline schema definitions for nested properties #9639 Green-Cat
  • fix(index.d.ts): add support for missing error message definitions #9638 SaifAlsabe
  • fix(schema+discriminator): support defining recursive embedded discriminators by passing document array schematype to discriminator #9600
  • fix(index.d.ts): make it possible to use LeanDocument with arrays #9620
  • fix(index.d.ts): add ModelUpdateOptions as alias for QueryOptions for backwards compat #9637

5.11.2 / 2020-12-02

  • fix(index.d.ts): add missing query options and model findById() function #9626 #9620
  • fix(index.d.ts): support defining schema paths as arrays of functions #9617
  • fix(index.d.ts): add automatic _id for Document, support creating Mongoose globals and accessing collection name #9618
  • fix(index.d.ts): add missing global get() and set() #9616
  • fix(index.d.ts): add missing new and returnOriginal options to QueryOptions, add missing model static properties #9627 #9616 #9615
  • fix(index.d.ts): allow useCreateIndex in connection options #9621

5.11.1 / 2020-12-01

  • fix(index.d.ts): add missing SchemaOptions #9606
  • fix(index.d.ts): allow using $set in updates #9609
  • fix(index.d.ts): add support for using return value of createConnection() as a connection as well as a promise #9612 #9610 alecgibson
  • fix(index.d.ts): allow using Types.ObjectId() without new in TypeScript #9608

5.11.0 / 2020-11-30

  • feat: add official TypeScript definitions index.d.ts file #8108
  • feat(connection): add bufferTimeoutMS option that configures how long Mongoose will allow commands to buffer #9469
  • feat(populate): support populate virtuals with localField and foreignField as arrays #6608
  • feat(populate+virtual): feat: support getters on populate virtuals, including get option for Schema#virtual() #9343
  • feat(populate+schema): add support for populate schematype option that sets default populate options #6029
  • feat(QueryCursor): execute post find hooks for each doc in query cursor #9345
  • feat(schema): support overwriting cast logic for individual schematype instances #8407
  • feat(QueryCursor): make cursor populate() in batch when using batchSize #9366 biomorgoth
  • chore: remove changelog from published bundle #9404
  • feat(model+mongoose): add overwriteModels option to bypass OverwriteModelError globally #9406
  • feat(model+query): allow defining middleware for all query methods or all document methods, but not other middleware types #9190
  • feat(document+model): make change tracking skip saving if new value matches last saved value #9396
  • perf(utils): major speedup for deepEqual() on documents and arrays #9396
  • feat(schema): support passing a TypeScript enum to enum validator in schema #9547 #9546 AbdelrahmanHafez
  • feat(debug): #8963 shell option for date format (ISODate) #9532 FlameFractal
  • feat(document): support square bracket indexing for get(), set() #9375
  • feat(document): support array and space-delimited syntax for Document#$isValid(), isDirectSelected(), isSelected(), $isDefault() #9474
  • feat(string): make minLength and maxLength behave the same as minlength and maxlength #8777 m-weeks
  • feat(document): add $parent() as an alias for parent() for documents and subdocuments to avoid path name conflicts #9455

5.10.19 / 2020-11-30

  • fix(query): support passing an array to $type in query filters #9577
  • perf(schema): avoid creating unnecessary objects when casting to array #9588
  • docs: make example gender neutral #9601 rehatkathuria

5.10.18 / 2020-11-29

  • fix(connection): connect and disconnect can be used destructured #9598 #9597 AbdelrahmanHafez

5.10.17 / 2020-11-27

  • fix(document): allow setting fields after an undefined field #9587 AbdelrahmanHafez

5.10.16 / 2020-11-25

  • fix(connection): copy config options from connection rather than base connection when calling useDb() #9569
  • fix(schema): support of for array type definitions to be consistent with maps #9564
  • docs(dates): fix broken example reference #9557 kertof
  • docs(virtualtype): remove unintentional h2 tag re: tj/dox#60 #9568

5.10.15 / 2020-11-16

  • fix(array): make sure Array#toObject() returns a vanilla JavaScript array in Node.js 6+ #9540
  • fix(connection): make disconnect() stop Mongoose if it is trying to reconnect #9531
  • fix: ensure Document#overwrite() correctly overwrites maps #9549
  • fix(document): make transform work with nested paths #9544 #9543 jonathan-wilkinson
  • fix(query): maxTimeMS in count, countDocuments, distinct #9552 FlameFractal
  • fix(schema): remove warning re: increment as a schema path name #9538
  • fix(model): automatically set partialFilterExpression for indexes in discriminator schemas #9542

5.10.14 / 2020-11-12

  • fix(update): handle casting immutable object properties with $setOnInsert #9537
  • fix(discriminator): overwrite instead of merge if discriminator schema specifies a path is single nested but base schema has path as doc array #9534
  • docs(middleware): clarify that you need to set both document and query on remove hooks to get just document middleware #9530 mustafaKamal-fe
  • docs(CONTRIBUTING): remove mmapv1 recommendation and clean up a few other details #9529
  • refactor: remove duplicate function definition #9527 ksullivan

5.10.13 / 2020-11-06

  • fix: upgrade mongodb driver -> 3.6.3 for Lambda cold start fixes #9521 #9179 AbdelrahmanHafez
  • fix(document): correctly handle setting props to other nested props #9519

5.10.12 / 2020-11-04

  • fix(connection): catch and report sync errors in connection wrappers like startSession() #9515
  • fix(document): ignore getters when diffing values for change tracking #9501
  • fix(connection): avoid executing promise handler unless it's a function #9507 AbdelrahmanHafez
  • fix(error): throw more helpful error when connecting to a non-SSL MongoDB server with SSL enabled #9511
  • docs(model+query): clarify that deleteOne and deleteMany trigger middleware #9504
  • docs(ssl): add note about ssl defaulting to true for srv connection strings #9511

5.10.11 / 2020-10-26

  • fix(connection): when calling mongoose.connect() multiple times in parallel, make 2nd call wait for connection before resolving #9476
  • fix(map): make save() persist Map#clear() #9493
  • fix(document): avoid overwriting array subdocument when setting dotted path that isn't selected #9427
  • fix(connection): don't throw Atlas error if server discovery doesn't find any servers #9470
  • docs: update options for Model.findOneAndUpdate #9499 radamson

5.10.10 / 2020-10-23

  • fix(schema): handle merging schemas from separate Mongoose module instances when schema has a virtual #9471
  • fix(connection): make connection.then(...) resolve to a connection instance #9497 AbdelrahmanHafez
  • fix(aggregate): when using $search with discriminators, add $match as the 2nd stage in pipeline rather than 1st #9487
  • fix(query): cast $nor within $elemMatch #9479
  • docs(connection): add note about 'error' event versus 'disconnected' event #9488 tareqdayya

5.10.9 / 2020-10-09

  • fix(update): strip out unused array filters to avoid "filter was not used in the update" error #9468
  • fix(mongoose): allow setting autoCreate as a global option to be consistent with autoIndex #9466

5.10.8 / 2020-10-05

  • fix(schema): handle setting nested paths underneath single nested subdocs #9459
  • fix(schema+index): allow calling mongoose.model() with schema from a different Mongoose module instance #9449
  • fix(transaction): fix saving new documents w/ arrays in transactions #9457 PenguinToast
  • fix(document): track reason on cast errors that occur while init-ing a document #9448
  • fix(model): make createCollection() not throw error when collection already exists to be consistent with v5.9 #9447
  • docs(connections): add SSL connections docs #9443
  • docs(query_casting): fix typo #9458 craig-davis

5.10.7 / 2020-09-24

  • fix(schema): set correct path and schema on nested primitive arrays #9429
  • fix(document): pass document to required validator so required can use arrow functions #9435 AbdelrahmanHafez
  • fix(document): handle required when schema has property named isSelected #9438
  • fix(timestamps): allow using timestamps when schema has a property named 'set' #9428
  • fix(schema): make Schema#clone() use parent Mongoose instance's Schema constructor #9426

5.10.6 / 2020-09-18

  • fix(populate): handle options.perDocumentLimit option same as perDocumentLimit when calling populate() #9418
  • fix(document): invalidate path if default function throws an error #9408
  • fix: ensure subdocument defaults run after initial values are set when initing #9408
  • docs(faq+queries): add more detail about duplicate queries, including an faq entry #9386
  • docs: replace var with let and const in docs and test files #9414 jmadankumar
  • docs(model+query): document using array of strings as projection #9413
  • docs(middleware): add missing backtick #9425 tphobe9312

5.10.5 / 2020-09-11

  • fix: bump mongodb -> 3.6.2 #9411 AbdelrahmanHafez
  • fix(query+aggregate+cursor): support async iteration over a cursor instance as opposed to a Query or Aggregate instance #9403
  • fix(document): respect child schema minimize if toObject() is called without an explicit minimize #9405
  • docs(guide): use const instead of var #9394 nainardev
  • docs(query): link to lean, findOneAndUpdate, query casting tutorials from query docs #9410

5.10.4 / 2020-09-09

  • fix(document): allow setting nested path to instance of model #9392
  • fix: handle findOneAndRemove() with orFail() #9381
  • fix(schema): support setting _id option to false after instantiating schema #9390
  • docs(document): fix formatting on getChanges() #9376

5.10.3 / 2020-09-03

  • fix: upgrade mongodb -> 3.6.1 #9380 lamhieu-vk
  • fix(populate): allow populating paths underneath subdocument maps #9359
  • fix(update): handle casting map paths when map is underneath a single nested subdoc #9298
  • fix(discriminator): avoid removing nested path if both base and discriminator schema have the same nested path #9362
  • fix(schema): support Schema#add() with schematype instances with different paths #9370
  • docs(api): fix typo in Query#get() example #9372 elainewlin

5.10.2 / 2020-08-28

  • fix(model): avoid uncaught error if insertMany() fails due to server selection error #9355
  • fix(aggregate): automatically convert accumulator function options to strings #9364
  • fix(document): handle pull() on a document array when _id is an alias #9319
  • fix(queryhelpers): avoid path collision error when projecting in discriminator key with .$ #9361
  • fix: fix typo in error message thrown by unimplemented createIndex #9367 timhaley94
  • docs(plugins): note that plugins should be applied before you call mongoose.model() #7723

5.10.1 / 2020-08-26

  • fix(mongoose): fix .then() is not a function error when calling mongoose.connect() multiple times #9358 #9335 #9331
  • fix: allow calling create() after bulkWrite() by clearing internal casting context #9350
  • fix(model): dont wipe out changes made while save() is in-flight #9327
  • fix(populate): skip checking refPath if the path to populate is undefined #9340
  • fix(document): allow accessing document values from function default on array #9351
  • fix(model): skip applying init hook if called with schema.pre(..., { document: false }) #9316
  • fix(populate): support retainNullValues when setting _id to false for subdocument #9337 #9336 FelixRe0
  • docs: update connect example to avoid deprecation warnings #9332 moander

5.10.0 / 2020-08-14

  • feat: upgrade to MongoDB driver 3.6 for full MongoDB 4.4 support
  • feat(connection): add Connection#transaction() helper that handles resetting Mongoose document state if the transaction fails #8380
  • feat(connection): make transaction() helper reset array atomics after failed transaction
  • feat(schema+model): add optimisticConcurrency option to use OCC for save() #9001 #5424
  • feat(aggregate): add Aggregate#search() for Atlas Text Search #9115
  • feat(mongoose): add support for setting setDefaultsOnInsert as a global option #9036 AbdelrahmanHafez
  • feat(mongoose): add support for setting returnOriginal as a global option #9189 #9183 AbdelrahmanHafez
  • feat(mongoose): allow global option mongoose.set('strictQuery', true) #9016 AbdelrahmanHafez
  • feat(document): add Document#getChanges #9097 AbdelrahmanHafez
  • feat(document): support defaults option to disable adding defaults to a single document #8271
  • feat(SingleNestedPath+DocumentArray): add static set() function for global options, support setting _id globally #8883
  • feat(query): handle casting $or when each clause contains a different discriminator key #9018
  • feat(query): add overwriteDiscriminatorKey option that allows changing the discriminator key in findOneAndUpdate(), updateOne(), etc. #6087
  • fix(connection): make calling mongoose.connect() while already connected a no-op #9203
  • feat(connection): add getClient() and setClient() function for interacting with a connection's underlying MongoClient instance #9164
  • feat(document+populate): add parent() function that allows you to get the parent document for populated docs #8092
  • feat(document): add useProjection option to toObject() and toJSON() for hiding deselected fields on newly created documents #9118

5.9.29 / 2020-08-13

  • fix(document): support setting nested path to itself when it has nested subpaths #9313
  • fix(model): make syncIndexes() report error if it can't create an index #9303
  • fix: handle auth error when Atlas username is incorrect #9300

5.9.28 / 2020-08-07

  • fix(connection): consistently stop buffering when "reconnected" is emitted #9295
  • fix(error): ensure name and message show up on individual ValidatorErrors when calling JSON.stringify() on a ValidationError #9296
  • fix(document): keeps manually populated paths when setting a nested path to itself #9293
  • fix(document): allow saving after setting document array to itself #9266
  • fix(schema): handle match schema validator with /g flag #9287
  • docs(guide): refactor transactions examples to async/await #9204

5.9.27 / 2020-07-31

  • fix: upgrade mongodb driver -> 3.5.10 AbdelrahmanHafez
  • docs(transactions): make transactions docs use async/await for readability #9204

5.9.26 / 2020-07-27

  • fix(document): allow unsetting boolean field by setting the field to undefined #9275
  • fix(document): throw error when overwriting a single nested subdoc changes an immutable path within the subdoc #9281
  • fix(timestamps): apply timestamps to bulkWrite() updates when not using $set #9268
  • fix(browser): upgrade babel to v7 to work around an issue with extends Error #9273
  • fix: make subdocument's invalidate() methods have the same return value as top-level document #9271
  • docs(model): make create() docs use async/await, and add another warning about how create() with options requires array syntax #9280
  • docs(connections): clarify that Mongoose can emit 'connected' when reconnecting after losing connectivity #9240
  • docs(populate): clarify that you can't filter based on foreign document properties when populating #9279
  • docs(document+model): clarify how validateModifiedOnly option works #9263
  • docs: remove extra poolSize option in comment #9270 shahvicky
  • docs: point bulkWrite() link to mongoose docs instead of localhost #9284

5.9.25 / 2020-07-17

  • fix(discriminator): allow passing a compiled model's schema as a parameter to discriminator() #9238
  • fix(connection): throw more readable error when querying db before initial connection when bufferCommands = false #9239
  • fix(indexes): don't unnecessarily drop text indexes when running syncIndexes() #9225
  • fix: make Boolean _castNullish respect omitUndefined #9242 ehpc
  • fix(populate): populate single nested discriminator underneath doc array when populated docs have different model but same id #9244
  • docs(mongoose): correct formatting typo #9247 JNa0

5.9.24 / 2020-07-13

  • fix(connection): respect connection-level bufferCommands option if mongoose.connect() is called after mongoose.model() #9179
  • fix(document): clear out priorDoc after overwriting single nested subdoc so changes after overwrite get persisted correctly #9208
  • fix(connection): dont overwrite user-specified bufferMaxEntries when setting bufferCommands #9218
  • fix(model): allow passing projection to Model.hydrate() #9209
  • fix(schema+document): support adding null to schema boolean's convertToFalse set #9223
  • docs(model): make find and findOne() examples use async/await and clarify find({}) is find all #9210

4.13.21 / 2020-07-12

  • fix(query): delete top-level _bsontype property in queries to prevent silent empty queries #8222

5.9.23 / 2020-07-10

  • fix(model): fix syncIndexes() error when db index has a collation but Mongoose index does not #9224 clhuang
  • fix(array): only cast array to proper depth if it contains an non-array value #9217 #9215 cyrilgandon
  • docs(schematype): document the transform option #9211
  • docs(mongoose): fix typo #9212 JNa0

5.9.22 / 2020-07-06

  • fix(schema): treat { type: mongoose.Schema.Types.Array } as equivalent to { type: Array } #9194
  • fix: revert fix for #9107 to avoid issues when calling connect() multiple times #9167
  • fix(update): respect storeSubdocValidationError option with update validators #9172
  • fix: upgrade to safe-buffer 5.2 #9198
  • docs: add a note about SSL validation to migration guide #9147
  • docs(schemas): fix inconsistent header #9196 samtsai15

5.9.21 / 2020-07-01

  • fix: propagate typeKey option to implicitly created schemas from typePojoToMixed #9185 joaoritter
  • fix(populate): handle embedded discriminator refPath with multiple documents #9153
  • fix(populate): handle deselected foreign field with perDocumentLimit and multiple documents #9175
  • fix(document): disallow transform functions that return promises #9176 #9163 AbdelrahmanHafez
  • fix(document): use strict equality when checking mixed paths for modifications #9165
  • docs: add target="_blank" to all edit links #9058

5.9.20 / 2020-06-22

  • fix(populate): handle populating primitive array under document array discriminator #9148
  • fix(connection): make sure to close previous connection when calling openUri() on an already open connection #9107
  • fix(model): fix conflicting $setOnInsert default values with update values in bulkWrite #9160 #9157 AbdelrahmanHafez
  • docs(validation): add note about validateBeforeSave and invalidate #9144 dandv
  • docs: specify the array field syntax for invalidate #9137 dandv
  • docs: fix several typos and broken references #9024 AbdelrahmanHafez
  • docs: fix minor typo #9143 dandv

5.9.19 / 2020-06-15

  • fix: upgrade mongodb driver -> 3.5.9 #9124 AbdelrahmanHafez
  • fix: copy required validator on single nested subdoc correctly when calling Schema#clone() #8819
  • fix(discriminator): handle tiedValue when casting update on nested paths #9108
  • fix(model): allow empty arrays for bulkWrite #9132 #9131 AbdelrahmanHafez
  • fix(schema): correctly set partialFilterExpression for nested schema indexes #9091
  • fix(castArrayFilters): handle casting on all fields of array filter #9122 lafeuil
  • fix(update): handle nested path createdAt when overwriting parent path #9105
  • docs(subdocs): add some notes on the difference between single nested subdocs and nested paths #9085
  • docs(subdocs): improve docs on typePojoToMixed #9085
  • docs: add note about connections in globalSetup with Jest #9063
  • docs: add schema and how to set default sub-schema to schematype options #9111 dfle
  • docs(index): use const instead of var in examples #9125 dmcgrouther
  • docs: corrected markdown typo #9117

5.9.18 / 2020-06-05

  • fix: improve atlas error in the event of incorrect password #9095
  • docs: add edit link for all docs pages #9058
  • fix(document): allow accessing $locals when initializing document #9099 #9098 AbdelrahmanHafez
  • fix(query): make setDefaultsOnInsert a mongoose option so it doesn't end up in debug output #9086
  • docs(connection+index): add serverSelectionTimeoutMS and heartbeatFrequencyMS to connect() and openUri() options #9071
  • docs(geojson): add notes about geojson 2dsphere indexes #9044
  • docs: make active page bold in navbar #9062
  • docs: correct a typo in a code snippet #9089 Elvis-Sarfo

5.9.17 / 2020-06-02

  • fix(document): avoid tracking changes like splice() on slice()-ed arrays #9011
  • fix(populate): make populating a nested path a no-op #9073
  • fix(document): clear nested cast errors when overwriting an array path #9080
  • fix: upgrade mongodb to v3.5.8 #9069 AbdelrahmanHafez
  • docs(document): add validateModifiedOnly to Document#save(), Document#validateSync() and Document#validate() #9078 AbdelrahmanHafez
  • docs(faq): fix typo #9075 tigransimonyan
  • docs: document all parameters to .debug #9029 dandv
  • docs: fix property value in Getters example #9061 ismet

5.9.16 / 2020-05-25

  • perf(error): convert errors to classes extending Error for lower CPU overhead #9021 zbjornson
  • fix(query): throw CastError if filter $and, $or, $nor contain non-object values #8948
  • fix(bulkwrite): cast filter & update to schema after applying timestamps #9030 AbdelrahmanHafez
  • fix(document): don't overwrite defaults with undefined keys in nested documents #9039 vitorhnn
  • fix(discriminator): remove discriminator schema nested paths pulled from base schema underneath a mixed path in discriminator schema #9042
  • fix(model): make syncIndexes() not drop index if all user-specified collation options are the same #8994
  • fix(document): make internal $__.scope property a symbol instead to work around a bug with fast-safe-stringify #8955
  • docs: model.findByIdAndUpdate() 'new' param fix #9026 dandv

5.9.15 / 2020-05-18

  • fix(schema): treat creating dotted path with no parent as creating a nested path #9020
  • fix(documentarray): make sure you can call unshift() after map() #9012 philippejer
  • fix(model): cast bulkwrite according to discriminator schema if discriminator key is present #8982 AbdelrahmanHafez
  • fix(schema): remove db from reserved keywords #8940
  • fix(populate): treat populating a doc array that doesn't have a ref as a no-op #8946
  • fix(timestamps): set createdAt and updatedAt on doubly nested subdocs when upserting #8894
  • fix(model): allow POJOs as schemas for model.discriminator(...) #8991 AbdelrahmanHafez
  • fix(model): report insertedDocs on insertMany() errors #8938
  • fix(model): ensure consistent writeErrors property on insertMany error with ordered: false, even if only one op failed #8938
  • docs: add anchor tag to strictQuery and strict #9014 AbdelrahmanHafez
  • docs(faq): remove faq ipv6 #9004
  • docs: add note about throwing error only after validation and fix broken reference to api/CastError #8993 AbdelrahmanHafez
  • docs: fix typos in documents.pug #9005 dandv

5.9.14 / 2020-05-13

  • fix(cursor): add index as second parameter to eachAsync callback #8972 AbdelrahmanHafez
  • fix(query): cast filter according to discriminator schema if discriminator key in filter #8881
  • fix(model): fix throwing error when populating virtual path defined on child discriminator #8924 AbdelrahmanHafez
  • fix(errors): handle case when user has make Error.prototype.toJSON read only #8986 osher
  • fix(model): add kind to cast errors thrown by query execution #8953 AbdelrahmanHafez
  • fix(update): use child schema strict on single nested updates if useNestedStrict not set #8922
  • docs(model): improve save() docs #8956 AbdelrahmanHafez
  • docs: add immutable type to Schema Types #8987 Andrew5569
  • docs: sort schema reserved keys in documentation #8966 AbdelrahmanHafez

5.9.13 / 2020-05-08

  • fix(schema): mark correct path as modified when setting a path underneath a nested array of documents #8926
  • fix(query): Query#select({ field: false }) should not overwrite schema selection options #8929 #8923
  • fix(update): handle immutable properties are ignored in bulk upserts #8952 philippejer
  • docs(browser): add back sample webpack config #8890
  • docs(faq): fix broken reference in limit vs perDocumentLimit #8937

5.9.12 / 2020-05-04

  • fix(document): report cast error on array elements with array index instead of just being a cast error for the whole array #8888
  • fix(connection): throw more helpful error in case of IP whitelisting issue with Atlas #8846
  • fix(schema): throw error on schema with reserved key with type of object #8869 AbdelrahmanHafez
  • fix(connection): inherit config for useDB from default connection #8267 AbdelrahmanHafez
  • fix(query): set mongodb options for distinct() #8906 clhuang
  • fix(schema): allow adding descending indexes on schema #8895 AbdelrahmanHafez
  • fix(document): set defaults if setting nested path to empty object with minimize: false #8829
  • fix(populate): check discriminator existence before accessing schema in getModelsMapForPopulate #8837 AbdelrahmanHafez
  • docs: fix broken references to Mongoose#Document API, and prefer mongoose.model(...) over Document#model(...) #8914 AbdelrahmanHafez
  • docs(model): adds options.limit to Model.insertMany(...) #8864 AbdelrahmanHafez
  • docs: add flattenMaps and aliases to Document#toObject() #8901 AbdelrahmanHafez
  • docs(model): add options.overwrite to findOneAndUpdate #8865 AbdelrahmanHafez
  • docs(populate+faq): separate limit-vs-perDocumentLimit into its own section, add FAQ for populate and limit #8917 AbdelrahmanHafez

5.9.11 / 2020-04-30

  • fix: upgrade mongodb driver -> 3.5.7 #8842 AbdelrahmanHafez
  • fix: validate nested paths on Model.validate(...) #8848 AbdelrahmanHafez
  • fix(populate): make doc.execPopulate(options) a shorthand for doc.populate(options).execPopulate() #8840 AbdelrahmanHafez
  • fix(model): return validation errors when all docs are invalid & rawResult set #8853 tusharf5
  • fix(schemaType): treat select: null or select: undefined as not specified #8850 AbdelrahmanHafez
  • fix: fix stream close event listener being called multiple times in Node 14 #8835 AbdelrahmanHafez
  • fix(populate): handle clone with lean when setting a path to null #8807
  • docs(faq): clarify setting paths under document arrays with markModified() #8854
  • docs: fix race condition in creating connection for lambda #8845 AbdelrahmanHafez
  • docs: add options.path for Model.populate(...) #8833 AbdelrahmanHafez
  • docs: use ES6 classes for custom schema type example #8802

5.9.10 / 2020-04-20

  • fix: upgrade mongodb -> 3.5.6, bson -> 1.1.4 #8719
  • fix(document): avoid calling $set() on object keys if object path isn't in schema #8751
  • fix(timestamps): handle timestamps on doubly nested subdocuments #8799
  • fix(schematype): throw error if default is set to a schema instance #8751
  • fix: handle $elemMatch projection with select: false in schema #8818 #8806 AbdelrahmanHafez
  • docs: make FAQ questions more linkable #8825 AbdelrahmanHafez
  • docs(validation): use init() as opposed to once('index') in unique example #8816
  • docs: clarify insertMany() return value #8820 dandv
  • docs(populate+query): fix typos #8793 #8794 dandv
  • docs(model): document skipId parameter #8791 AbdelrahmanHafez

5.9.9 / 2020-04-13

  • fix(model): make Model.bulkWrite accept strict option #8782 #8788 AbdelrahmanHafez
  • fix(virtual): make populated virtual getter return value when it is passed in #8775 #8774 makinde
  • fix(document): handle validating document array whose docs contain maps and nested paths #8767
  • fix(document): skip discriminator key when overwriting a document #8765
  • fix(populate): support clone option with lean #8761 #8760
  • docs(transactions): use endSession() in all transactions examples #8741
  • docs(queries): expand streaming section to include async iterators, cursor timeouts, and sesssion idle timeouts #8720
  • docs(model+query+findoneandupdate): add docs for returnOriginal option #8766
  • docs(model): fix punctuation #8788 dandv
  • docs: fix typos #8780 #8799 dandv

5.9.8 / 2020-04-06

  • fix(map): run getters when calling Map#get() #8730
  • fix(populate): handle refPath function in embedded discriminator #8731
  • fix(model): allow setting timestamps to false for bulkWrite #8758 #8745 AbdelrahmanHafez
  • fix(model): pass custom options to exists() when no changes to save #8764 #8739 AbdelrahmanHafez
  • fix(update): respect useNestedStrict: false when updating a single nested path #8735
  • fix(schema): allow modelName as a schema path, since modelName is a static property on models #7967
  • docs(promises): add section about using exec() with queries and await #8747
  • docs(connections): clarify that connectTimeoutMS doesn't do anything with useUnifiedTopology, should use serverSelectionTimeoutMS #8721
  • chore: upgrade mpath -> 0.7.0 #8762 roja548

5.9.7 / 2020-03-30

  • fix(map): avoid infinite loop when setting a map of documents to a document copied using spread operator #8722
  • fix(query): clean stack trace for filter cast errors so they include the calling file #8691
  • fix(model): make bulkWrite updates error if strict and upsert are set and filter contains a non-schema path #8698
  • fix(cast): make internal castToNumber() allow undefined #8725 p3x-robot

5.9.6 / 2020-03-23

  • fix(document): allow saving document with nested document array after setting nestedArr.0 #8689
  • docs(connections): expand section about multiple connections to describe patterns for exporting schemas #8679
  • docs(populate): add note about execPopulate() to "populate an existing document" section #8671 #8275
  • docs: fix broken links #8690 AbdelrahmanHafez
  • docs(guide): fix typos #8704 MateRyze
  • docs(guide): fix minor typo #8683 pkellz

5.9.5 / 2020-03-16

  • fix: upgrade mongodb driver -> 3.5.5 #8667 #8664 AbdelrahmanHafez
  • fix(connection): emit "disconnected" after losing connectivity to every member of a replica set with useUnifiedTopology: true #8643
  • fix(array): allow calling slice() after push() #8668 #8655 AbdelrahmanHafez
  • fix(map): avoid marking map as modified if setting key to the same value #8652
  • fix(updateValidators): don't run Mixed update validator on dotted path underneath mixed type #8659
  • fix(populate): ensure top-level limit applies if one document being populated has more than limit results #8657
  • fix(populate): throw error if both limit and perDocumentLimit are set #8661 #8658 AbdelrahmanHafez
  • docs(findOneAndUpdate): add a section about the rawResult option #8662
  • docs(guide): add section about loadClass() #8623
  • docs(query): improve Query#populate() example to clarify that sort doesn't affect the original result's order #8647

5.9.4 / 2020-03-09

  • fix(document): allow new Model(doc) to set immutable properties when doc is a mongoose document #8642
  • fix(array): make sure you can call unshift() after slice() #8482
  • fix(schema): propagate typePojoToMixed to implicitly created arrays #8627
  • fix(schema): also propagate typePojoToMixed option to schemas implicitly created because of typePojoToMixed #8627
  • fix(model): support passing background option to syncIndexes() #8645
  • docs(schema): add a section about the _id path in schemas #8625
  • docs(virtualtype+populate): document using match with virtual populate #8616
  • docs(guide): fix typo #8648 sauzy34

5.9.3 / 2020-03-02

  • fix: upgrade mongodb driver -> 3.5.4 #8620
  • fix(document): set subpath defaults when overwriting single nested subdoc #8603
  • fix(document): make calling validate() with single nested subpath only validate that single nested subpath #8626
  • fix(browser): make mongoose.model() return a class in the browser to allow hydrating populated data in the browser #8605
  • fix(model): make syncIndexes() and cleanIndexes() drop compound indexes with _id that aren't in the schema #8559
  • docs(connection+index): add warnings to explain that bufferMaxEntries does nothing with useUnifiedTopology #8604
  • docs(document+model+query): add options.timestamps parameter docs to findOneAndUpdate() and findByIdAndUpdate() #8619
  • docs: fix out of date links to tumblr #8599

5.9.2 / 2020-02-21

  • fix(model): add discriminator key to bulkWrite filters #8590
  • fix(document): when setting nested array path to non-nested array, wrap values top-down rather than bottom up when possible #8544
  • fix(document): dont leave nested key as undefined when setting nested key to empty object with minimize #8565
  • fix(document): avoid throwing error if setting path to Mongoose document with nullish _doc #8565
  • fix(update): handle Binary type correctly with runValidators #8580
  • fix(query): run deleteOne hooks only on Document#deleteOne() when setting options.document = true for Schema#pre() #8555
  • fix(document): allow calling validate() in post validate hook without causing parallel validation error #8597
  • fix(virtualtype): correctly copy options when cloning #8587
  • fix(collection): skip creating capped collection if autoCreate set to false #8566
  • docs(middleware): clarify that updateOne and deleteOne hooks are query middleware by default, not document middleware #8581
  • docs(aggregate): clarify that Aggregate#unwind() can take object parameters as well as strings #8594

5.9.1 / 2020-02-14

  • fix(model): set session when calling save() with no changes #8571
  • fix(schema): return correct pathType when single nested path is embedded under a nested path with a numeric name #8583
  • fix(queryhelpers): remove Object.values() for Node.js 4.x-6.x support #8596
  • fix(cursor): respect sort order when using eachAsync() with parallel and a sync callback #8577
  • docs: update documentation of custom _id overriding in discriminators #8591 sam-mfb

5.9.0 / 2020-02-13

  • fix: upgrade to MongoDB driver 3.5 #8520 #8563
  • feat(schematype): support setting default options for schema type (trim on all strings, etc.) #8487
  • feat(populate): add perDocumentLimit option that limits per document in find() result, rather than across all documents #7318
  • feat(schematype): enable setting transform option on individual schematypes #8403
  • feat(timestamps): allow setting currentTime option for setting custom function to get the current time #3957
  • feat(connection): add Connection#watch() to watch for changes on an entire database #8425
  • feat(document): add Document#$op property to make it easier to tell what operation is running in middleware #8439
  • feat(populate): support limit as top-level populate option #8445

5.8.13 / 2020-02-13

  • fix(populate): use safe get to avoid crash if schematype doesn't have options #8586

5.8.12 / 2020-02-12

  • fix(query): correctly cast dbref $id with $elemMatch #8577
  • fix(populate): handle populating when some embedded discriminator schemas have refPath but none of the subdocs have refPath #8553
  • docs: add useUnifiedTopology to homepage example #8558 AbdelrahmanHafez
  • refactor(utils): moving promiseOrCallback to helpers/promiseOrCallback #8573 hugosenari

5.8.11 / 2020-01-31

  • fix(document): allow calling validate() multiple times in parallel on subdocs to avoid errors if Mongoose double-validates taxilian #8548 #8539
  • fix(connection): allow calling initial mongoose.connect() after connection helpers on the same tick #8534
  • fix(connection): throw helpful error when callback param to mongoose.connect() or mongoose.createConnection() is not a function #8556
  • fix(drivers): avoid unnecessary caught error when importing #8528
  • fix(discriminator): remove unnecessary utils.merge() samgladstone #8542
  • docs: add "built with mongoose" page #8540

5.8.10 / 2020-01-27

  • perf(document): improve performance of document creation by skipping unnecessary split() calls #8533 igrunert-atlassian
  • fix(document): only call validate once for deeply nested subdocuments #8532 #8531 taxilian
  • fix(document): create document array defaults in forward order, not reverse #8514
  • fix(document): allow function as message for date min/max validator #8512
  • fix(populate): don't try to populate embedded discriminator that has populated path but no refPath #8527
  • fix(document): plugins from base schema when creating a discriminator #8536 samgladstone
  • fix(document): ensure parent and ownerDocument are set for subdocs in document array defaults #8509
  • fix(document): dont set undefined keys to null if minimize is false #8504
  • fix(update): bump timestamps when using update aggregation pipelines #8524
  • fix(model): ensure cleanIndexes() drops indexes with different collations #8521
  • docs(model): document insertMany lean option #8522
  • docs(connections): document authSource option #8517

5.8.9 / 2020-01-17

  • fix(populate): skip populating embedded discriminator array values that don't have a refPath #8499
  • docs(queries): clarify when to use queries versus aggregations #8494

5.8.8 / 2020-01-14

  • fix(model): allow using lean with insertMany() #8507 #8234 ntsekouras
  • fix(document): don't throw parallel validate error when validating subdoc underneath modified nested path #8486
  • fix: allow typePojoToMixed as top-level option #8501 #8500 AbdelrahmanHafez
  • docs(populate+schematypes): make note of _id getter for ObjectIds in populate docs #8483

5.8.7 / 2020-01-10

  • fix(documentarray): modify ownerDocument when setting doc array to a doc array thats part of another document #8479
  • fix(document): ensure that you can call splice() after slice() on an array #8482
  • docs(populate): improve cross-db populate docs to include model refs #8497

5.8.6 / 2020-01-07

  • chore: merge changes from 4.13.20 and override mistaken publish to latest tag

4.13.20 / 2020-01-07

  • fix(schema): make aliases handle mongoose-lean-virtuals #6069

5.8.5 / 2020-01-06

  • fix(document): throw error when running validate() multiple times on the same document #8468
  • fix(model): ensure deleteOne() and deleteMany() set discriminator filter even if no conditions passed #8471
  • fix(document): allow pre('validate') hooks to throw errors with name = 'ValidationError' #8466
  • fix(update): move top level $set of immutable properties to $setOnInsert so upserting with immutable properties actually sets the property #8467
  • fix(document): avoid double-running validators on single nested subdocs within single nested subdocs #8468
  • fix(populate): support top-level match option for virtual populate #8475
  • fix(model): avoid applying skip when populating virtual with count #8476

5.8.4 / 2020-01-02

  • fix(populate): ensure populate virtual gets set to empty array if localField is undefined in the database #8455
  • fix(connection): wrap mongoose.connect() server selection timeouts in MongooseTimeoutError for more readable stack traces #8451
  • fix(populate): allow deselecting foreignField from projection by prefixing with - #8460
  • fix(populate): support embedded discriminators with refPath when not all discriminator schemas have refPath #8452
  • fix(array): allow defining enum on array if an array of numbers #8449

5.8.3 / 2019-12-23

  • fix: upgrade mongodb -> 3.4.1 #8430 jaschaio
  • fix(populate): don't add empty subdocument to array when populating path underneath a non-existent document array #8432
  • fix(schema): handle _id option for document array schematypes #8450
  • fix(update): call setters when updating mixed type #8444
  • docs(connections): add note about MongoTimeoutError.reason #8402

5.8.2 / 2019-12-20

  • fix(schema): copy .add()-ed paths when calling .add() with schema argument #8429
  • fix(cursor): pull schema-level readPreference when using Query#cursor() #8421
  • fix(cursor): wait for all promises to resolve if parallel is greater than number of documents #8422
  • fix(document): depopulate entire array when setting array path to a partially populated array #8443
  • fix: handle setDefaultsOnInsert with deeply nested subdocs #8392
  • fix(document): report DocumentNotFoundError if underlying document deleted but no changes made #8428 #8371 AbdelrahmanHafez
  • docs(populate): clarify limitations of limit option for populate and suggest workaround #8409
  • docs(deprecations): explain which connection options are no longer relevant with useUnifiedTopology #8411
  • chore: allow browser build to be published #8435 #8427 captaincaius

5.8.1 / 2019-12-12

  • fix(documentarray): dont attempt to cast when modifying array returned from map() #8399
  • fix(document): update single nested subdoc parent when setting to existing single nested doc #8400
  • fix(schema): add $embeddedSchemaType property to arrays for consistency with document arrays #8389

5.8.0 / 2019-12-09

  • feat: wrap server selection timeout errors in MongooseTimeoutError to retain original stack trace #8259
  • feat(model): add Model.validate() function that validates a POJO against the model's schema #7587
  • feat(schema): add Schema#pick() function to create a new schema with a picked subset of the original schema's paths #8207
  • feat(schema): add ability to change CastError message using cast option to SchemaType #8300
  • feat(schema): group indexes defined in schema path with the same name #6499
  • fix(model): build all indexes even if one index fails #8185 unusualbob
  • feat(browser): pre-compile mongoose/browser #8350 captaincaius
  • fix(connection): throw error when setting unsupported option #8335 #6899 AbdelrahmanHafez
  • feat(schema): support enum validator for number type #8139
  • feat(update): allow using MongoDB 4.2 update aggregation pipelines, with no Mongoose casting #8225
  • fix(update): make update validators run on all subpaths when setting a nested path, even omitted subpaths #3587
  • feat(schema): support setting _id as an option to single nested schema paths #8137
  • feat(query): add Query#mongooseOptions() function #8296
  • feat(array): make MongooseArray#push() support using $position #4322
  • feat(schema): make pojo paths optionally become subdoc instead of Mixed #8228 captaincaius
  • feat(model): add Model.cleanIndexes() to drop non-schema indexes #6676
  • feat(document): make updateOne() document middleware pass this to post hooks #8262
  • feat(aggregate): run pre/post aggregate hooks on explain() #5887
  • docs(model+query): add session option to docs for findOneAndX() methods #8396

5.7.14 / 2019-12-06

  • fix(cursor): wait until all eachAsync() functions finish before resolving the promise #8352
  • fix(update): handle embedded discriminator paths when discriminator key is defined in the update #8378
  • fix(schematype): handle passing message function to SchemaType#validate() as positional arg #8360
  • fix(map): handle cloning a schema that has a map of subdocuments #8357
  • docs(schema): clarify that uppercase, lowercase, and trim options for SchemaString don't affect RegExp queries #8333

5.7.13 / 2019-11-29

  • fix: upgrade mongodb driver -> 3.3.5 #8383
  • fix(model): catch the error when insertMany fails to initialize the document #8365 #8363 Fonger
  • fix(schema): add array.$, array.$.$ subpaths for nested arrays #6405
  • docs(error): add more detail about the ValidatorError class, including properties #8346
  • docs(connection): document Connection#models property #8314

5.7.12 / 2019-11-19

  • fix: avoid throwing error if calling push() on a doc array with no parent #8351 #8317 #8312 AbdelrahmanHafez
  • fix(connection): only buffer for "open" events when calling connection helper while connecting #8319
  • fix(connection): pull default database from connection string if specified #8355 #8354 zachazar
  • fix(populate+discriminator): handle populating document whose discriminator value is different from discriminator model name #8324
  • fix: add mongoose.isValidObjectId() function to test whether Mongoose can cast a value to an objectid #3823
  • fix(model): support setting excludeIndexes as schema option for subdocs #8343
  • fix: add SchemaMapOptions class for options to map schematype #8318
  • docs(query): remove duplicate omitUndefined options #8349 mdumandag
  • docs(schema): add Schema#paths docs to public API docs #8340

5.7.11 / 2019-11-14

  • fix: update mongodb driver -> 3.3.4 #8276
  • fix(model): throw readable error when casting bulkWrite update without a 'filter' or 'update' #8332 #8331 AbdelrahmanHafez
  • fix(connection): bubble up connected/disconnected events with unified topology #8338 #8337
  • fix(model): delete $versionError after saving #8326 #8048 Fonger
  • test(model): add test for issue #8040 #8341 Fonger

5.7.10 / 2019-11-11

  • perf(cursor): remove unnecessary setTimeout() in eachAsync(), 4x speedup in basic benchmarks #8310
  • docs(README): re-order sections for better readability #8321 dandv
  • chore: make npm test not hard-code file paths #8322 stieg

5.7.9 / 2019-11-08

  • fix(schema): support setting schema path to an instance of SchemaTypeOptions to fix integration with mongoose-i18n-localize #8297 #8292
  • fix(populate): make retainNullValues set array element to null if foreign doc with that id was not found #8293
  • fix(document): support getter setting virtual on manually populated doc when calling toJSON() #8295
  • fix(model): allow objects with toBSON() to make it to save() #8299

5.7.8 / 2019-11-04

  • fix(document): allow manually populating path within document array #8273
  • fix(populate): update top-level populated() when updating document array with populated subpaths #8265
  • fix(cursor): throw error when using aggregation cursor as async iterator #8280
  • fix(schema): retain _id: false in schema after nesting in another schema #8274
  • fix(document): make Document class an event emitter to support defining documents without models in node #8272
  • docs: document return types for .discriminator() #8287
  • docs(connection): add note about exporting schemas, not models, in multi connection paradigm #8275
  • docs: clarify that transforms defined in toObject() options are applied to subdocs #8260

5.7.7 / 2019-10-24

  • fix(populate): make populate virtual consistently an empty array if local field is only empty arrays #8230
  • fix(query): allow findOne(objectid) and find(objectid) #8268

5.7.6 / 2019-10-21

  • fix: upgrade mongodb driver -> 3.3.3 to fix issue with failing to connect to a replica set if one member is down #8209
  • fix(document): fix TypeError when setting a single nested subdoc with timestamps #8251
  • fix(cursor): fix issue with long-running eachAsync() cursor #8249 #8235
  • fix(connection): ensure repeated close events from useUnifiedTopology don't disconnect Mongoose from replica set #8224
  • fix(document): support calling Document constructor directly in Node.js #8237
  • fix(populate): add document array subpaths to parent doc populated() when calling DocumentArray#push() #8247
  • fix(options): add missing minlength and maxlength to SchemaStringOptions #8256
  • docs: add documentarraypath to API docs, including DocumentArrayPath#discriminator() #8164
  • docs(schematypes): add a section about the type property #8227
  • docs(api): fix Connection.close return param #8258 gosuhiman
  • docs: update link to broken image on home page #8253 krosenk729

5.7.5 / 2019-10-14

  • fix(query): delete top-level _bsontype property in queries to prevent silent empty queries #8222
  • fix(update): handle subdocument pre('validate') errors in update validation #7187
  • fix(subdocument): make subdocument#isModified use parent document's isModified #8223
  • docs(index): add favicon to home page #8226
  • docs: add schema options to API docs #8012
  • docs(middleware): add note about accessing the document being updated in pre('findOneAndUpdate') #8218
  • refactor: remove redundant code in ValidationError #8244 AbdelrahmanHafez

5.7.4 / 2019-10-09

  • fix(schema): handle required: null and required: undefined as required: false #8219
  • fix(update): support updating array embedded discriminator props if discriminator key in $elemMatch #8063
  • fix(populate): allow accessing populate virtual prop underneath array when virtual defined on top level #8198
  • fix(model): support passing options to Model.remove() #8211
  • fix(document): handle Document#set() merge option when setting underneath single nested schema #8201
  • fix: use options constructor class for all schematypes #8012

5.7.3 / 2019-09-30

  • fix: make CoreMongooseArray#includes() handle fromIndex parameter #8203
  • fix(update): cast right hand side of $pull as a query instead of an update for document arrays #8166
  • fix(populate): handle virtual populate of an embedded discriminator nested path #8173
  • docs(validation): remove deprecated isAsync from validation docs in favor of emphasizing promises #8184
  • docs(documents): add overwriting section #8178
  • docs(promises): add note about queries being thenable #8110
  • perf: avoid update validators going into Mixed types #8192 birdofpreyru
  • refactor: remove async as a prod dependency #8073

5.7.2 / 2019-09-23

  • fix(mongoose): support mongoose.set('autoIndex', false) #8158
  • fix(discriminator): support tiedValue parameter for embedded discriminators analagous to top-level discriminators #8164
  • fix(query): handle toConstructor() with entries-style sort syntax #8159
  • fix(populate): avoid converting mixed paths into arrays if populating an object path under Mixed #8157
  • fix: use $wrapCallback when using promises for mongoose-async-hooks
  • fix: handle queries with setter that converts value to Number instance #8150
  • docs: add mongoosejs-cli to readme #8142
  • docs: fix example typo for Schema.prototype.plugin() #8175 anaethoss

5.7.1 / 2019-09-13

  • fix(query): fix TypeError when calling findOneAndUpdate() with runValidators #8151 fernandolguevara
  • fix(document): throw strict mode error if setting an immutable path with strict mode: false #8149
  • fix(mongoose): support passing options object to Mongoose constructor #8144
  • fix(model): make syncIndexes() handle changes in index key order #8135
  • fix(error): export StrictModeError as a static property of MongooseError #8148 ouyuran
  • docs(connection+mongoose): add useUnifiedTopology option to connect() and openUri() docs #8146

5.7.0 / 2019-09-09

  • feat(document+query): support conditionally immutable schema paths #8001
  • perf(documentarray): refactor to use ES6 classes instead of mixins, ~30% speedup #7895
  • feat: use MongoDB driver 3.3.x for MongoDB 4.2 support #8083 #8078
  • feat(schema+query): add pre('validate') and post('validate') hooks for update validation #7984
  • fix(timestamps): ensure updatedAt gets incremented consistently using update with and without $set #4768
  • feat(query): add Query#get() to make writing custom setters that handle both queries and documents easier #7312
  • feat(document): run setters on defaults #8012
  • feat(document): add aliases: false option to Document#toObject() #7548
  • feat(timestamps): support skipping updatedAt and createdAt for individual save() and update() #3934
  • docs: fix index creation link in guide #8138 joebowbeer

5.6.13 / 2019-09-04

  • fix(parallel): fix parallelLimit when fns is empty #8130 #8128 sibelius
  • fix(document): ensure nested mixed validator gets called exactly once #8117
  • fix(populate): handle justOne = undefined #8125 taxilian

5.6.12 / 2019-09-03

  • fix(schema): handle required validator correctly with clone() #8111
  • fix(schema): copy schematype getters and setters when cloning #8124 StphnDamon
  • fix(discriminator): avoid unnecessarily cloning schema to avoid leaking memory on repeated discriminator() calls #2874
  • docs(schematypes): clarify when Mongoose uses toString() to convert an object to a string #8112 TheTrueRandom
  • docs(plugins): fix out of date link to npm docs #8100
  • docs(deprecations): fix typo #8109 jgcmarins
  • refactor(model): remove dependency on async.parallelLimit() for insertMany() #8073

5.6.11 / 2019-08-25

  • fix(model): allow passing options to exists() #8075
  • fix(document): make validateUpdatedOnly option handle pre-existing errors #8091
  • fix: throw readable error if middleware callback isnt a function #8087
  • fix: don't throw error if calling find() on a nested array #8089
  • docs(middleware): clarify that you must add middleware before compiling your model #5087
  • docs(query): add missing options to setOptions() #8099

5.6.10 / 2019-08-20

  • fix(schema): fix require() path to work around yet another bug in Jest #8053
  • fix(document): skip casting when initing a populated path #8062
  • fix(document): prevent double-calling validators on mixed objects with nested properties #8067
  • fix(query): handle schematype with null options when checking immutability #8070 rich-earth
  • fix(schema): support Schema#path() to get schema path underneath doc array #8057
  • docs(faq): add disable color instruction #8066

5.6.9 / 2019-08-07

  • fix(model): delete versionError after saving to prevent memory leak #8048
  • fix(cursor): correctly handle batchSize option with query cursor #8039
  • fix(populate): handle virtual populate with count = 0 if virtual embedded in doc array #7573
  • fix(schema): allow declaring ObjectId array with { type: 'ObjectID' }, last 'D' case insensitive #8034

5.6.8 / 2019-08-02

  • fix(aggregate): allow modifying pipeline in pre('aggregate') hooks #8017
  • fix(query): make findOneAndReplace() work with orFail() #8030
  • fix(document): allow saving an unchanged document if required populated path is null #8018
  • fix(debug): support disabling colors in debug mode #8033 Mangosteen-Yang
  • docs: add async-await guide #8028 Rossh87
  • docs(plugins): rewrite plugins docs to be more modern and not use strange = exports syntax #8026
  • docs(transactions): clarify relationship between session in docs and MongoDB driver ClientSession class, link to driver docs #8009

5.6.7 / 2019-07-26

  • fix(document): support validators on nested arrays #7926
  • fix(timestamps): handle timestamps: false in child schema #8007
  • fix(query): consistently support new option to findOneAndX() as an alternative to returnOriginal #7846
  • fix(document): make inspect() never return null, because a document or nested path is never == null #7942
  • docs(query+lean): add links to mongoose-lean-virtuals, mongoose-lean-getters, mongoose-lean-defaults #5606
  • docs: add example for Schema#pre(Array) #8022 Mangosteen-Yang
  • docs(schematype): updated comment from Schema.path to proper s.path #8013 chrisweilacker
  • chore: upgrade nyc #8015 kolya182

5.6.6 / 2019-07-22

  • fix(populate): handle refPath returning a virtual with Query#populate() #7341
  • fix(populate): handle refPath in discriminator when populating top-level model #5109
  • fix(mongoose): ensure destucturing and named imports work for Mongoose singleton methods like set(), etc. #6039
  • fix(query): add missing options for deleteOne and deleteMany in Query #8004 Fonger
  • fix(schema): make embedded discriminators instanceof their parent types #5005
  • fix(array): make validators a private property that doesn't show up in for/in #6572
  • docs(api): fix array API docs that vanished because of #7798 #7979
  • docs(discriminators+api): add single nested discriminator to discriminator docs and API docs #7983
  • docs(connection+mongoose): make option lists consistent between mongoose.connect(), mongoose.createConnection(), and conn.openUri() #7976
  • docs(validation): clarify resolve(false) vs reject() for promise-based async custom validators #7761
  • docs(guide): use correct mongoose.set() instead of mongoose.use() #7998
  • docs: add redis cache example #7997 usama-asfar

5.6.5 / 2019-07-17

  • fix(document): handle setting non-schema path to ObjectId or Decimal128 if strict: false #7973
  • fix(connection): remove backwards-breaking multiple mongoose.connect() call for now #7977
  • fix(schema): print invalid value in error message when a schema path is set to undefined or null #7956
  • fix(model): throw readable error if calling new Model.discriminator() #7957
  • fix(mongoose): export cast() function #7975 perfectstorm88
  • docs(model): fix link to Model.inspect() and add example #7990
  • docs: fix broken anchor links on validation tutorial #7966
  • docs(api): fix broken links to split API pages #7978
  • chore: create LICENSE.md #7989 Fonger

5.6.4 / 2019-07-08

  • fix(schema): support pre(Array, Function) and post(Array, Function) #7803
  • fix(document): load docs with a once property successfully #7958
  • fix(queryhelpers): ensure parent select overwrites child path select if parent is nested #7945
  • fix(schema): make clone() correctly copy array embedded discriminators #7954
  • fix(update): fix error when update property gets casted to null #7949
  • fix(connection): bubble up attemptReconnect event for now #7872
  • docs(tutorials): add virtuals tutorial #7965
  • docs(connection): add section on connection handling #6997

5.6.3 / 2019-07-03

  • fix(document): respect projection when running getters #7940
  • fix(model): call createCollection() in syncIndexes() to ensure the collection exists #7931
  • fix(document): consistently use post-order traversal for gathering subdocs for hooks #7929
  • fix(schema): ensure Schema#pathType() returns correct path type given non-existent positional path #7935
  • fix(ChangeStream): set closed if emitting close event #7930
  • fix(connection): bubble up 'attemptReconnect' event from MongoDB connection #7872
  • docs: fix broken .jade links on search page #7932
  • docs: correct link to Query#select() #7953 rayhatfield
  • docs(README): add list of related projects #7773

4.13.19 / 2019-07-02

  • fix(aggregate): make setOptions() work as advertised #7950 #6011 cdimitroulas

5.6.2 / 2019-06-28

  • fix(update): allow using update() with immutable createdAt #7917
  • fix(model): pass doc parameter to save() error handling middleware #7832
  • fix(mongoose): add applyPluginsToChildSchemas option to allow opting out of global plugins for child schemas #7916
  • docs(connection): document useCache option for useDb() #7923
  • docs: fix broken link in FAQ #7925 christophergeiger3

5.6.1 / 2019-06-24

  • fix(update): skip setting defaults for single embedded subdocs underneath maps #7909
  • fix(document): copy date objects correctly when strict = false #7907
  • feat(mongoose): throw an error if calling mongoose.connect() multiple times while connected #7905 Fonger
  • fix(document): copies virtuals from array subdocs when casting array of docs with same schema #7898
  • fix(schema): ensure clone() copies single embedded discriminators correctly #7894
  • fix(discriminator): merge instead of overwriting conflicting nested schemas in discriminator schema #7884
  • fix(populate): ignore nullish arguments when calling populate() #7913 rayhatfield
  • docs: add getters/setters tutorial #7919
  • docs: clean up error docs so they refer to Error rather than MongooseError #7867
  • docs: fix a couple broken links #7921 kizmo04
  • refactor: remove unnecessary if #7911 rayhatfield

5.6.0 / 2019-06-14

  • feat(schematype): add immutable option to disallow changing a given field #7671
  • docs: split API docs into separate pages to make API documentation more Google-able #7812
  • perf(array): remove all mixins in favor of ES6 classes, ~20% faster in basic benchmarks #7798
  • feat(document): use promise rejection error message when async custom validator throws an error #4913
  • feat(virtual): pass document as 3rd parameter to virtual getters and setters to enable using arrow functions #4143
  • feat(model): add Model.exists() function to quickly check whether a document matching filter exists #6872
  • feat(index+connection): support setting global and connection-level maxTimeMS
  • feat(populate): support setting ref to a function for conventional populate #7669
  • feat(document): add overwrite() function that overwrites all values in a document #7830
  • feat(populate): support PopulateOptions#connection option to allow cross-db populate with refPath #6520
  • feat(populate): add skipInvalidIds option to silently skip population if id is invalid, instead of throwing #7706
  • feat(array): skip empty array default if there's a 2dsphere index on a geojson path #3233
  • feat(query): add getFilter() as an alias of getQuery() to be more in line with API docs #7839
  • feat(model): add Model.inspect() to make models not clutter util.inspect() #7836
  • perf(discriminator): skip calling createIndex() on indexes that are defined in the base schema #7379
  • docs: upgrade from Jade to latest Pug #7812
  • docs(README): update reference to example schema.js #7899 sharils
  • docs(README): improve variable name #7900 sharils
  • chore: replace charAt(0) with startsWith #7897 Fonger
  • chore: replace indexOf with includes, startsWith and endsWith for String #7897 Fonger

5.5.15 / 2019-06-12

  • fix(connection): reject initial connect promise even if there is an on('error') listener #7850
  • fix(map): make of automatically convert POJOs to schemas unless typeKey is set #7859
  • fix(update): use discriminator schema to cast update if discriminator key specified in filter #7843
  • fix(array): copy atomics from source array #7891 #7889 jyrkive
  • fix(schema): return this when Schema.prototype.add is called with Schema #7887 Mickael-van-der-Beek
  • fix(document): add numAffected and result to DocumentNotFoundError for better debugging #7892 #7844

5.5.14 / 2019-06-08

  • fix(query): correct this scope of setters in update query #7876 Fonger
  • fix(model): reset modifiedPaths after successful insertMany #7852 #7873 Fonger
  • fix(populate): allow using refPath with virtual populate #7848
  • fix(document): prepend private methods getValue and setValue with $ #7870 Fonger
  • fix: update mongodb driver -> 3.2.7 #7871 Fonger
  • docs(tutorials): add tutorial about custom casting functions #7045
  • docs(connection): fix outdated events document #7874 Fonger
  • docs: fix typo in lean docs #7875 tannakartikey
  • docs: move off of KeenIO for tracking and use self-hosted analytics instead

5.5.13 / 2019-06-05

  • fix(model): support passing deleteOne options #7860 #7857 Fonger
  • fix(update): run setters on array elements when doing $addToSet, $push, etc #4185
  • fix(model): support getting discriminator by value when creating a new model #7851
  • docs(transactions): add section about the withTransaction() helper #7598
  • docs(schema): clarify relationship between Schema#static() and Schema#statics #7827
  • docs(model): fix typo projetion to projection #7868 dfdeagle47
  • docs(schema): correct schema options lists #7828

5.5.12 / 2019-05-31

  • fix(document): fix unexpected error when loading a document with a nested property named schema #7831
  • fix(model): skip applying static hooks by default if static name conflicts with query middleware (re: mongoose-delete plugin) #7790
  • fix(query): apply schema-level projections to the result of findOneAndReplace() #7654
  • fix: upgrade mongodb driver -> 3.2.6
  • docs(tutorials): add findOneAndUpdate() tutorial #7847
  • docs(validation): add updateOne() and updateMany() to list of update validator operations #7845
  • docs(model): make sure options lists in update() API line up #7842

5.5.11 / 2019-05-23

  • fix(discriminator): allow numeric discriminator keys for embedded discriminators #7808
  • chore: add Node.js 12 to travis build matrix #7784

5.5.10 / 2019-05-20

  • fix(discriminator): allow user-defined discriminator path in schema #7807
  • fix(query): ensure findOneAndReplace() sends replacement to server #7654
  • fix(cast): allow [] as a value when casting $nin #7806
  • docs(model): clarify that setters do run on update() by default #7801
  • docs: fix typo in FAQ #7821 jaona

5.5.9 / 2019-05-16

  • fix(query): skip schema setters when casting $regexp $options #7802 Fonger
  • fix(populate): don't skip populating doc array properties whose name conflicts with an array method #7782
  • fix(populate): make populated virtual return undefined if not populated #7795
  • fix(schema): handle custom setters in arrays of document arrays #7804 Fonger
  • docs(tutorials): add query casting tutorial #7789

5.5.8 / 2019-05-13

  • fix(document): run pre save hooks on nested child schemas #7792
  • fix(model): set $session() before validation middleware for bulkWrite/insertMany #7785 #7769 Fonger
  • fix(query): make getPopulatedPaths() return deeply populated paths #7757
  • fix(query): suppress findAndModify deprecation warning when using Model.findOneAndUpdate() #7794
  • fix: upgrade mongodb -> 3.2.4 #7794
  • fix(document): handle a couple edge cases with atomics that happen when schema defines an array property named 'undefined' #7756
  • docs(discriminator): correct function parameters #7786 gfpacheco

5.5.7 / 2019-05-09

  • fix(model): set $session() before pre save middleware runs when calling save() with options #7742
  • fix(model): set $session before pre remove hooks run when calling remove() with options #7742
  • fix(schema): support remove() on nested path #2398
  • fix(map): handle setting populated map element to doc #7745
  • fix(query): return rawResult when inserting with options {new:false,upsert:true,rawResult:true} #7774 #7770 LiaanM
  • fix(schematype): remove internal validators option because it conflicts with Backbone #7720

5.5.6 / 2019-05-06

  • fix(document): stop converting arrays to objects when setting non-schema path to array with strict: false #7733
  • fix(array): make two Mongoose arrays assert.deepEqual() each other if they have the same values #7700
  • fix(populate): support populating a path in a document array embedded in an array #7647
  • fix(populate): set populate virtual count to 0 if local field is empty #7731
  • fix(update): avoid throwing cast error if casting array filter that isn't in schema with strictQuery = false #7728
  • docs: fix typo in distinct() description #7767 phil-r

5.5.5 / 2019-04-30

  • fix(document): ensure nested properties within single nested subdocs get set correctly when overwriting single nested subdoc #7748
  • fix(document): skip non-object validators in schema types #7720
  • fix: bump mongodb driver -> 3.2.3 #7752
  • fix(map): disallow setting map key with special properties #7750 Fonger

5.5.4 / 2019-04-25

  • fix(document): avoid calling custom getters when saving #7719
  • fix(timestamps): handle child schema timestamps correctly when reusing child schemas #7712
  • fix(query): pass correct callback for _legacyFindAndModify #7736 Fonger
  • fix(model+query): allow setting replacement parameter for findOneAndReplace() #7654
  • fix(map): make delete() unset the key in the database #7746 Fonger
  • fix(array): use symbol for _schema property to avoid confusing deep equality checks #7700
  • fix(document): prevent depopulate() from removing fields with empty array #7741 #7740 Fonger
  • fix: make MongooseArray#includes support ObjectIds #7732 #6354 hansemannn
  • fix(document): report correct validation error index when pushing onto doc array #7744 Fonger

5.5.3 / 2019-04-22

  • fix: add findAndModify deprecation warning that references the useFindAndModify option #7644
  • fix(document): handle pushing a doc onto a discriminator that contains a doc array #7704
  • fix(update): run setters on array elements when doing $set #7679
  • fix: correct usage of arguments while buffering commands #7718 rzymek
  • fix(document): avoid error clearing modified subpaths if doc not defined #7715 bitflower
  • refactor(array): move _parent property behind a symbol #7726 #7700
  • docs(model): list out all operations and options for bulkWrite() #7055
  • docs(aggregate): use eachAsync() instead of nonexistent each() #7699
  • docs(validation): add CastError validation example #7514
  • docs(query+model): list out all options and callback details for Model.updateX() and Query#updateX() #7646

5.5.2 / 2019-04-16

  • fix(document): support setting nested path to non-POJO object #7639
  • perf(connection): remove leaked event handler in Model.init() so deleteModel() frees all memory #7682
  • fix(timestamps): handle custom statics that conflict with built-in functions (like mongoose-delete plugin) #7698
  • fix(populate): make Document#populated() work for populated subdocs #7685
  • fix(document): support .set() on document array underneath embedded discriminator path #7656

5.5.1 / 2019-04-11

  • fix(document): correctly overwrite all properties when setting a single nested subdoc #7660 #7681
  • fix(array): allow customization of array required validator #7696 freewil
  • fix(discriminator): handle embedded discriminators when casting array defaults #7687
  • fix(collection): ensure collection functions return a promise even if disconnected #7676
  • fix(schematype): avoid indexing properties with { unique: false, index: false } #7620
  • fix(aggregate): make Aggregate#model() with no arguments return the aggregation's model #7608

5.5.0 / 2019-04-08

  • feat(model): support applying hooks to custom static functions #5982
  • feat(populate): support specifying a function as match #7397
  • perf(buffer): avoid calling defineProperties() in Buffer constructor #7331
  • feat(connection): add plugin() for connection-scoped plugins #7378
  • feat(model): add Model#deleteOne() and corresponding hooks #7538
  • feat(query): support hooks for Query#distinct() #5938
  • feat(model): print warning when calling create() incorrectly with a session #7535
  • feat(document): add Document#isEmpty() and corresponding helpers for nested paths #5369
  • feat(document): add getters option to Document#get() #7233
  • feat(query): add Query#projection() to get or overwrite the current projection #7384
  • fix(document): set full validator path on validatorProperties if propsParameter set on validator #7447
  • feat(document): add Document#directModifiedPaths() #7373
  • feat(document): add $locals property #7691
  • feat(document): add validateUpdatedOnly option that only validates modified paths in save() #7492 captaincaius
  • chore: upgrade MongoDB driver to v3.2.0 #7641
  • fix(schematype): deprecate isAsync option for custom validators #6700
  • chore(mongoose): deprecate global.MONGOOSE_DRIVER_PATH so we can be webpack-warning-free in 6.0 #7501

5.4.23 / 2019-04-08

  • fix(document): report cast error when string path in schema is an array in MongoDB #7619
  • fix(query): set deletedCount on result of remove() #7629
  • docs(subdocs): add note about parent() and ownerDocument() to subdocument docs #7576

5.4.22 / 2019-04-04

  • fix(aggregate): allow modifying options in pre('aggregate') hook #7606
  • fix(map): correctly init maps of maps when loading from MongoDB #7630
  • docs(model+query): add omitUndefined option to docs for updateX() and findOneAndX() #3486
  • docs: removed duplicate Query.prototype.merge() reference from doc #7684 shihabmridha
  • docs(schema): fix shardKey type to object instead of bool #7668 kyletsang
  • docs(api): fix Model.prototypedelete link #7665 pixcai

5.4.21 / 2019-04-02

  • fix(updateValidators): run update validators correctly on Decimal128 paths #7561
  • fix(update): cast array filters in nested doc arrays correctly #7603
  • fix(document): allow .get() + .set() with aliased paths #7592
  • fix(document): ensure custom getters on single nested subdocs don't get persisted if toObject.getters = true #7601
  • fix(document): support setting subdoc path to subdoc copied using object rest {...doc} #7645
  • docs(schema): correct out-of-date list of reserved words #7593
  • docs(model+query): add link to update results docs and examples of using results of updateOne(), etc. #7582
  • docs: use atomic as opposed to $atomic consistently #7649 720degreeLotus

5.4.20 / 2019-03-25

  • docs(tutorials): add tutorial about lean() #7640
  • fix(discriminator): fix wrong modelName being used as value to partialFilterExpression index #7635 #7634 egorovli
  • fix(document): allow setters to modify this when overwriting single nested subdoc #7585
  • fix(populate): handle count option correctly with multiple docs #7573
  • fix(date): support declaring min/max validators as functions #7600 ChienDevIT
  • fix(discriminator): avoid projecting in embedded discriminator if only auto-selected path is discriminator key #7574
  • fix(discriminator): use discriminator model when using new BaseModel() with discriminator key #7586
  • fix(timestamps): avoid throwing if doc array has timestamps and array is undefined #7625 serg33v
  • docs(document): explain DocumentNotFoundError in save() docs #7580
  • docs(query): fix .all() param type and add example #7612 720degreeLotus
  • docs: add useNewUrlParser to mongoose.connect for some pages #7615 YC

5.4.19 / 2019-03-11

  • fix(mongoose): ensure virtuals set on subdocs in global plugins get applied #7572
  • docs(tutorials): add "Working With Dates" tutorial #7597
  • docs(guide): clarify that versioning only affects array fields #7555
  • docs(model): list out all bulkWrite() options #7550

5.4.18 / 2019-03-08

  • fix(document): handle nested virtuals in populated docs when parent path is projected out #7491
  • fix(model): make subclassed models handle discriminators correctly #7547
  • fix(model): remove $versionError from save options for better debug output #7570

5.4.17 / 2019-03-03

  • fix(update): handle all positional operator when casting array filters #7540
  • fix(populate): handle populating nested path where top-level path is a primitive in the db #7545
  • fix(update): run update validators on array filters #7536
  • fix(document): clean modified subpaths when sorting an array #7556
  • fix(model): cast $setOnInsert correctly with nested docs #7534
  • docs: remove extra curly brace from example #7569 kolya182

5.4.16 / 2019-02-26

  • fix(schema): handle nested objects with _id: false #7524
  • fix(schema): don't throw error if declaring a virtual that starts with a map path name #7464
  • fix(browser): add stubbed model() function so code that uses model doesn't throw #7541 caub
  • fix(schema): merge virtuals correctly #7563 yoursdearboy
  • docs(connections): add reconnectFailed to connection docs #7477
  • docs(index): fix typo #7553 DenrizSusam
  • refactor(schema): iterate over paths instead of depending on childSchemas #7554

5.4.15 / 2019-02-22

  • fix(update): don't call schematype validators on array if using $pull with runValidators #6971
  • fix(schema): clone all schema types when cloning an array #7537
  • docs(connections): improve connectTimeoutMS docs and socketTimeoutMS docs to link to Node.js net.setTimeout() #5169
  • docs: fix setters example in migration guide #7546 freewil

5.4.14 / 2019-02-19

  • fix(populate): make getters option handle nested paths #7521
  • fix(documentarray): report validation errors that occur in an array subdoc created using create() and then set() #7504
  • docs(schema): add examples for schema functions that didn't have any #7525
  • docs: add MongooseError to API docs and add list of error names
  • docs(CONTRIBUTING): fix link #7530 sarpik

5.4.13 / 2019-02-15

  • fix(query): throw handy error when using updateOne() with overwrite: true and no dollar keys #7475
  • fix(schema): support inheriting existing schema types using Node.js util.inherits like mongoose-float #7486
  • docs(connections): add list of connection events #7477

5.4.12 / 2019-02-13

  • fix(connection): dont emit reconnected due to socketTimeoutMS #7452
  • fix(schema): revert check for false schema paths #7516 #7512
  • fix(model): don't delete unaliased keys in translateAliases #7510 chrischen
  • fix(document): run single nested schematype validator if nested path has a default and subpath is modified #7493
  • fix(query): copy mongoose options when using Query#merge() #1790
  • fix(timestamps): don't call createdAt getters when setting updatedAt on new doc #7496
  • docs: improve description of ValidationError #7515 JulioJu
  • docs: add an asterisk before comment, otherwise the comment line is not generated #7513 JulioJu