unstale

npm / mongoose

mongoose

What changed in mongoose 6 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.

48 breaking11 security1 deprecations33 new APIs and options17 performance19 behavior and defaults183 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.3.1 on npm

mongoose 9272 changes

Breaking changes 43

  • Catches top-level filter fields starting with $ to prevent bypasses using MongoDB internal expressions.

    8.24.10, 9.12.2release notesrelease notes

  • The unused use$geoWithin property was removed.

    9.12.0release notes

  • Special properties such as __proto__ are disallowed as paths in mod().

    9.11.4release notes

  • Setting special properties via virtual() is disallowed.

    8.24.7, 9.11.4release notesrelease notessecurity advisory

  • Special properties such as __proto__ are disallowed as paths in where().

    8.24.7, 9.11.4release notesrelease notes

  • Removing a path now also drops its subpaths and singleNestedPaths.

    9.10.2release notes

  • Removing a map path also drops its values subpath, and removes maps that live under nested paths.

    9.9.4release notes

  • Casting to Double now rejects arrays.

    8.24.6, 9.9.3release notesrelease notes

  • Casting to Int32 now rejects arrays.

    9.9.3release notes

  • Queries now reject update modifiers without paths.

    9.8.1release notes

  • Empty document array elements are no longer minimized to null.

    8.24.2, 9.8.0release notesrelease notes

  • Schematype lookups return only own properties, and setting schema paths under special properties is disallowed.

    9.7.2release notes

  • Throws an error when overwriting an array selected with $slice.

    9.7.0release notes

  • Removes the union fallback from validateSync().

    9.7.0release notes

  • insertOne() throws ObjectParameterError when the document argument is not an object.

    9.5.0release notes

  • Reverts running setters on default values during upsert.

    9.4.1release notes

  • TypeScript now reports an error when $and contains an unrecognized query operator.

    9.4.0release notes

  • Makes MergeType distributive over union types.

    9.4.0release notes

  • Retains populated paths in the result type unless depopulate: true is set.

    9.4.0release notes

  • Schema type errors now use MongooseError instead of plain Error, allowing developers to handle them consistently.

    9.3.3release notes

  • Setting null or undefined as options now throws an error.

    9.3.2release notes

  • Removes the dead GeoSearch type.

    9.2.0release notes

  • Removes the dead MapReduce type.

    9.2.0release notes

  • Inference no longer adds _id to nested paths and handles _id: false in options and schema definitions.

    9.2.0release notes

  • The browser build is removed; browser support moves to @mongoosejs/browser.

    9.0.0release notes

  • bson is no longer a direct dependency; use mongodb/lib/bson instead.

    9.0.0release notes

  • The casterConstructor property is removed in favor of embeddedSchemaType and Constructor.

    9.0.0release notes

  • The TypeScript parameters for create() are stricter, and its generics are removed to prevent type inference.

    9.0.0release notes

  • The TypeScript this type for default() changes to HydratedDocument.

    9.0.0release notes

  • FilterQuery properties no longer resolve to any in TypeScript.

    9.0.0release notes

  • findOne(null) and similar calls now throw an error instead of returning the first document.

    9.0.0release notes

  • In TypeScript, id is now a virtual rather than a property on the Document base class.

    9.0.0release notes

  • The TypeScript parameters for insertOne() are stricter, and its generics are removed to prevent type inference.

    9.0.0release notes

  • Mongoose updates to MongoDB Node driver v7, which may affect applications relying on driver behavior.

    9.0.0release notes

  • Browser support is moved to the @mongoosejs/browser package.

    9.0.0release notes

  • The connection noListener option is removed.

    9.0.0release notes

  • Callback-based pre middleware, including calling next() in pre() hooks, is no longer supported.

    9.0.0release notes

  • The TypeScript this type for required() changes to HydratedDocument.

    9.0.0release notes

  • The schematype caster property is removed in favor of embeddedSchemaType and Constructor.

    9.0.0release notes

  • Update pipelines are disallowed by default; enable them with the updatePipeline option.

    9.0.0release notes

  • The UUID schema type now returns BSON UUIDs.

    9.0.0release notes

  • validate() is now an async function, and Kareem hooks are called directly rather than through wrappers.

    9.0.0release notes

  • Virtual ref functions are called with the subdocument instead of the top-level document.

    9.0.0release notes

Security 9

Deprecations 1

  • Adds $getChanges() as an alias for getChanges(), which is deprecated.

    9.4.0release notes

New APIs and options 28

  • Adds Query.prototype.findAndCount() for composable paginated queries.

    9.11.0release notes

  • Adds a wrapper for limit-and-skip-based pagination with countDocuments.

    9.10.0release notes

  • Adds a method to make it easier to define query helpers in TypeScript.

    9.10.0release notes

  • Supports a middleware skip option for cursors and custom hooks.

    9.10.0release notes

  • Adds pathsToSave to the SaveOptions type.

    9.8.0release notes

  • Adds a schema option to filter or throw on unknown fields during document hydration.

    9.8.0release notes

  • Adds a standard schema adapter for models.

    9.7.0release notes

  • Adds Node.js TracingChannel support for APM instrumentation.

    9.7.0release notes

  • Adds $percentile to TypeScript aggregation expression types.

    9.6.3release notes

  • Exports ArrayProjectionOperators for use in TypeScript code.

    9.6.0release notes

  • Exports Projector for use in TypeScript code.

    9.6.0release notes

  • Adds the allowNull option to disallow null values even when a schema path is not required.

    9.6.0release notes

  • Adds a timestamp option to debug output.

    9.5.0release notes

  • Extends the defaults query option to find().

    9.5.0release notes

  • Adds an option to explicitly disable update cloning.

    9.5.0release notes

  • Implements validation for Union schemas and subdocuments.

    9.4.0release notes

  • Supports the discriminators option inline for better TypeScript support.

    9.3.0release notes

  • Adds a helper for reusing pipelines with $unionWith in TypeScript.

    8.24.0, 9.3.0release notesrelease notes

  • An option was added to skip middleware.

    9.2.0release notes

  • Adds a strict option to Model.hydrate(...).

    9.2.0release notes

  • Adds the flattenUUIDs option to toObject() and toJSON().

    8.23.0, 9.2.0release notesrelease notes

  • DocumentArrayElement is exposed for use by developers.

    9.1.3release notes

  • Allows calling create() with TRawDocType for better generics support.

    9.1.0release notes

  • Adds getAtomics() support so custom container types can utilize atomics.

    8.21.0, 9.1.0release notesrelease notes

  • Adds an exclude option for optimistic concurrency.

    9.1.0release notes

  • Adds support for TypeScript-style enums.

    8.21.0, 9.1.0release notesrelease notes

  • Exports a type that replicates Mongoose 8 InferRawDocType behavior.

    9.0.2release notes

  • Schema.create() is added to support TypeScript type inference.

    9.0.0release notes

Performance 16

  • Avoid quadratic concat() when creating a MongooseMap from an object.

    9.12.1release notes

  • Improves performance for document arrays by caching paths with defaults and schemas with select paths, and avoiding unnecessary $isModified() lookups.

    9.12.0release notes

  • Makes MergeType more efficiently handle MergeType<A, {}>.

    9.11.2release notes

  • Avoids applying saveSubdocs and sharding plugins to subdocuments.

    9.11.2release notes

  • Projection metadata is cached, and flat projections avoid scanning all projected paths.

    9.9.3release notes

  • Improves general change tracking performance.

    9.9.0release notes

  • Avoids adding $setOnInsert for createdAt unless upsert is set.

    9.9.0release notes

  • Improves insertMany() performance.

    9.9.0release notes

  • Improves toObject performance with faster string checks and by avoiding unnecessary isSelected checks on paths with no getters.

    9.9.0release notes

  • Improves save performance by avoiding unnecessary promise allocations and reducing path, default, and dirty-state overhead.

    9.7.1release notes

  • Removes an unnecessary clone in findOneAndUpdate().

    9.5.0release notes

  • Removes unnecessary overhead when saving a new document.

    9.3.0release notes

  • Indexed-path checks for subdocuments are optimized.

    9.2.2release notes

  • pathsToSave is optimized for subdocuments.

    9.2.2release notes

  • Selects only _id when checking document existence during save(), improving performance.

    9.1.2release notes

  • Buffer comparison uses native Buffer.equals() for improved performance.

    9.0.1release notes

