Skip to content

chore(deps): update dependency mongoose --> v7

FW Serviceworker requested to merge deps/mongoose-7.x into master

This MR contains the following updates:

Package Change Age Adoption Passing Confidence
mongoose (source) ^5.12.3 -> ^7.0.0 age adoption passing confidence

Release Notes

Automattic/mongoose

v7.2.0

Compare Source

==================

  • feat: upgrade mongodb -> 5.5.0
  • feat(document): add flattenObjectIds option to toObject() and toJSON() #​13383 #​13341
  • feat(query): add translateAliases option to automatically call translate aliases on query fields #​13397 #​8678 #​7511
  • feat(schema): propagate toObject and toJSON options to implicitly created schemas #​13325
  • feat(model): add throwOnValidationError option for opting into getting MongooseBulkWriteError if all valid operations succeed in bulkWrite() and insertMany() #​13410 #​13256
  • feat(types+mongoose): export MongooseError #​13403 #​13387 ramos-ph

v7.1.2

Compare Source

==================

v7.1.1

Compare Source

==================

v7.1.0

Compare Source

==================

v7.0.5

Compare Source

==================

  • fix(schema): correctly handle uuids with populate() #​13317 #​13267
  • fix(schema): add clusteredIndex to schema options #​13286 jakesjews
  • fix(document): use collection.findOne() for saving docs with no changes to avoid firing findOne middleware #​13298
  • types(schema): avoid circular constraint in TSchemaOptions with --incremental by deferring ResolveSchemaOptions<> #​13291 #​13129
  • docs(subdocs): fix mention of subdocument ".remove" function #​13312 hasezoey
  • docs: add mongoose.Promise removal to migrating to 7 guide #​13295
  • docs: updated formatting of Error Handling section to better highlight the two kinds of possible errors #​13279 Ankit-Mandal
  • docs: fix broken link #​13301 #​13281

v7.0.4

Compare Source

==================

v7.0.3

Compare Source

==================

v7.0.2

Compare Source

==================

v7.0.1

Compare Source

==================

v7.0.0

Compare Source

==================

  • BREAKING CHANGE: copy schema options when merging schemas using new Schema() or Schema.prototype.add() #​13092
  • feat(types): export mongodb types more robustly #​12948 simon-abbott
  • docs: fix populate docs #​13090 hasezoey
  • docs(migrating_to_6): added info about removal of reconnectTries and reconnectInterval options #​13083 lpizzinidev

v6.11.1

Compare Source

===================

  • fix(query): apply schema-level paths before calculating projection for findOneAndUpdate() #​13348 #​13340
  • fix: add SUPMRESS_JEST_WARNINGS environment variable to hide jest warnings #​13384 #​13373
  • types(model): allow overwriting expected param type for bulkWrite() #​13292 hasezoey

v6.11.0

Compare Source

===================

v6.10.5

Compare Source

===================

  • perf(document): avoid unnecessary loops, conditionals, string manipulation on Document.prototype.get() for 10x speedup on top-level properties #​12953
  • fix(model): execute valid write operations if calling bulkWrite() with ordered: false #​13218 #​13176
  • fix(array): pass-through all parameters #​13202 #​13201 hasezoey
  • fix: improve error message when sorting by empty string #​13249 #​10182
  • docs: add version support and check version docs #​13251 #​13193

v6.10.4

Compare Source

===================

  • fix(document): apply setters on resulting value when calling Document.prototype.$inc() #​13178 #​13158
  • fix(model): add results property to unordered insertMany() to make it easy to identify exactly which documents were inserted #​13163 #​12791
  • docs(guide+schematypes): add UUID to schematypes guide #​13184

v6.10.3

Compare Source

===================

v6.10.2

Compare Source

===================

  • fix(document): avoid setting array default if document array projected out by sibling projection #​13135 #​13043 #​13003
  • fix(documentarray): set correct document array path if making map of document arrays #​13133
  • fix: undo accidental change to engines in package.json #​13124 lorand-horvath
  • docs: quick improvement to Model.init() docs #​13054

v6.10.1

Compare Source

===================

v6.10.0

Compare Source

===================

v6.9.3

