arrays - Coffescript for each loop not finishing before promise return -


im attempting rows.foreach return before bluebird promise. coffeescript section grabbing array object.

rowsselall.foreach (item) ->     item.mid = []     item.mname = []     #log.info 'info', 'items before changes:  '+json.stringify(item)     midandnamequery = 'select * x_files.' + item.uid     connection.query midandnamequery, (errmidname, rowsmidname) ->        # done connection.        try           connection.release()        catch e           log.error 'error', json.stringify(e)        if errmidname           if errmidname.fatal              log.error 'error', 'fatal error in select all: ' + errmidname.message           #else              #log.warn 'warn', 'error select all: ' + errmidname              #reject errmidname        else           #combim data prepare return.           rowsmidname.map (item2) -> item.mid.push item2.mid           rowsmidname.map (item2) -> item.mname.push item2.merchname           #log.info 'info', 'items after changes: '+json.stringify(item)           #log.info 'info', 'array afters: '+json.stringify(rowsselall) log.error 'error', 'calling resolve' resolve rowsselall return 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -