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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -