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
Post a Comment