it is required to execute several sql queries to MySQL
I implement the command call through Promise
but the question arose how to make a universal method of processing a sequence of queries sequentially?
more specifically on Promise to implement such a call chain?
class myClass() { constructor() { this.list = [sq1,sql2,sql3]; } function myFunc(i) { ... if(++i < list.length) { if(...) list.push(newSQL); <= {1} <= this.myFunc(i) } } } let m = new MyClass(); m.myFunct(0); UPDATE
Now, one iteration is implemented, the question is how to consistently process the entire list:
myBuy(sql) { return new Promise((resolve, reject) => { ... let promise = global._query(sql); promise .then( data=>resolve(data), err=>reject(err) ) }) } listSQL.forEach((e) => myClass.myBuy(e) )
Promise.allmake a sequential and processing dynamic (padded) array. - ravend{1}. - ravendпоследовательности- ravend