createConnection does not return a Promise, as it should #11686
Labels
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running createConnection() gives the following error "TypeError: mongoose.createConnection(...).then is not a function"
If the current behavior is a bug, please provide the steps to reproduce.
import mongoose from 'mongoose';
mongoose.createConnection('mongodb://localhost:27017/db', {}).then((db) => {});
What is the expected behavior?
That the function would return a Promise, according to the documentation:
@return {Connection} the created Connection object. Connections are thenable, so you can do
await mongoose.createConnection()
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 6.3.0
The problem is this line: https://github.com/Automattic/mongoose/blob/master/lib/index.js#L286
In Mongoose 5.12.3 its working, and then the code reads:
It returns the Promise created by openUri()
The text was updated successfully, but these errors were encountered: