Node.js async with events in order

Previously I wrote about Bookshelf, a wonderful and fairly powerful ORM for the Node world (and javascript in general). Considering how new Node really is to the public, that I can do most major things in MySQL with a few simple files and commands is just amazing.

But sometimes you want to do things in an order but the order isn’t know because it hasn’t arrived (new request or websocket message).

In comes a super simple tool called kue.
Here is a tutorial.

This allowed me to use a utility class along with a reversed controller that could accept messages, filter them out and then queue them to be saved to a database. This was required because some messages were updates to previous updates, with out build a super large container with its own comparison system, this allowed the queues to be processed in order, the promises to “.then” handle when the job was done and trigger that so that the next job could be processed.

Continue reading Node.js async with events in order