DEV Community

Discussion on: Using await/async in a Simple Script

Collapse
 
misterhtmlcss profile image
Roger K.

Henry I like your idea here. What are your thoughts on where this could be a bad coding pattern and also where this would be a good pattern to use?

Collapse
 
henryjw profile image
Henry Williams

I generally don't like to use this pattern except for initializing something like a database connection or something of the sort at the end of the script.


module.exports.runQuery = async query => {
    ....
}

(async () => {
    await initializeDatabase()
})()
Enter fullscreen mode Exit fullscreen mode