Asynchronous programming paradigm with nodejs and redis- node

How to translate the following pseudo sync code to async js code

result = [] for pid in r.smembers('active_prog'): for prog_obj in r.hgetall("prog:" + pid): for item_obj in r.hgetall("item:" + prog_obj['iid']): prog_obj['items'].append(item_obj) result.append(prog_obj) return result 

This seems natural when programming synchronization:

  • get some identifiers
  • get elements by id
  • Get relevant information for each item and attach this information to them.
  • merge all elements into an array and return

I tried using MULTI but it doesn't seem to work when the recursion goes deeper.

Is there any recommendation for learning programming in an asynchronous paradigm? (preferably in js code, not in the .net file)

+4
source share

All Articles