Saturday, 3 August 2019

some call back issue n clarification

i have to update data in multiple tables, adding data from various tables n then updatingi had huges issues with thatiam using monogodb n mongoose, that .find are the tablenamesso now trying to implement it at a minor levelwhen i call a function, it iterates n push exchange names into an array, i want that function to return only after adding all the data into array, and then return, after completing the total iterationreturn ex?, WILL IT retrun only after adding all the data in array or it can return in midway itselfso how can i code that, i may have missed async await syntx, but i want to be sure that it returns only after pushing all the exchange names in an array, not in a midwayfunction callall(){let abc= getexchgangenames()console.log(abc)}function getexchgangenames(){let ex=[]exchangename.find().exec((err,docs)=>{docs.forEach(kk=>{ex.push(kk.name)})return ex})}

Submitted August 03, 2019 at 09:16AM by aminnagpure

No comments:

Post a Comment