Mongodb-memory-server: DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`

Created on 24 Aug 2017  路  2Comments  路  Source: nodkz/mongodb-memory-server

When I start my tests I see this:

DeprecationWarning: open() is deprecated in mongoose >= 4.11.0, use openUri() instead, or set the useMongoClient option if using connect() or createConnection(). See http://mongoosejs.com/docs/connections.html#use-mongo-client

Most helpful comment

Fix mongoose deprecationWarning: open()

Following console warning:

(node:5017) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()`
 or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client

Was fixed in mongoose version 4.11.3. It requires small config changes:

- mongoose.connect(await mongod.getConnectionString())
+ mongoose.connect(await mongod.getConnectionString(), { useMongoClient: true })

For more info you may read docs and may see this issues #5423, huge #5399


Thanks for issue, I made proper changes in README.md

All 2 comments

When I run npm run dev then I don't get this message, only when I run my tests.

Fix mongoose deprecationWarning: open()

Following console warning:

(node:5017) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()`
 or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client

Was fixed in mongoose version 4.11.3. It requires small config changes:

- mongoose.connect(await mongod.getConnectionString())
+ mongoose.connect(await mongod.getConnectionString(), { useMongoClient: true })

For more info you may read docs and may see this issues #5423, huge #5399


Thanks for issue, I made proper changes in README.md

Was this page helpful?
0 / 5 - 0 ratings