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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -