I'm trying to create a specific structure of data but I'm having troubles with that.
I want to do this:
- Parts
- u_order
- u_familia
- u_part
- u_type
- articles (i want to add an array of articles here)
First, create the array parts:
parts.push(request.query("SELECT u_order, u_familia, u_part, u_type FROM u_part (nolock) where u_order <'92'"));
Next I will iterate this array and for each part I get the articles of this part and I want to add them to parts array:
return Promise.all([Promise.all(parts)]).then(function(listOfResults)
{
var articles = [];
for(var i=0; i<listOfResults[0][0].length; i++)
{
articles.push(request.query("SELECT ststamp, ref, design FROM st WHERE u_posic = '"+listOfResults[0][0][i].u_order+"'"));
}
Promise.all([Promise.all(articles)]).then(function(listOfArticles)
{
console.log("ARTICLES:");
for(var j=0; j<listOfArticles[0][0].length; j++)
{
HERE I WANT TO ADD THE ARTICLE ARRAY TO PART
I TRY USE SPLICE BUT DOESN'T WORK.
}
});
}).catch(function(err)
{
console.log(err);
});
How can I do that?
Thank you