Compare Source

==================

v6.9.2

Compare Source

==================

v6.9.1

Compare Source

==================

  • fix(document): isModified should not be triggered when setting a nested boolean to the same value as previously #​12994 lpizzinidev
  • fix(document): save newly set defaults underneath single nested subdocuments #​13002 #​12905
  • fix(update): handle custom discriminator model name when casting update #​12947 wassil
  • fix(connection): handles unique autoincrement ID for connections #​12990 lpizzinidev
  • fix(types): fix type of options of Model.aggregate #​12933 ghost91-
  • fix(types): fix "near" aggregation operator input type #​12954 Jokero
  • fix(types): add missing Top operator to AccumulatorOperator type declaration #​12952 lpizzinidev
  • docs(transactions): added example for Connection.transaction() method #​12943 #​12934 lpizzinidev
  • docs(populate): fix out of date comment referencing onModel property #​13000
  • docs(transactions): fix typo in transactions.md #​12995 Parth86

v6.9.0

Compare Source

==================

v6.8.4

Compare Source

==================

v6.8.3

Compare Source

==================

  • perf: improve performance of assignRawDocsToIdStructure for faster populate on large docs #​12867 Uzlopak
  • fix(model): ensure consistent ordering of validation errors in insertMany() with ordered: false and rawResult: true #​12866
  • fix: avoid passing final callback to pre hook, because calling the callback can mess up hook execution #​12836
  • fix(types): avoid inferring timestamps if methods, virtuals, or statics set #​12871
  • fix(types): correctly infer string enums on const arrays #​12870 JavaScriptBach
  • fix(types): allow virtuals to be invoked in the definition of other virtuals #​12874 sffc
  • fix(types): add type def for Aggregate#model without arguments #​12864 hasezoey
  • docs(discriminators): add section about changing discriminator key #​12861
  • docs(typescript): explain that virtuals inferred from schema only show up on Model, not raw document type #​12860 #​12684

v6.8.2

Compare Source

==================

  • fix(schema): propagate strictQuery to implicitly created schemas for embedded discriminators #​12827 #​12796
  • fix(model): respect discriminators with Model.validate() #​12824 #​12621
  • fix(query): fix unexpected validation error when doing findOneAndReplace() with a nullish value #​12826 #​12821
  • fix(discriminator): apply built-in plugins to discriminator schema even if mergeHooks and mergePlugins are both false #​12833 #​12696
  • fix(types): add option "overwriteModels" as a schema option #​12817 #​12816 hasezoey
  • fix(types): add property "defaultOptions" #​12818 hasezoey
  • docs: make search bar respect documentation version, so you can search 5.x docs #​12548
  • docs(typescript): make note about recommending strict mode when using auto typed schemas #​12825 #​12420
  • docs: add section on sorting to query docs #​12588 IslandRhythms
  • test(query.test): add write-concern option #​12829 hasezoey

v6.8.1

Compare Source

==================

v6.8.0

Compare Source

==================

v6.7.5

Compare Source

==================

v6.7.4

Compare Source

==================

v6.7.3

Compare Source

==================

v6.7.2

Compare Source

==================

v6.7.1

Compare Source

==================

v6.7.0

Compare Source

==================

  • 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

v6.6.7

Compare Source

==================

v6.6.6

Compare Source

==================

v6.6.5

Compare Source

==================

  • 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

v6.6.4

Compare Source

==================

  • 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

v6.6.3

Compare Source

==================

v6.6.2

Compare Source

==================

  • 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

v6.6.1

Compare Source

==================

  • 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

v6.6.0

Compare Source

==================

v6.5.5

Compare Source

==================

  • 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

v6.5.4

Compare Source

==================

  • 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

v6.5.3

Compare Source

==================

v6.5.2

Compare Source

==================

  • 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

v6.5.1

Compare Source

==================

  • 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

v6.5.0

Compare Source

==================

  • 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

v6.4.7

Compare Source

==================

v6.4.6

Compare Source

==================

  • 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

v6.4.5

Compare Source

==================

v6.4.4

Compare Source

==================

v6.4.3

Compare Source

==================

  • 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

v6.4.2

Compare Source

==================

  • 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

v6.4.1

Compare Source

==================

  • 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

v6.4.0

Compare Source

==================

v6.3.9

Compare Source

==================

  • 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

v6.3.8

Compare Source

==================

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

v6.3.7

Compare Source

==================

  • 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

v6.3.6

Compare Source

==================

  • 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

v6.3.5

Compare Source

==================

  • 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

v6.3.4

Compare Source

==================

  • 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

v6.3.3

Compare Source

==================

  • 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

v6.3.2

Compare Source

==================

  • 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

v6.3.1

Compare Source

==================

  • 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

v6.3.0

Compare Source

==================

v6.2.11

Compare Source

===================

  • 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

v6.2.10

Compare Source

===================

v6.2.9

Compare Source

==================

v6.2.8

Compare Source

==================

  • 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

v6.2.7

Compare Source

==================

  • 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

v6.2.6

Compare Source

==================

  • 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

v6.2.5

Compare Source

==================

  • 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

v6.2.4

Compare Source

==================

  • 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

v6.2.3

Compare Source

==================

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

v6.2.2

Compare Source

==================

v6.2.1

Compare Source

===================

  • 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

v6.2.0

Compare Source

==================

  • 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

v6.1.10

Compare Source

===================

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

v6.1.9

Compare Source

==================

  • 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

v6.1.8

Compare Source

==================

v6.1.7

Compare Source

==================

  • 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

v6.1.6

Compare Source

==================

  • 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

v6.1.5

Compare Source

==================

  • 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

v6.1.4

Compare Source

==================

  • 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

v6.1.3

Compare Source

==================

  • 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

v6.1.2

Compare Source

==================

  • 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

v6.1.1

Compare Source

===================

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

v6.1.0

Compare Source

==================

v6.0.15

Compare Source

===================

  • 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

v6.0.14

Compare Source

===================

  • 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

v6.0.13

Compare Source

===================

  • 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

v6.0.12

Compare Source

===================

  • 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

v6.0.11

Compare Source

===================

  • 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

v6.0.10

Compare Source

===================

  • 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

v6.0.9

Compare Source

==================

  • 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

v6.0.8

Compare Source

==================

  • 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

v6.0.7

Compare Source

==================

  • 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

v6.0.6

Compare Source

==================

  • 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

v6.0.5

Compare Source

==================

  • 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

v6.0.4

Compare Source

==================

  • 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

v6.0.3

Compare Source

==================

v6.0.2

Compare Source

==================

  • 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

v6.0.1

Compare Source

===================

  • 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

v6.0.0

Compare Source

==================

  • 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

v5.13.17

Compare Source

====================

v5.13.16

Compare Source

====================

v5.13.15

Compare Source

====================

v5.13.14

Compare Source

====================

  • 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

v5.13.13

Compare Source

====================

v5.13.12

Compare Source

====================

  • 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

v5.13.11

Compare Source

====================

  • 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

v5.13.10

Compare Source

====================

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

v5.13.9

Compare Source

===================

  • 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

v5.13.8

Compare Source

===================

  • 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

v5.13.7

Compare Source

===================

  • 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

v5.13.6

Compare Source

===================

  • 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

v5.13.5

Compare Source

===================

v5.13.4

Compare Source

===================

  • 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

v5.13.3

Compare Source

===================

  • 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

v5.13.2

Compare Source

===================

v5.13.1

Compare Source

====================

v5.13.0

Compare Source

===================

  • 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

v5.12.15

Compare Source

====================

v5.12.14

Compare Source

====================

  • 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

v5.12.13

Compare Source

====================

  • 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

v5.12.12

Compare Source

====================

v5.12.11

Compare Source

====================

  • 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

v5.12.10

Compare Source

====================

  • 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

v5.12.9

Compare Source

===================

  • 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

v5.12.8

Compare Source

===================

  • 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

v5.12.7

Compare Source

===================

  • 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

v5.12.6

Compare Source

===================

  • 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

Configuration

📅 Schedule: At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this MR and you won't be reminded about this update again.


  • If you want to rebase/retry this MR, check this box.
Edited by FW Serviceworker

Merge request reports

Loading