[Mongoose] (node:42286) 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. の解決方法

Express (Node.js) + Mongoose (MongoDB) という構成の Web アプリケーションで、
(node:42286) 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.
というエラーが発生したときの解決方法をご紹介します。

mongoose | マングース

解決方法 { useNewUrlParser: true } オプションを付けよう

(node:42286) DeprecationWarning エラーメッセージ

(node:42286) 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.

(node:42286) DeprecationWarning 解決前のサンプルコード

const mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URL);

(node:42286) DeprecationWarning 解決後のサンプルコード

const mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URL, { useNewUrlParser: true });

以上、Express + Mongoose で DeprecationWarning 無く開発していきたい、現場からお送りしました。