You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix(populate): handle ref() functions that return a model instance #14343#14249
19
+
* fix: insert version key when using insertMany even if `toObject.versionKey` set to false #14344
20
+
* fix(cursor): make aggregation cursor support transform option to match query cursor #14348#14331
21
+
* docs(document): clarify that transform function option applies to subdocs #13757
22
+
23
+
8.1.2 / 2024-02-08
24
+
==================
25
+
* fix: include virtuals in document array toString() output if toObject.virtuals set #14335#14315
26
+
* fix(document): handle setting nested path to spread doc with extra properties #14287#14269
27
+
* fix(populate): call setter on virtual populated path with populated doc instead of undefined #14314
28
+
* fix(QueryCursor): remove callback parameter of AggregationCursor and QueryCursor #14299[DevooKim](https://github.com/DevooKim)
29
+
* types: add typescript support for arbitrary fields for the options parameter of Model functions which are of type MongooseQueryOptions #14342#14341[FaizBShah](https://github.com/FaizBShah)
30
+
* types(model): correct return type for findOneAndUpdate with includeResultMetadata and lean set #14336#14303
31
+
* types(connection): add type definition for `createCollections()`#14295#14279
32
+
* docs(timestamps): clarify that replaceOne() and findOneAndReplace() overwrite timestamps #14337#14309
33
+
1
34
8.1.1 / 2024-01-24
2
35
==================
3
36
* fix(model): throw readable error when calling Model() with a string instead of model() #14288#14281
This [connection](api/connection.html#connection_Connection) object is then used to
430
-
create and retrieve [models](api/model.html#model_Model). Models are
431
-
**always** scoped to a single connection.
429
+
This [connection](api/connection.html#connection_Connection) object is then used to create and retrieve [models](api/model.html#model_Model).
430
+
Models are **always** scoped to a single connection.
432
431
433
432
```javascript
434
433
constUserModel=conn.model('User', userSchema);
435
434
```
436
435
437
-
If you use multiple connections, you should make sure you export schemas,
438
-
**not** models. Exporting a model from a file is called the *export model pattern*.
436
+
The `createConnection()` function returns a connection instance, not a promise.
437
+
If you want to use `await` to make sure Mongoose successfully connects to MongoDB, use the [`asPromise()` function](api/connection.html#Connection.prototype.asPromise()):
438
+
439
+
```javascript
440
+
// `asPromise()` returns a promise that resolves to the connection
441
+
// once the connection succeeds, or rejects if connection failed.
Copy file name to clipboardexpand all lines: docs/middleware.md
+4
Original file line number
Diff line number
Diff line change
@@ -67,13 +67,17 @@ Model middleware is supported for the following model functions.
67
67
Don't confuse model middleware and document middleware: model middleware hooks into *static* functions on a `Model` class, document middleware hooks into *methods* on a `Model` class.
68
68
In model middleware functions, `this` refers to the model.
As the name implies, `findOneAndUpdate()` finds the first document that matches a given `filter`, applies an `update`, and returns the document. By default, `findOneAndUpdate()` returns the document as it was **before**`update` was applied.
14
+
As the name implies, `findOneAndUpdate()` finds the first document that matches a given `filter`, applies an `update`, and returns the document.
15
+
The `findOneAndUpdate()` function has the following signature:
0 commit comments