Thursday, July 27, 2017

How to Interact With a Database Using the async Module in Node.js

DZone Database Zone
How to Interact With a Database Using the async Module in Node.js

The first pattern we looked at in this series was the Node.js callback pattern. As I mentioned there, that pattern alone will only get you so far. Eventually, you’ll want to construct asynchronous workflows that process elements in a collection serially or run several tasks in parallel. You could write your own library, but why reinvent the wheel when you could just use async, one of the most popular Node.js libraries ever? In this post, we’ll take a look at async to see how it can help you write asynchronous code in Node.js.

async Module Overview

async is not included with Node.js, so it must be installed via NPM (Yarn and Bower work, too) using a command like npm install async –save. A native means to reason about async processing, Promise, eventually made its way into JavaScript and Node.js. We’ll cover promises in the next part of this series. For now, let’s focus on async.

No comments:

Fun With SQL: Functions in Postgres

DZone Database Zone Fun With SQL: Functions in Postgres In our previous  Fun with SQL  post on the  Citus Data  blog, we covered w...