Behavior and default changes 17

  • Int32 paths are now treated as number in schema types.

    9.11.1release notes

  • Adds type narrowing when using projection in find and findOne.

    9.10.0release notes

  • Custom cast error messages from document validation now replace {MODEL}.

    8.24.8, 9.9.5release notesrelease notes

  • Includes id among HydratedDocument virtuals by default unless explicitly set.

    9.4.0release notes

  • Runs setters on default values during upsert.

    9.4.0release notes

  • Supports generating JSON Schema for unions.

    9.4.0release notes

  • Makes UnpackedIntersection distributive over union types.

    9.4.0release notes

  • Default functions now receive the query as their context.

    9.3.0release notes

  • Types allow unknown keys in subdocuments while retaining autocomplete suggestions.

    9.2.4release notes

  • The warning is delayed until createIndexes runs so it can include the model name.

    9.2.0release notes

  • Adds the id virtual getter by default when TOverrides is Record<string, never>.

    9.1.0release notes

  • Can handle saving just a subpath of a modified path.

    9.1.0release notes

  • Passes update and options to pre('updateOne') hooks.

    8.21.0, 9.1.0release notesrelease notes

  • Save hooks are asyncified for improved stack traces.

    9.0.0release notes

  • SchemaType.prototype.doValidate() is asyncified for improved stack traces.

    9.0.0release notes

  • Update validators are asyncified for improved stack traces.

    9.0.0release notes

  • The TypeScript this type for validate() changes to HydratedDocument | Query.

    9.0.0release notes

Fixes and other changes 158

  • Avoids converting BigInts to numbers when using addToSet().

    9.12.2release notes

  • Casts $and, $or, and $nor wherever they appear in an array filter.

    9.12.2release notes

  • Propagates an error passed to destroy() without re-emitting it if the error was already emitted.

    9.12.2release notes

  • Throws cast errors and respects the strict option in replaceOne().

    9.12.2release notes

  • Setting dotted paths at least three levels deep underneath single nested subdocuments is now allowed.

    8.24.9, 9.12.2release notesrelease notes

  • Resets document state before retrying after a transient commit error.

    9.12.2release notes

  • Subdocuments pushed via array filters receive timestamps.

    9.12.1release notes

  • Cursor destruction finishes after terminal initialization.

    9.12.1release notes

  • Calling push() again with $each keeps values that were pushed earlier.

    9.12.1release notes

  • Validates paths under a nested path passed to Model.validate().

    9.12.1release notes

  • Skips array-level validators for $pull with $in.

    9.12.1release notes

  • Cloned queries handle inherited read preference and read concern.

    9.12.1release notes

  • Cloned queries handle inherited read preference and read concern.

    9.12.1release notes

  • Compares UUIDs by value so pull() and addToSet() work.

    9.12.0release notes

  • Recomputes derived caches and delays _preCompile() until an actual model is compiled, rather than for subdocuments or document arrays.

    9.12.0release notes

  • autoCreate is no longer disabled for a primary ReadPreference instance.

    9.11.3release notes

  • autoIndex is no longer disabled for a primary ReadPreference instance.

    9.11.3release notes

  • Model.validate() no longer crashes when nested objects are missing.

    9.11.3release notes

  • Upserts and nested timestamps now honor overwriteImmutable.

    9.11.3release notes

  • Casts array filter values in bulkWrite().

    9.11.2release notes

  • Allows function messages for number min/max and string minlength validators.

    9.11.2release notes

  • Array filters continue to be cast after a path not in the schema.

    9.11.1release notes

  • Filters selecting a discriminator key with $eq or $in now use the embedded discriminator schema.

    9.11.1release notes

  • flattenDecimals is now applied when toObject() takes the shallow fast path.

    9.11.1release notes

  • Initializing nested document arrays no longer passes arrayPathIndex to subdocuments.

    9.11.1release notes

  • Operators under $not inside $elemMatch on primitive arrays are now cast.

    9.11.1release notes

  • Destroying query cursors now awaits driver cleanup.

    9.11.1release notes

  • Setting a path to a nested object now calls recursive toObject().

    9.11.1release notes

  • UpdateManyModel update typing is now aligned with UpdateQuery.

    9.11.1release notes

  • UpdateOneModel update typing is now aligned with UpdateQuery.

    9.11.1release notes

  • Avoids double-calling validators on document arrays underneath nested paths.

    9.11.0release notes

  • Passes TLeanResultType into query for type narrowing support with lean().

    9.11.0release notes

  • Handle MongoDB server 9.x returning collation: { locale: 'simple' } on all indexes.

    8.24.5, 9.10.4release notesrelease notes

  • Compare dates by value in indexOf() so pull() removes them.

    8.24.6, 9.10.4release notesrelease notes

  • Register $set when Map#set() replaces an array.

    9.10.4release notes

  • Resolve dotted parent paths when collecting deferred sub-populate children.

    9.10.4release notes

  • Cast case and then expressions in $expr $switch branches.

    9.10.4release notes

  • Preserves unsaved documents after ordered bulkSave errors.

    9.10.3release notes

  • Avoids mutating the caller's update object in bulkWrite updateMany.

    9.10.3release notes

  • Replaces {MODEL} in cast error messages from update and bulkWrite casting.

    9.10.3release notes

  • Opens the collection when the connection was already opened.

    9.10.3release notes

  • Setters declared on the union path itself now run.

    8.24.8, 9.10.3release notesrelease notes

  • Cast error messages from castObject now replace {MODEL}.

    9.10.2release notes

  • Cloning with a seen map now preserves circular arrays.

    8.24.6, 9.10.2release notesrelease notes

  • Path-level setters are now registered on Map paths.

    9.10.2release notes

  • Relaxes Model generics so typed virtuals can be passed to populate in TypeScript 7 with skipLibCheck.

    9.10.1release notes

  • Defaults are now applied to undefined array elements.

    9.10.0release notes

  • The method's return type now includes the new static.

    9.10.0release notes

  • Correctly builds the dotted path when checking inclusive path selection.

    9.9.5release notes

  • Adds missing properties to the return type, improving the type information available to callers.

    9.9.5release notes

  • The schema is now passed through when casting a nested comparison.

    8.24.6, 9.9.5release notesrelease notes

  • Indexes bulkSave write errors by document id.

    9.9.4release notes

  • Cloned document array elements retain their own constructor signature.

    9.9.4release notes

  • Clarifies that a duplicate index warning means the index is not created.

    9.9.4release notes

  • Cloning keeps the map value schematype as a single object.

    8.24.8, 9.9.4release notesrelease notes

  • Reference lookup during hydration now uses the document's model.

    8.24.8, 9.9.4release notesrelease notes

  • Avoids repeating null in an enum when the enum already lists null.

    9.9.4release notes

  • bulkSave() sets the document session so transaction retries restore document state.

    9.9.2release notes

  • The optimistic concurrency paths option now supports map wildcards.

    9.9.2release notes

  • toJSONSchema() puts enum on array elements and supports the object enum form.

    9.9.2release notes

  • Types now respect schema toObject and toJSON options.

    9.9.2release notes

  • Delete state is restored across transaction retries.

    9.9.2release notes

  • Types now support overriding schema-level lean with lean: false.

    9.9.1release notes

  • Avoids path collisions when excluding subdocuments that have nested select: false paths.

    9.9.1release notes

  • Adds the discriminator key to each member of the embedded discriminator enum.

    9.9.0release notes

  • Model.schema remains typed when TSchema is omitted.

    9.8.1release notes

  • StandardSchema type inference now respects the _id option.

    9.8.1release notes

  • Avoids mutating shared setters when casting array query values.

    9.8.0release notes

  • Correctly handles version keys when bulkSave() inserts new documents.

    9.8.0release notes

  • Types now support extra fields in hydrate() when strict: false.

    9.8.0release notes

  • Correctly casts object-shaped geo query values.

    9.8.0release notes

  • Correctly handles excluded parent paths with optimistic concurrency.

    9.8.0release notes

  • Fixes TypeScript handling of nested objects typed as interfaces when using create.

    9.7.4release notes

  • Corrects TypeScript handling of the this parameter for methods when versionKey is used.

    9.7.4release notes

  • Corrects the return type of Model.validate() to Promise<TRawDocType>.

    8.24.2, 9.7.3release notesrelease notes

  • Reindexes subdocuments after array reordering and removal so subsequent nested changes save using the correct path.

    8.24.1, 9.7.2release notesrelease notes

  • Avoids accessing special properties in Document.prototype.get().

    8.24.1, 9.7.2release notesrelease notes

  • Runs separate populate queries per document when the resulting $in filter has more than 50k elements, reducing the risk of BSON size errors.

    9.7.1release notes

  • Includes the ObjectId regex pattern in toJSONSchema() output.

    9.7.1release notes

  • Aggregation middleware no longer waits on buffering to run.

    9.7.0release notes

  • Primitive types within unions are cast when applying create casting.

    9.7.0release notes

  • Cloned arrays are isolated from source documents.

    8.24.1, 9.6.3release notesrelease notes

  • Error validators receive the raw string value; trimming to 30 characters is limited to the maxlength validator.

    8.23.1, 9.6.3release notesrelease notes

  • Preserves a user-provided value when overwriteImmutable: true is used.

    9.6.3release notes

  • Handles compiling with the exactOptionalPropertyTypes TypeScript option.

    8.24.0, 9.6.2release notesrelease notes

  • Correctly handles modified subpaths when the parent path is unset after modifying.

    9.6.2release notes

  • Fixes the _id getter helper on ObjectId.

    9.6.1release notes

  • QueryFilter types now respect string unions and enums.

    9.6.0release notes

  • Preserves the reason in the CastError message after setModel().

    9.5.0release notes

  • Query helpers now pass default options to discriminators.

    9.5.0release notes

  • Fixes handling of included and excluded nested paths with optimistic concurrency.

    9.5.0release notes

  • Casting updates no longer treats documents with a $set() method as objects with a $set property.

    9.5.0release notes

  • Updates are cloned only when absolutely necessary, improving support for updates with __proto__.

    9.5.0release notes

  • Snapshots Date values in the heartbeat handler and flushes the queue on recovery.

    9.4.0release notes

  • Compares Set objects properly.

    9.4.0release notes

  • Corrects the error reported for an unsupported query operator with a number.

    9.4.0release notes

  • Validates that the argument is actually a connection using duck-typing with a version check.

    9.4.0release notes

  • MergeType is distributive, improving populate type support for models whose hydrated document type is a union.

    9.3.3release notes

  • castNumber replaces assert.ok with a descriptive Error.

    9.3.2release notes

  • Connection errors use MongooseError instead of Error.

    9.3.2release notes

  • Query errors use MongooseError instead of Error.

    9.3.2release notes

  • Query filter cast errors now include the array value in the error message, making failures easier to diagnose.

    9.3.2release notes

  • Fixes sorting in bulkWrite().

    9.3.1release notes

  • Passing a string projection to hydrate() is now handled correctly.

    9.3.1release notes

  • Fixes the type definition for HydratedDocType in autoTypedVirtuals.

    9.3.1release notes

  • The QueryCursor close callback now has the correct this context.

    9.3.1release notes

  • Schema options are now inferred correctly for model context in statics.

    9.3.1release notes

  • Schema.prototype.plugin() now allows passing a model with custom TStatics.

    9.3.1release notes

  • Resolves deeply nested discriminator paths in arrayFilters.

    9.3.0release notes

  • Emits ready on the next tick, allowing the stream to initialize.

    9.3.0release notes

  • Adds type constraints for Document#$model() and Document#model().

    9.3.0release notes

  • Falls back to InferRawDocType instead of pulling a non-raw inferred document type when EnforcedDocType is not set.

    9.3.0release notes

  • Avoids a TypeError when handling a nullish update.

    9.3.0release notes

  • Makes validateBeforeSave handling backwards compatible.

    9.3.0release notes

  • Handles calling watch() on a disconnected connection.

    8.24.0, 9.3.0release notesrelease notes

  • Fixes type issues when defining timestamps and virtuals with methods and/or statics in schema options.

    9.2.4release notes

  • Corrects the type signature so bulkSave() takes an array of THydratedDocumentType.

    9.2.3release notes

  • The document pathsToSave filter now handles all update operators and preserves unsaved state.

    9.2.2release notes

  • refPath now works as a function, including on map paths with $*.

    9.2.2release notes

  • Checks child filter paths before applying defaults.

    8.23.1, 9.2.2release notesrelease notes

  • Allows assigning QueryFilter<DocType> to QueryFilter<any>.

    9.2.1release notes

  • Preserves subdocument toObject() field types when using virtuals and versionKey options.

    9.2.1release notes

  • Fixes a duplicate identifier in mongoosejs 9.2.0.

    9.2.1release notes

  • An undefined id option is treated as not provided.

    9.2.0release notes

  • An undefined strict option is treated as not provided.

    9.2.0release notes

  • An undefined strictQuery option is treated as not provided.

    9.2.0release notes

  • Correctly clones a subdocument when updating a document array.

    9.1.6release notes

  • Fixes change tracking for document arrays stored in nested maps.

    9.1.6release notes

  • Subpopulation is deferred until after match functions, avoiding comparisons against populated subdocuments.

    9.1.6release notes

  • Fixes toObject() type inference when timestamps and virtuals are used.

    9.1.6release notesrelease notes

  • Corrects type inference handling for subdocuments and document arrays.

    9.1.5release notes

  • Map subdocuments are validated when loaded with init.

    9.1.5release notes

  • Prevents indexes and callQueue duplication when schemas are shared as nested schemas.

    8.24.4, 9.1.5release notesrelease notes

  • Cloning map and array subdocuments now fixes their parent document reference.

    8.21.1, 9.1.4release notesrelease notes

  • Documents retrieved by a cursor now have sessions attached.

    9.1.4release notes

  • hydrate() now handles nested schema arrays.

    9.1.4release notes

  • Accessing nested paths on a prototype no longer crashes.

    9.1.4release notes

  • The timestamps option supports both boolean and QueryTimestampsConfig values when using insertMany().

    9.1.3release notes

  • Basic type casting is applied to paths underneath subdocuments.

    9.1.3release notes

  • Errors when merging a normal update with a pipeline include previews of the current and incoming updates.

    9.1.3release notes

  • Correctly handles PopulatedDoc and other TypeScript unions with Document members.

    9.1.3release notes

  • Passes options to pre-save hooks for subdocuments.

    9.1.2release notes

  • Avoids 'Cannot mix array and object updates' when using doc.updateOne() with a pipeline.

    9.1.1release notes

  • The filter property supports Mongoose query casting in its types.

    8.21.1, 9.1.0release notesrelease notesrelease notes

  • Passes options to pre('deleteOne') hooks.

    8.21.0, 9.1.0release notesrelease notes

  • Triggers the error post hook when a pre-hook throws an error during bulkWrite.

    9.0.2release notes

  • Correctly infers virtuals and methods from schema options.

    9.0.2release notes

  • Applies Mongoose casting to the default MongoDB driver _id in RootFilterOperators.

    9.0.2release notes

  • Fixes detection of the this parameter type for methods with arguments.

    9.0.2release notes

  • Accumulates version mode flags using bitwise OR.

    9.0.2release notes

  • Passes the overwriteImmutable option to castUpdate in bulkWrite.

    7.8.8, 8.20.2, 9.0.1release notesrelease notesrelease notes

  • Clears timeouts in collection operations.

    9.0.1release notes

  • Fixes an incorrect variable bug in double casting.

    9.0.1release notes

  • Adds the enumValues property to Number enums for consistency with String enums.

    9.0.1release notes

  • Fixes overwriteImmutable with timestamps: true and adds types for overwriteImmutable.

    9.0.1release notes

  • Uses function overrides instead of | Query<any, any> to support using Query as a filter.

    9.0.1release notes

  • Missing pluralizations are added and existing pluralization is fixed, including virus to viruses.

    9.0.0release notes

  • RootQuerySelector, Condition, and related types are consolidated with the MongoDB driver's types.

    9.0.0release notes

mongoose 831 changes

Breaking changes 3

  • cursor() now applies sanitizeFilter.

    8.24.3release notes

  • Schema path lookups no longer return inherited properties, including for paths underneath maps of subdocuments.

    8.24.1release notes

  • Defaults the _id type to ObjectId for Document.

    8.20.0release notes

Security 1

  • Prototype pollution through query helpers such as gt() and in() is avoided.

    8.24.7release notes

New APIs and options 3

  • Supports the sort option in updateOne and replaceOne operations passed to Model.bulkWrite().

    8.23.1release notes

  • hydrate() now accepts a strict option, allowing developers to control strict behavior when hydrating documents.

    8.22.0release notes

  • Documents now include toBSON() in their types.

    8.21.1release notesrelease notes

Performance 1

  • Avoids computing all modified paths when running setDefaultsOnInsert and update validators; paths are calculated only if there are defaults to set.

    8.19.2release notes

Behavior and default changes 1

  • Passes the parent schema to SchemaType constructors, making it easier to implement custom container types.

    8.20.0release notes

Fixes and other changes 22

  • A primary ReadPreference instance no longer disables autoIndex or autoCreate.

    8.24.9release notes

  • Removing map paths now works cleanly, including maps under nested paths.

    8.24.8release notes

  • MongooseMap.has() now supports ObjectId keys.

    8.24.8release notes

  • Query path collisions are avoided when excluding a subdocument that has a select: false child.

    8.24.6release notes

  • Reindex subdocuments when addToSet() skips a duplicate.

    8.24.5release notes

  • Bulk write updates now respect the schema currentTime option.

    8.21.1release notes

  • When cloning a document with subdocuments, the subdocuments now have the cloned document as their parent.

    8.21.1release notesrelease notes

  • After a successful doc.deleteOne(), $isDeleted is now set.

    8.20.4release notes

  • Paths with default: null are no longer treated as required in schema types.

    8.20.3release notes

  • Improves the error when Document.prototype.init() is called with null or undefined.

    8.20.3release notes

  • Allows partial statics to be passed to schema.statics().

    8.20.3release notes

  • Mongoose now bumps the version if necessary after a successful bulkSave().

    7.8.8, 8.20.2release notesrelease notes

  • Type definitions now allow calling schema.static() with as TStatics.

    8.20.2release notes

  • Corrects the Model.schema type and fixes the unknown check for this parameter type in schema.methods, improving TypeScript type checking.

    8.20.1release notes

  • Casts the id parameter based on the schema _id type.

    8.20.0release notes

  • Avoids throwing an error when a schema contains an array of unions.

    8.19.4release notes

  • Corrects the return type of discriminator to Model<U>.

    8.19.4release notes

  • Validation errors now store the original index of the document in the insertMany input.

    8.19.4release notes

  • Correctly applies the shard key when calling deleteOne().

    8.19.3release notes

  • Correctly infers the empty array type [] as any[].

    8.19.3release notes

  • Correctly caches text indexes as 'text' rather than 1.

    8.19.3release notes

  • Corrects handling of relative versus absolute paths with maps and subdocuments.

    8.19.2release notes

mongoose 75 changes

Breaking changes 1

  • Schema options are copied when merging schemas with new Schema() or Schema.prototype.add().

    7.0.0release notes

Security 1

New APIs and options 1

Behavior and default changes 1

  • Allows merging single nested paths and document array paths outside discriminator schema merges.

    7.8.11release notes

Fixes and other changes 1

  • Adds defensive checks for special properties when getting values from a document.

    7.8.10release notes

mongoose 64 changes

Breaking changes 1

  • The deprecated safe option was removed in favor of write concerns.

    6.0.0release notes

New APIs and options 1

  • Adds aggregate operator types for $firstN, $lastN, $bottom, $bottomN, $minN and $maxN.

    6.13.9release notes

Fixes and other changes 2

  • countDocuments() can now be called with options.

    6.0.0release notes

  • $parent() is used as a getter function for a subdocument's parent.

    6.0.0release notes