Hello, I use the bluebird tools as follows:
Promise 1
function fntTotalDeRegistros () {
promise.using (db, () => {
db.query ('SELECT COUNT (*) FROM CUSTOMER')
.then ((rows) => {
rows.forEach ((row) => {
qtdRegsARQ = row.registers});
})
.then () => db.close ())
.catch ((error) => {console.log (error), db.close ()});
})
};
Promise 2
unction fntRegistroCli () {
promise.using (db, () => {
db.query ('Select * from DB_ICADIS.CLIENTE ORDER BY cli_codigo')
.then ((rows) => {
rows.forEach ((row) => {
seqCLI + = (+1);
regCLI = func.concatRight ('CLI', 3, '');
destinationCRL = func.concatRight (row.cli_destinator, 20, '');
socialCocial = func.concatRight (row.cli_rozao_social, 40, ");
addressCLI = func.concatRight (row.cli_endereco, 40, '');
neighborhoodCLI = func.concatRight (row.cli_boirro, 25, '');
cepCLI = func.concatRight (row.cli_cep, 8, '0');
municipalityCLI = func.concatRight (row.cli_municipality, 25, '');
ufCLI = func.concatRight (row.cli_uf, 2, ");
telCLI = func.concatRight (row.cli_phone, 8, '0');
cnpjCLI = func.concatRight (row.cli_cnpj, 14, '0');
inscEstCLI = func.concatRight (row.cli_insc_est, 18, '');
typeCloser = func.concatRight (row.cli_people_type, 1, '');
dataLastLastCLI = Func.dataFormaradaAnoMesDia (func.concatRight (row.cli_data_ultima_alt, 10, ''));
// CMP registry
fntRegisterCmp (row.cli_compl_end, seqCLI);
// *** CMP Registry Sequence Control ******
other SeqCMP = seqCLI;
if (seqCLI == seqCMP) {seqCLI + = +1}
other SeqCMP = func.concatLeft (seqCLI, 6, '0')
if (complEndCMP! == null)
{regsCLI + = `$ {regCLI} {{CLI recipient} $ {CSocialSource} $ {CGIers} $ {neighborhoodCLI} $ {cepCLI} {municipalitiesCLI} $ {ufCLI} {telCLI} $ {cnpjCLI} $ {inscEstCLI} $ {typeClosedChart} {dataLastLastCLI} $ {seqCLI} \ n $ {regsCMP} \ n`}
else
{regsCLI + = `$ {regCLI} {{CLI recipient} $ {CSocialSource} $ {CGIers} $ {neighborhoodCLI} $ {cepCLI} {municipalitiesCLI} $ {ufCLI} {telCLI} $ {cnpjCLI} $ {inscEstCLI} $ {typeClosedChart} {dataUltimaLastCLI} $ {seqCLI} \ n`}
}); // end end row
})
.then (() => console.log (regsCLI))
.then () => db.close ())
.catch ((error) => {console.log (error), db.close ()});
})
};
**** AS PROMISSE ARE WORKING ALL Okay *******
now how do I chain the two promisses and also other generic functions! something like that
functionExeCPromise () {
promise1;
promise2;
function ();
funcB ();
......................
}