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
There are several deprecations in the [MongoDB Node.js driver](http://npmjs.com/package/mongodb)
4
-
that Mongoose users should be aware of. Mongoose provides options to work
5
-
around these deprecation warnings, but you need to test whether these options
6
-
cause any problems for your application. Please [report any issues on GitHub](https://github.com/Automattic/mongoose/issues/new).
7
-
8
-
## Summary {#summary}
9
-
10
-
To fix all deprecation warnings, follow the below steps:
11
-
12
-
* Replace `rawResult: true` with `includeResultMetadata: true` in `findOneAndUpdate()`, `findOneAndReplace()`, `findOneAndDelete()` calls.
13
-
14
-
Read below for more a more detailed description of each deprecation warning.
15
-
16
-
## `rawResult` {#rawresult}
17
-
18
-
As of Mongoose 7.4.0, the `rawResult` option to `findOneAndUpdate()` is deprecated.
19
-
You should instead use the `includeResultMetadata` option, which the MongoDB Node.js driver's new option that replaces `rawResult`.
20
-
21
-
```javascript
22
-
// Replace this:
23
-
constdoc=awaitTest.findOneAndUpdate(
24
-
{ name:'Test' },
25
-
{ name:'Test Testerson' },
26
-
{ rawResult:true }
27
-
);
28
-
29
-
// With this:
30
-
constdoc=awaitTest.findOneAndUpdate(
31
-
{ name:'Test' },
32
-
{ name:'Test Testerson' },
33
-
{ includeResultMetadata:true }
34
-
);
35
-
```
36
-
37
-
The `rawResult` option only affects Mongoose; the MongoDB Node.js driver still returns the full result metadata, Mongoose just parses out the raw document.
38
-
The `includeResultMetadata` option also tells the MongoDB Node.js driver to only return the document, not the full `ModifyResult` object.
3
+
There are no current deprecation warnings for Mongoose 9.x.
0 commit comments