node.js - MongoDB - check if it is connected with async and await? -


how check if mongodb connected async , await?

i tried:

  const db = await mongodb.connect(config.database.url)   db.on('ready',function() {     console.log('database connected');   }) 

i don't 'database connected' db connected.

any ideas?

if mongodb.connect(config.database.url) returns promise, need put console.log('database connected') on next line, because js hold , execution in non-blocking manner until connection established , continue.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -