We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I realized that the mongoose connect is an async function.
Because that, it's possible that the server start without a established mongo connection. (I could generate errors).
I think in something like that:
exports.connect = async () => { await mongoose .connect(mongo.uri, { useCreateIndex: true, keepAlive: 1, useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, }) .then(() => console.log('mongoDB connected...')); return mongoose.connection; };
Or just return mongoose.connect as a promise without then, and await for the resolution of the promise on the other side.
mongoose.connect
then
What do you think about that?
The text was updated successfully, but these errors were encountered:
I think we can just return the value of mongoose.connect, and await it inside a async function (that can be called main or something like this) in https://github.com/danielfsousa/express-rest-es2017-boilerplate/blob/master/src/index.js#L9
async
main
Sorry, something went wrong.
This will be fixed on version 2 #334
No branches or pull requests
I realized that the mongoose connect is an async function.
Because that, it's possible that the server start without a established mongo connection. (I could generate errors).
I think in something like that:
Or just return
mongoose.connect
as a promise withoutthen
, and await for the resolution of the promise on the other side.What do you think about that?
The text was updated successfully, but these errors were encountered: