We added the ability to set `ref` to a function in 5.6.0, but with a limitation: `this` and `doc` were the top-level document in v5.x.
That made populating subdocs based on subdoc properties hard
In v6.0, `ref` functions now know what subdoc they're on 😎
#NodeJS#MongoDB
Mongoose 6.0.1 released, with a few minor fixes mostly related to TypeScript
⭐️ Allow calling Model.aggregate() with options
📒 Add instance, options, schema properties to SchemaType class
github.com/Automattic/mongoo…#NodeJS#MongoDB#JavaScript
Mongoose 6 uses v4.x of the MongoDB Node driver (`mongodb` on npm).
This introduces a couple of breaking changes for Mongoose users. One is the result of `updateMany()` has a few new properties. `res.n` no longer works!
#NodeJS#MongoDB#JavaScript
In v5.13.8 we added the missing `match` property to `VirtualTypeOptions` in TypeScript, so you can now use `match` with populate virtuals.
More about populating in TypeScript with Mongoose: mongoosejs.com/docs/typescri…#NodeJS#MongoDB#JavaScript
🌟🌟🌟 Mongoose 6.0.0 released!
👍 MongoDB driver 4.0 for MongoDB 5 support
😀 Arrays as proxies
🦺 `sanitizeFilter` and `trusted()`
And more! Here's the migration guide: mongoosejs.com/docs/migratin…#NodeJS#MongoDB#JavaScript
New addition to our docs: the `Document#$where` property.
`$where` is used to add extra properties to the query filter that `save()` uses. It is useful for customized optimistic concurrency, soft deletes, and more.
mongoosejs.com/docs/api/docu…#NodeJS#MongoDB#JavaScript
Mongoose 6.0.0-rc2 released:
🌟 Make document set() set keys in the order they're defined in the schema, not in the user specified object
🌟 Remove most schema reserved words - can now opt in to using save, isNew, etc. as schema paths
github.com/Automattic/mongoo…#NodeJS#MongoDB
Mongoose pro tip: if you're using a function as a default value, wrap it in a function.
Mongoose 6 will pass the document as the first param to the default function, which may cause issues if you're using a default function that uses params.
#NodeJS#MongoDB#JavaScript
Mongoose v5.13.7 released:
🏎️ Loosen up restrictions on ModelType generic for Schema for a ~50% perf improvement when compiling TypeScript and using intellisense
🔖 Fix broken Schema#index() types
Full changelog: github.com/Automattic/mongoo…#NodeJS#MongoDB#JavaScript
Mongoose 5.13.6 released:
🛠️ Upgrade mongodb driver -> 3.6.11
🛠️ Throw more helpful error when defining a document array using a schema from a different copy of the Mongoose module
Full changelog: github.com/Automattic/mongoo…#NodeJS#MongoDB#JavaScript