mirror of
https://github.com/strapi/strapi.git
synced 2025-09-19 13:31:34 +00:00
Connect to mongo db 4.0.x using mongoose 5.7.0
Added support for connection setting useUnifiedTopology so it can be positioned via the database.json file in strapi project. By default it is positioned to false. If this is not set and you are connecting to a mongo db v4.0.x using the beta-16.1 and higher version of the strapi-hook-mongoose you will get the following warning message when starting the strapi server: DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
This commit is contained in:
parent
dc02ba67e3
commit
1bae7943fa
@ -56,6 +56,7 @@ module.exports = function(strapi) {
|
|||||||
password,
|
password,
|
||||||
database,
|
database,
|
||||||
srv,
|
srv,
|
||||||
|
useUnifiedTopology
|
||||||
} = connection.settings;
|
} = connection.settings;
|
||||||
|
|
||||||
const uriOptions = uri ? url.parse(uri, true).query : {};
|
const uriOptions = uri ? url.parse(uri, true).query : {};
|
||||||
@ -85,6 +86,7 @@ module.exports = function(strapi) {
|
|||||||
connectOptions.useNewUrlParser = true;
|
connectOptions.useNewUrlParser = true;
|
||||||
connectOptions.dbName = database;
|
connectOptions.dbName = database;
|
||||||
connectOptions.useCreateIndex = true;
|
connectOptions.useCreateIndex = true;
|
||||||
|
connectOptions.useUnifiedTopology = useUnifiedTopology || 'false';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* FIXME: for now, mongoose doesn't support srv auth except the way including user/pass in URI.
|
/* FIXME: for now, mongoose doesn't support srv auth except the way including user/pass in URI.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user