Skip to content

How to use async/await with mongoose.createConnection() ? #12051

Answered by Uzlopak
chriscodes91 asked this question in Q&A
Discussion options

You must be logged in to vote

https://mongoosejs.com/docs/api.html#mongoose_Mongoose-createConnection

Returns:
«Connection» the created Connection object. Connections are not thenable, so you can't do await mongoose.createConnection(). To await use mongoose.createConnection(uri).asPromise() instead.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@chriscodes91
Comment options

@Uzlopak
Comment options

Uzlopak Jul 4, 2022
Collaborator

@chriscodes91
Comment options

Answer selected by chriscodes91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants