unstale

npm / mongoose

mongoose

What changed in mongoose 8 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-21.

1 breaking2 security2 performance1 behavior and defaults15 fixes and other

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

npx @unstale/cli init

@unstale/cli on npm

mongoose 916 changes

Security 2

  • Mongoose: Prototype pollution in mongoose update casting via __proto__-prefixed dotted path (Schema._getSchema/path getter)

    7.8.10, 8.24.1, 9.7.2security advisory

  • Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection

    6.13.9, 8.22.1, 9.1.6security advisory

Performance 2

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

    9.11.2release notes

  • Avoids applying saveSubdocs and sharding plugins to subdocuments.

    9.11.2release notes

Behavior and default changes 1

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

    9.11.1release notes

Fixes and other changes 11

  • 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

mongoose 85 changes

Breaking changes 1

  • Casting to Int32 or Double now rejects arrays.

    8.24.6release notes

Fixes and other changes 4

  • Cloning with a seen map now preserves circular arrays.

    8.24.6release notes

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

    8.24.6release notes

  • pull() now removes dates by comparing their values in indexOf(), rather than relying on reference equality.

    8.24.6release notes

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

    8.24.6release notes