-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
extends layout | ||
|
||
append style | ||
link(rel="stylesheet", href="/docs/css/inlinecpc.css") | ||
script(type="text/javascript" src="/docs/js/native.js") | ||
|
||
block content | ||
:markdown | ||
## Deprecation Warnings | ||
|
||
<script> | ||
_native.init("CK7DT53U",{ | ||
targetClass: 'native-inline' | ||
}); | ||
</script> | ||
|
||
<div class="native-inline"> | ||
<a href="#native_link#"><span class="sponsor">Sponsor</span> #native_company# — #native_desc#</a> | ||
</div> | ||
|
||
There are several deprecations in the [MongoDB Node.js driver](http://npmjs.com/package/mongodb) | ||
that Mongoose users should be aware of. Mongoose provides options to work | ||
around these deprecation warnings, but you need to test whether these options | ||
cause any problems for your application. Please [report any issues on GitHub](https://github.com/Automattic/mongoose/issues/new). | ||
|
||
## The `useNewUrlParser` Option | ||
|
||
By default, `mongoose.connect()` will print out the below warning: | ||
|
||
``` | ||
DeprecationWarning: current URL string parser is deprecated, and will be | ||
removed in a future version. To use the new parser, pass option | ||
{ useNewUrlParser: true } to MongoClient.connect. | ||
``` | ||
|
||
The MongoDB Node.js driver rewrote the tool it uses to parse [MongoDB connection strings](https://docs.mongodb.com/manual/reference/connection-string/). | ||
Because this is such a big change, they put the new connection string parser | ||
behind a flag. To turn on this option, pass the `useNewUrlParser` option to | ||
[`mongoose.connect()`](https://mongoosejs.com/docs/api.html#mongoose_Mongoose-connect) | ||
or [`mongoose.createConnection()`](https://mongoosejs.com/docs/api.html#mongoose_Mongoose-createConnection). | ||
|
||
```javascript | ||
mongoose.connect(uri, { useNewUrlParser: true }); | ||
mongoose.createConnection(uri, { useNewUrlParser: true }); | ||
``` | ||
|
||
You can also [set the global `useNewUrlParser` option](https://mongoosejs.com/docs/api.html#mongoose_Mongoose-set) | ||
to turn on `useNewUrlParser` for every connection by default. | ||
|
||
```javascript | ||
// Optional. Use this if you create a lot of connections and don't want | ||
// to copy/paste `{ useNewUrlParser: true }`. | ||
mongoose.set('useNewUrlParser', true); | ||
``` | ||
|
||
To test your app with `{ useNewUrlParser: true }`, you only need to check | ||
whether your app successfully connects. Once Mongoose has successfully | ||
connected, the URL parser is no longer important. If you can't connect | ||
with `{ useNewUrlParser: true }`, please [open an issue on GitHub](https://github.com/Automattic/mongoose/issues/new). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters